Numerical Differentiation 1
Numerical Differentiation 1
Numerical Differentiation
1
Numerical Analysis 0905201
Chapter 18
ND – Part(1)
2
Introduction
3) To obtain some higher derivative without going through the lower derivatives.
4) To find the derivative(s) for some data points without having to do interpolation.
1) Forward Difference Approximation of the 1st Derivative
Which is:
Example x y
1 2
Given that
5 3
9 5
14 10
Find the value of 𝑓′(5) using the forward difference approximation of the 1st derivative.
Solution
𝒇(𝟖) − 𝒇(𝟓) 𝟒 − 𝟏
𝒇′ 𝟓 = = =𝟏
𝟖−𝟓 𝟖−𝟓
2) Backward Difference Approximation of the 1st Derivative
→ ℎ = 𝑥𝑖 − 𝑥𝑖−1
Example
Given that
x y
14 -1
20 3
26 12
Find the value of 𝑓′(26) using the backward difference approximation of the 1st derivative.
Solution
′
𝑓(26) − 𝑓(20) 12 − 3
𝑓 26 = = = 1.5
26 − 20 6
3) Centered Difference Approximation of the 1st Derivative
→ ℎ = 𝑥𝑖+1 − 𝑥𝑖 𝑜𝑟 ℎ = 𝑥𝑖 − 𝑥𝑖−1
Example
Given that
x y
14 -1
20 3
26 12
Find the value of 𝑓′(20) using the centered difference approximation of the 1st derivative.
Solution
𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖−1 )
=
2(𝑥𝑖+1 − 𝑥𝑖 )
𝑓(26) − 𝑓(14) 12 − −1 13
∴ 𝑓′ 20 = = =
2(26 − 20) 12 12
Approximation of the 1st Derivative
′ 𝑓(𝑥𝑖+1 )−𝑓(𝑥𝑖 )
Forward approximation : 𝑓 𝑥𝑖 = + 𝑂(ℎ) ℎ = 𝑥𝑖+1 − 𝑥𝑖
ℎ
𝑓(𝑥𝑖 )−𝑓(𝑥𝑖−1 )
Backward approximation : 𝑓′ 𝑥𝑖 = +𝑂 ℎ ℎ = 𝑥𝑖 − 𝑥𝑖−1
ℎ
𝑓(𝑥𝑖+1 )−𝑓(𝑥𝑖−1 )
Centered approximation : 𝑓′ 𝑥𝑖 = +𝑂(ℎ2 ) ℎ = 𝑥𝑖 − 𝑥𝑖−1
2ℎ
ℎ = 𝑥𝑖+1 − 𝑥𝑖
Relative True Error 𝜺𝒕
Calculate when:
a) h = 1
b) h = 0.5
Solution 𝒇 𝒙 = 𝒙𝟑 + 𝟑 𝒙 − 𝟏 Find 𝒇′(𝟐)
a) When h = 1
𝑥𝑖−1 = 𝑥𝑖 − ℎ = 1 𝑓 1 =3
𝑥𝑖 = 2 𝑓 2 = 13
𝑥𝑖+1 = 𝑥𝑖 + ℎ = 3 𝑓 3 = 35
𝜀𝑡 = 46.6 %
Solution 𝒇 𝒙 = 𝒙𝟑 + 𝟑 𝒙 − 𝟏 Find 𝒇′(𝟐)
a) When h = 1
𝑥𝑖−1 = 𝑥𝑖 − ℎ = 1 𝑓 1 =3
𝑥𝑖 = 2 𝑓 2 = 13
𝑥𝑖+1 = 𝑥𝑖 + ℎ = 3 𝑓 3 = 35
𝜀𝑡 = 33.3 %
Solution 𝒇 𝒙 = 𝒙𝟑 + 𝟑 𝒙 − 𝟏 Find 𝒇′(𝟐)
a) When h = 1
𝑥𝑖−1 = 𝑥𝑖 − ℎ = 1 𝑓 1 =3
𝑥𝑖 = 2 𝑓 2 = 13
𝑥𝑖+1 = 𝑥𝑖 + ℎ = 3 𝑓 3 = 35
𝜀𝑡 = 6.66 %
Solution 𝒇 𝒙 = 𝒙𝟑 + 𝟑 𝒙 − 𝟏 Find 𝒇′(𝟐)
b) When h = 0.5
𝑥𝑖 = 2 𝑓 2 = 13
𝜀𝑡 = 21.66 %
Solution 𝒇 𝒙 = 𝒙𝟑 + 𝟑 𝒙 − 𝟏 Find 𝒇′(𝟐)
b) When h = 0.5
𝑥𝑖 = 2 𝑓 2 = 13
𝜀𝑡 = 18.33 %
Solution 𝒇 𝒙 = 𝒙𝟑 + 𝟑 𝒙 − 𝟏 Find 𝒇′(𝟐)
b) When h = 0.5
𝑥𝑖 = 2 𝑓 2 = 13
𝜀𝑡 = 1.66 %
Solution
h=1 h = 0.5
value 𝜺𝒕 value 𝜺𝒕
𝑻𝒓𝒖𝒆 𝒗𝒂𝒍𝒖𝒆 𝒐𝒇 𝒇′ 𝟐 = 𝟏𝟓
Richardson Extrapolation
𝟒 𝟏
𝑫= 𝑫 𝒉𝟐 − 𝑫(𝒉𝟏 )
𝟑 𝟑
Example
Using the results from example 4 from the previous lecture, use the
approximations obtained from the centered method with Richardson
extrapolation to find the 𝑓′(2), given that the true value of 𝒇′ 𝟐 = 𝟏𝟓
𝒇 𝒙 = 𝒙𝟑 + 𝟑𝒙 − 𝟏
Solution
ℎ1 = 1 , ℎ2 = 0.5
4 1
𝐷 = 𝐷 ℎ2 − 𝐷 ℎ1
3 3
4 1
𝐷 = (15.25) − (16)
3 3
𝐷 = 15
𝑻𝒓𝒖𝒆 𝒗𝒂𝒍𝒖𝒆 −𝑨𝒑𝒑𝒓𝒐𝒙𝒊𝒎𝒂𝒕𝒆 𝒗𝒂𝒍𝒖𝒆 𝟏𝟓 −𝟏𝟓
𝜺𝒕 = . 𝟏𝟎𝟎 % ⇒ 𝜺𝒕 = . 𝟏𝟎𝟎 %
𝑻𝒓𝒖𝒆 𝒗𝒂𝒍𝒖𝒆 𝟏𝟓
𝜺𝒕 = 0 %