Numerical Differentiation
Numerical Differentiation
Numerical Differentiation
Learning Outcomes:
At the end of the topic, the students have:
1. derived the formulas of the three methods of differentiation,
namely; backward difference, forward difference and centered
difference.
2. calculated the approximate derivative of a given function.
3. Determined the improved derivative of a given function.
Concept:
The first derivative of a function at a given point is also the
tangent or slope of the function at that specified point. There are some
engineering functions whose derivative cannot be determined by the
exact differentiation formulas or by canned software.
True Slope
Approximate Slope
f(xi)
f(xi+1)
f(x)
h
(step size)
0 xi xi+1
'
f ( x i+1 ) −f ( xi )
f (x )=
h
2. Backward Differentiation
Forward differentiation requires a point xi-1 backward of a
specified point, xi with interval, h called as step size to estimate
the derivative of a function (see figure below). The approximate
slope is the line connecting the points in the curve f(xi-1) and
f(xi).
True Slope
Approximate Slope
f(xi)
f(xi-1)
f(x)
h
(step size)
0 xi-1 xi
'
f ( x i )−f ( x i−1)
f (x )=
h
3. Centered Differentiation
Centered differentiation requires two points forward and
backward of a specified point, xi with intervals, h to estimate
the derivative of a function (see figure below). The approximate
slope is the line connecting the points in the curve f(xi-1) and
f(xi+1).
True Slope
Approximate Slope
f(xi)
f(xi-1) f(xi+1)
f(x)
h h
0 xi-1 xi xi+1
'
f ( x i+1 ) −f ( xi−1 )
f (x )=
2h
Example 1:
Solution:
h = 0.2
Needed data:
x f(x)
xi-1 0.3 1.045336
xi 0.5 1.127582
xi+1 0.7 1.254842
x i−1=0.5−0.2=0.3
f ( x i−1 )= ( 0.3 )2+ cos( 0.3¿)=1.045336 ¿
1. Forward Differentiation
1.254842−1.127582
f ' ( x )= =0.636298
0.20
2. Backward Differentiation
1.127582−1.045336
f ' ( x )= =0.411230
0.20
3. Centered Differentiation
1.254842−1.045336
f ' ( x )= =0.523764
2(0.20)
Comments:
'
−f ( x i+ 2) + 4 f ( xi +1 )−3 f ( x i)
f (x )=
2h
2. Backward Differentiation
'
3 f ( x i )−4 f ( x i−1 ) + f (x i−2)
f (x )=
2h
3. Centered Differentiation
'
−f ( x i+ 2) + 8 f ( x i+1 )−8 f ( x i−1) + f (x i−2)
f (x )=
12h
Example 2:
Solution:
1. Forward Differentiation
'
−f ( x i+ 2) + 4 f ( xi +1 )−3 f ( x i)
f (x )=
2h
3. Centered Differentiation
'
−f ( x i+ 2) + 8 f ( x i+1 )−8 f ( x i−1) + f (x i−2)
f (x )=
12h
f ' ( x )=−1.431610+8 ¿ ¿
Comments:
a. The answers have small differences.
b. The true errors are 1.54%, 0.88% and 0.005%, respectively.
c. The answers are much better that using the approximate
formulas.
d. Centered differentiation gives the best answer.
4 1
D= D ( h 2) − D ( h1 )
3 3
Solution:
For h1 = 0.2;
D1 = 0.523764
h1
For h2 = = 0.1;
2
Needed data:
x f(x)
xi-1 0.4 1.081061
xi 0.5 1.127582
xi+1 0.6 1.185336
1.185336−1.081061
D 2= =0.521375
2(0.10)
4 1
D= ( 0.521375 )− ( 0.523764 )=0.520579
3 3
References: