Chapter 5c Numerical Differentiation - Full
Chapter 5c Numerical Differentiation - Full
f ' ' ( xi ) 2
f ( xi +1 ) = f ( xi ) + f ' ( xi )h + h + .........
2!
Taylor Series
f ( n +1) ( ) n +1
and Rn is the remainder term Rn = h = O(h n +1 )
(n + 1)!
Forward Finite Difference
f (xi +1 ) − f (xi )
f ' (xi ) = + O ( h) Forward difference
h approximation
Forward Divided Difference
f ( xi + 1 ) − f ( xi ) f i
f ' ( xi ) = + O( xi + 1 − xi ) = + O( h)
xi + 1 − xi h
f(x)
x
Forward Divided Difference
f ( xi + 1 ) − f ( xi ) f i
f ' ( xi ) = + O( xi + 1 − xi ) = + O( h)
xi + 1 − xi h
f(x)
(x i+1,y i+1)
x
Forward Divided Difference
f ( xi + 1 ) − f ( xi ) f i
f ' ( xi ) = + O( xi + 1 − xi ) = + O( h)
xi + 1 − xi h
f(x)
How does (x i+1,y i+1)
this compare
to the actual (xi, yi)
first derivative
at xi?
x
Forward Divided Difference
f ( xi + 1 ) − f ( xi ) f i
f ' ( xi ) = + O( xi + 1 − xi ) = + O( h)
xi + 1 − xi h
f(x)
(x i+1,y i+1)
(xi, yi)
x
Forward Divided Difference
f i
f ' ( xi ) = + O( h) Error is proportional to
h the step size
(xi,yi)
(xi-1,yi-1)
x
Centered Difference Approximation of the
First Derivative
f (3) (xi ) 3
f ( xi +1 ) = f (xi −1 ) + 2 f ' (xi )h + h +
3!
f (xi +1 ) − f (xi −1 )
f ' ( xi ) =
2h
( )
− O h2
f ( xi +1 ) − f ( xi −1 )
f(x) f ' ( xi ) = − O(h 2 )
2h
(xi+1,yi+1)
(xi,yi)
(xi-1,yi-1)
x
f(x) f(x)
forward
true derivative
finite divided
difference approx.
x x
f(x) f(x)
backward centered
finite divided finite divided
difference approx. difference approx.
x x
Deriving more accurate version of
the divided difference formula
Let’s return back to the derivation of the forward difference formula
By substituting the f ( xi + 2 ) − 2 f ( xi +1 ) + f ( xi )
following approximation for f " ( x) = + O ( h)
the second derivative: h2
− f ( xi + 2 ) + 4 f ( xi +1 ) − 3 f ( xi )
Or by collecting terms f ' (xi ) = + O( h 2 )
2h
Forward finite-divided-difference
formulas
Backward finite-divided-difference
formulas
Centered finite-divided-difference
formulas
Example 1
Given the following function, use finite divided difference
(with error of O(h2)) to estimate the derivative at x = 2.2
using step size h = 0.6 , h=0.2 Forward , backward
and centre, then calculate true percentage error.
H=0.2 F(x) H=0.6 F(x)
f(x) = 50cos 3x 2
Xi-2 + ln 3x 1.8 -46.15 1.0 -48.4010
Xi-1 2 43.984 1.6 10.2239
xi 2.2 -16.7904 2.2 -16.7904
2 x − xi − xi +1 2 x − xi −1 − xi +1
f ' ( x) = f ( xi −1 ) + f ( xi )
( xi −1 − xi )( xi −1 − xi +1 ) ( xi − xi −1 )( xi − xi +1 )
2 x − xi − xi −1
+ f ( xi +1 )
( xi +1 − xi )( xi +1 − xi −1 )
Derivatives of Unequally Spaced
Data
⚫ Refer to example problem 23.3 from the
text book
…..end of lecture