Professional Documents
Culture Documents
Computational Methods
Week 2(4), Lecture 6
-Finite Difference Approximations
of Higher DerivativesLecturer: Dr Azizan
azizan1957@gmail.com
January 22,2015
Thursday Repl class
Dr Azizan
Lesson outcome
At the end of this session, you should be able
to use a centered difference approximation of
O(h2) to estimate the second derivative of a
function.
January 22,2015
Thursday Repl class
Dr Azizan
.....(19)
2!
3!
Recall the Forward Taylor series expansion;
f ( xi ) 2 f (3) ( xi ) 3
f ( xi 1 ) f ( xi ) f ' ( xi )
h
h ................(12)
2!
3!
and multiplying (12) by 2 and subtracting it from (19);
January 22,2015
Thursday Repl class
Dr Azizan
......Rn (19)
2!
3!
2 f ( xi ) 2 2 f (3) ( xi ) 3
2 f ( xi 1 ) 2 f ( xi ) 2 f ' ( xi )h
h
h ..... 2 Rn
2!
3!
7 f ( 4 ) ( xi ) 4
f ( xi 2 ) 2 f ( xi 1 ) f ( xi ) f ( xi )h f ( xi )h
h ... Rn
12
Now truncate the series after the second derivative;
2
( 3)
f ( xi 2 ) 2 f ( xi 1 ) f ( xi ) f ( xi )h 2 R2
f ( xi 2 ) 2 f ( xi 1 ) f ( xi ) R2 f ( xi )h 2
'second forward finite difference'
f ( xi 2 ) 2 f ( xi 1 ) f ( xi ) R2
f ( xi )
2
h
f ( xi 2 ) 2 f ( xi 1 ) f ( xi )
O(h) f ( xi ).............(20)
2
h
7 f ( xi ) 2
( 3)
where O(h) f ( xi )h
h ....
12
January 22,2015
Thursday Repl class
Dr Azizan
Exercise
Perform manipulations to obtain a 'second
backward finite difference'
f ( xi ) 2 f ( xi 1 ) f ( xi 2 )
f ( xi )
O(h)......(21)
2
h
( 4)
7
f
( xi ) 2
( 3)
where O(h) f ( xi )h
h ......
12
January 22,2015
Thursday Repl class
Dr Azizan
Exercise
Perform manipulations to obtain a 'second
centered finite difference'
f ( xi 1 ) 2 f ( xi ) f ( xi 1 )
2
O
(
h
)......(21)
2
h
( 4)
(6)
f
(
x
)
f
( xi ) 4
2
2
i
where O(h )
h
h ......
12
360
Alternatively, the second centered finite difference
can be expressed as
f ( xi 1 ) f ( xi ) f ( xi ) f ( xi 1 )
h
h
f ( xi )
.....(23)
h
f ( xi )
January 22,2015
Thursday Repl class
Dr Azizan
Example
Use a centered difference approximation of O(h 2 )
to estimate the second derivative of the function
f ( x) 25 x 3 6 x 2 7 x 88
at x 2 using step sizes h 0.25 and 0.125.
Compare your estimates with the true value of
the second derivative. Interpret your results on
the basis of the remainder term of the Taylor series
expansion.
January 22,2015
Thursday Repl class
Dr Azizan
Solution
f ( x) 25 x 3 6 x 2 7 x 88
f ' ( x) 75 x 12 x 7
f ( x) 150 x 12
The true value of the second derivative at x 2 is
f (2) 150(2) 12 288
2
January 22,2015
Thursday Repl class
Dr Azizan
Solution
Using h 0.25
xi-1 1.75
xi 2
f ( xi ) f (2) 102
xi 1 2.25
f ( xi 1 ) f (2.25)
f ( xi 1 ) 2 f ( xi ) f ( xi 1 )
f ( xi )
h2
f (2.25) 2 f (2) f (1.75)
f (2)
288.
2
(0.25)
January 22,2015
Thursday Repl class
Dr Azizan
Solution
Using h 0.125
f ( xi 1 ) 2 f ( xi ) f ( xi 1 )
f ( xi )
h2
f (2.125) 2 f (2) f (1.875)
f (2)
2
(0.125)
139.6738 2(102) 68.82617)
288
2
(0.125)
January 22,2015
Thursday Repl class
Dr Azizan
10
Conclusion
Both results are exact because the errors are a
function of 4th and higher derivatives which
are zero for a 3rd order polynomial function.
January 22,2015
Thursday Repl class
Dr Azizan
11
Homework
Consider the function f ( x) x 2 x 4 on
the interval [2,2] with h 0.25. Find the
first and second derivatives of the function
3
January 22,2015
Thursday Repl class
Dr Azizan
12