Beruflich Dokumente
Kultur Dokumente
eating
Introduction
• Some numerical algorithms require
evaluation of the derivative of a function.
DN +1 − DN ≥ DN − DN −1
• In the example,
0.0007 = D6 − D5 > D5 − D4 = 0.00012
Sources of error
• The truncation error εt comes from higher
terms in the Taylor series expansion:
f (x + h ) − f (x ) 1
f '= − hf "− L
h 2
• Round-off error εr must be expected since
real numbers don’t have exact
representation in binary.
Central-difference formulas
• Assume that f ∈C3[a,b] and that x-h, x, x+h
∈[a,b]. Then
f (x + h ) − f (x − h )
f ' (x ) ≈ + εt ( 2)
2h
where, there exists a number c=c(x) ∈[a,b]
such that
h 2 f (3 ) (c )
εt = −
6
( )
= O h2
Centered-formula of order O(h4)
Assume that f ∈C5[a,b] and that x-2h, x-h, x
x+h, x+2h ∈[a,b]. Then
− f ( x + 2h ) + 8 f ( x + h ) − 8 f ( x − h ) + f ( x − 2h )
f ' (x ) ≈ + εt
12h
(3)
where
h 4 f (5 ) (c )
εt = −
30
= O h4 ( )
Example
Let f(x)=cos(x). Calculate approximations for
f’(0.8) using Eqs. (2) and (3) with step
sizes h=0.1, 0.01, 0.001, 0.0001 and
compare with true value f’(0.8) = -sin(0.8).
• Differentiating
P2 ' (0.8) = −0.716161095
Differentiating an
Interpolating Polynomial
• The Lagrange quadric polynomial P4(x)
that passes through x=0.6,0.7,0.8, 0.9 and
1.0.
P4 ( x ) = 0.998452927 + 0.00963839 x − 0.523291341x 2
+ 0.026521229 x 3 + 0.028981100 x 4
• Differentiating
P4 ' (0.8) = −0.717353703
Differentiation using Limits
To approximate f ’(x) numerically, generate a
sequence
(
f ' ( x ) ≈ Dk =
−k
) ( −k
f x + 10 h − f x − 10 h )
( )−k
2 10 h
− f 2 + 16 f1 − 30 f 0 + 16 f −1 − f − 2
f " ( x0 ) ≈ 2
12h