Beruflich Dokumente
Kultur Dokumente
Introduction
• Some numerical algorithms require
evaluation of the derivative of a function.
Numerical Differentiation • When the function is difficult to
differentiate analytically or when the
function is given empirically as in table of
values, approximate calculation of the
derivative is necessary.
eating
1
9/15/2009
Differentiating an
Example
Interpolating Polynomial
Eq. (2) • The Lagrange quadratic polynomial P2(x)
f x h x h
f ' x that passes through x=0.7,0.8, and 0.9.
2h
Eq. (3)
P2 x 1.046875165 0.159260044 x 0.348063157 x 2
f x 2h 8 f x h 8 f x h f x 2h
f ' x
12h
• Differentiating
2
9/15/2009
Differentiating an
Differentiation using Limits
Interpolating Polynomial
• The Lagrange quadric polynomial P4(x) To approximate f ’(x) numerically, generate a
that passes through x=0.6,0.7,0.8, 0.9 and sequence
1.0.
f ' x Dk
f x 10 k h f x 10 k h
P4 x 0.998452927 0.00963839 x 0.523291341x 2
2 10k h
0.026521229x 3 0.028981100x 4
for k=0,..,n until |Dn+1 – Dn| ≥ |Dn-1 – Dn| or
• Differentiating |Dn – Dn-1|≤ tolerance.
P4 ' 0.8 0.717353703
3
9/15/2009
4
9/15/2009
Example Example
Let f(x)=cos(x). Use the formula • The calculation for h=0.01 is
f1 2 f 0 f 1 f 0.81 2 f 0.80 f 0.79
f "x f " 0.8 0.696690000
h2 0.0001
Exercise 1 Exercise 2
Let f(x)=sin(x), where x is measured in Use numerical differentiation formula
radians.
(a) Calculate approximations to f ’(0.8) f 2 16 f1 30 f 0 16 f 1 f 2
f " x0
using Eq.(3) with h=0.1, 0.01, and 12h 2
compare with f ’( 0.8)=cos(0.8).
and h=0.1 to approximate f ”(1) for the
(b) Use extrapolation formula to compute functions
the approximation to f ’( 0.8)
(a) f(x) = x2 (b) f(x) = x4