Numerical Analysis For Engineer - 1
Numerical Analysis For Engineer - 1
′(
𝑓 ′ (𝑥𝑖 − 0)
𝑓 𝑥𝑖 ) = tan 𝜃 =
𝑥𝑖 − 𝑥𝑖+1
𝑓(𝑥𝑖 )
𝑥𝑖+1 − 𝑥𝑖 = − … … . (∗)
𝑓 ′ (𝑥𝑖 )
𝐸𝑥: 𝑏𝑒𝑔𝑖𝑛𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 𝑎𝑛 𝑖𝑛𝑖𝑡𝑖𝑎𝑙 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒 𝑜𝑓 𝑥𝑖 = 5 , 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒 𝑡ℎ𝑒 𝑠𝑖𝑛𝑔𝑙𝑒
𝑟𝑜𝑜𝑡 𝑜𝑓 𝑡ℎ𝑒 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛
𝑒 𝑥 − 10 cos 𝑥 − 100 = 0
𝑠𝑜𝑙: 𝑓 (𝑥𝑖 ) = 𝑒 𝑥 − 10 𝑐𝑜𝑠 𝑥 − 100 … … . . (1)
𝑓 ′ (𝑥𝑖 ) = 𝑒 𝑥 + 10 sin 𝑥 … … … (2)
𝑓 ′(𝑥) = −𝑒 −𝑥 − 1…………..(2)
𝑓(𝑥𝑖 )
𝑥𝑖+1 − 𝑥𝑖 = − … … . (∗)
𝑓 ′ (𝑥𝑖 )
′′ (
𝒇′′ (𝟎)
𝑃′′3 (0) = 2𝑎2 = 𝑓 0 ) → 𝒂𝟐 =
𝟐!
𝑃′′′3 (𝑥 ) = 6𝑎3
′′′ (
𝒇′′′ (𝟎)
𝑃′′′3 (0) = 6𝑎3 = 𝑓 0) → 𝒂𝟑 =
𝟑!
′(
𝒇′′ (𝟎) 𝟐 𝒇′′′ (𝟎) 𝟑
𝑷𝟑 (𝒙) = 𝒇(𝟎) + 𝒇 𝟎)𝒙 + 𝒙 + 𝒙
𝟐! 𝟑!
𝑥
𝑥2 𝑥3
𝑒 =1+𝑥+ + +⋯
2! 3!
If instead of approximating the value of f(x) near zero, we are concerned with value
of x near some other point a.
𝑃𝑛 (𝑥 ) = 𝑎0 + 𝑎1 (𝑥 − 𝑎) + 𝑎2 (𝑥 − 𝑎)2 + ⋯ + 𝑎𝑛 (𝑥−𝑎)𝑛
∴ 𝑡ℎ𝑒 𝑇𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑑 𝑏𝑦 𝑓 𝑎𝑡 𝑥 = 𝑎
′(
𝑓 ′′ (𝑎) 2
𝑓 ′′′ (𝑎)
𝑓(𝑥 ) = 𝑓(𝑎) + 𝑓 𝑎) ∗ (𝑥 − 𝑎) + (𝑥 − 𝑎) + (𝑥 − 𝑎)3 +
2! 3!
𝑓 𝑛 (𝑎)
…+ (𝑥 − 𝑎)𝑛
𝑛!
𝑤ℎ𝑒𝑛 𝑥 → ∞ 𝑡ℎ𝑒 𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑎𝑙 𝑐𝑎𝑙𝑙𝑒𝑑 𝑡𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠.
𝐸𝑥: 𝑢𝑠𝑒 𝑧𝑒𝑟𝑜 𝑡ℎ𝑟𝑜𝑢𝑔ℎ 𝑓𝑜𝑢𝑟𝑡ℎ 𝑜𝑟𝑑𝑒𝑟 . 𝑇𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠 𝑒𝑥𝑝𝑎𝑛𝑠𝑖𝑜𝑛 𝑡𝑜 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑡ℎ𝑒
𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛:
𝑓(𝑎) = √16 = 4
Interpolation :
If a table of values of function f(x) is given it is often necessary to obtain values of
f(x) for value of x between the x-values appearing in the table.
a) Linear interpolation:
The simplest form of interpolation is to connect two data point
with a straight line.
𝑙𝑒𝑡 𝑓1 (𝑥 ) = 𝑎0 + 𝑎1 𝑥 … . (∗)
𝑤ℎ𝑒𝑟𝑒 𝑓1 (𝑥 ) ∶ 𝑙𝑖𝑛𝑒𝑎𝑟 𝑖𝑛𝑡𝑒𝑟𝑝𝑜𝑙𝑎𝑡𝑖𝑜𝑛 𝑓𝑜𝑟𝑚𝑢𝑙𝑎 .
𝑤ℎ𝑒𝑛 𝑥 = 𝑥0 → 𝑓1 (𝑥 ) = 𝑓(𝑥0 )
𝑓 (𝑥0 ) = 𝑎0 + 𝑎1 𝑥0 … … … (1)
𝑤ℎ𝑒𝑛 𝑥 = 𝑥1 → 𝑓1 (𝑥 ) = 𝑓(𝑥1 )
𝑓 (𝑥1 ) = 𝑎0 + 𝑎1 𝑥1 … … … (2)
𝑓𝑟𝑜𝑚 𝑒𝑞 (1)& (2)
𝑓 (𝑥1 ) − 𝑓(𝑥0)
𝑎1 =
𝑥1 − 𝑥0
𝑓(𝑥1 ) − 𝑓(𝑥0 )
𝑎0 = 𝑓(𝑥0 ) −
𝑥1 − 𝑥0
𝑓𝑟𝑜𝑚 𝑒𝑞 (∗)
𝑓(𝑥1 ) − 𝑓(𝑥0 )
𝑓(𝑥 ) = 𝑓(𝑥0 ) + (𝑥 − 𝑥0 )
𝑥1 − 𝑥0
𝐸𝑥: 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒 𝑡ℎ𝑒 𝑙𝑛2 𝑢𝑠𝑖𝑛𝑔 𝑙𝑖𝑛𝑒𝑎𝑟 𝑖𝑛𝑡𝑒𝑟𝑝𝑜𝑙𝑎𝑡𝑖𝑜𝑛 . 𝑢𝑠𝑖𝑛𝑔 ∶
1) ln 1 = 0 , ln 6 = 1.79176
2) ln 1 = 0 , ln 4 = 1.386294
𝑓(𝑥1 ) − 𝑓(𝑥0 )
𝑠𝑜𝑙: 𝑓(𝑥 ) = 𝑓(𝑥0 ) + (𝑥 − 𝑥0 )
𝑥1 − 𝑥0
𝑢𝑠𝑖𝑛𝑔 𝑥 = 1 → ln 1 = 0
𝑥 = 6 → ln 6 = 1.79176
1.79176 − 0
ln 2 = 0 + ∗ (2 − 1)
6−1
ln 2 = 0.3583
𝑢𝑠𝑖𝑛𝑔 𝑤ℎ𝑒𝑛 𝑥 = 1 , ln 1 = 0
𝑥 = 4 , ln 4 = 1.386294
1.386294 − 0
ln 2 = 0 + (2 − 1)
4−1
ln 2 = 0.46209
From calculator ln 2 = 0.69314
b) Quadratic interpolation :
If three data point are available this can be accomplished with a
second order polynomial
𝑓2 (𝑥 ) = 𝑎0 + 𝑎1 𝑥+𝑎2 𝑥 2 … … … (∗∗)
𝑤ℎ𝑒𝑛 𝑥 = 𝑥0 , 𝑓2 (𝑥 ) = 𝑓(𝑥0 )
𝑥 = 𝑥1 , 𝑓2 (𝑥 ) = 𝑓(𝑥1 )
𝑥 = 𝑥2 , 𝑓2 (𝑥 ) = 𝑓(𝑥2 )
𝑓(𝑥0 ) = 𝑎0 + 𝑎1 𝑥0 +𝑎2 𝑥0 2 … … … (1)
𝑓(𝑥1 ) = 𝑎0 + 𝑎1 𝑥1 +𝑎2 𝑥1 2 … … … (2)
𝑓(𝑥2 ) = 𝑎0 + 𝑎1 𝑥2 +𝑎2 𝑥2 2 … … … (3)
𝑓2 (𝑥 ) = 𝑏0 + 𝑏1 (𝑥 − 𝑥0 ) + 𝑏2 (𝑥 − 𝑥1 )(𝑥 − 𝑥0 )
𝑤ℎ𝑒𝑟𝑒; 𝑏0 = 𝑓(𝑥0 )
𝑓(𝑥1 ) − 𝑓(𝑥0 )
𝑏1 =
𝑥1 − 𝑥0
𝑏2 = −0.05187116
𝑓2 (𝑥 ) = 𝑏0 + 𝑏1 (𝑥 − 𝑥0 )+𝑏2 (𝑥 − 𝑥1 )(𝑥 − 𝑥0 )
= 0 + 0.46209(𝑥 − 1) − 0.05187116(𝑥 − 4)(𝑥 − 1)
x=2
𝑙𝑛 2 ≅ 𝑓2 (𝑥 ) = 0.5658446
𝑓1 (𝑥 ) = 0.46209
𝑙𝑛 2 = 0.69314
Numerical Method for Solving First Order D.E
Step by step:
We stand from 𝑦0 = 𝑦(𝑥0 ) and proceed stepwise:
Euler Method
From Taylor series :-
′(
ℎ2 ′′
𝑦(𝑥 + ℎ) = 𝑦(𝑥 ) + ℎ 𝑦 𝑥 ) + 𝑦 (𝑥 ) + ⋯
2!
If we take only two term:
𝑦(𝑥 + ℎ) = 𝑦(𝑥 ) + ℎ 𝑦 ′ (𝑥 )
𝑑𝑦
= 𝑓(𝑥, 𝑦)
𝑑𝑥
Where h is very small
𝑦(𝑥 + ℎ) ≌ 𝑦(𝑥 ) + ℎ𝑓
Where h ≌ step
The step of computing stant
𝑥 = 𝑥0 , 𝑦 = 𝑦0
1. 𝑦1 ≌ 𝑦0 + ℎ 𝑓(𝑥0 , 𝑦0 )
𝑓(𝑥0 , 𝑦0 ) = 𝑠𝑡𝑟𝑒𝑝 𝑜𝑓 𝑐𝑢𝑟𝑣𝑒 𝑎𝑡 𝑥0 , 𝑦0
2. 𝑦2 ≌ 𝑦1 + ℎ 𝑓(𝑥1 , 𝑦1 )
𝑓(𝑥0 , 𝑦0 ) = 𝑠𝑙𝑜𝑝𝑒 𝑜𝑓 𝑡ℎ𝑒 𝑐𝑢𝑟𝑣𝑒 𝑎𝑡 𝑥1 , 𝑦1
..
..
..
𝑦𝑛+1 ≌ 𝑦𝑛 + ℎ 𝑓(𝑥𝑛 , 𝑦𝑛 )
𝒉
In the internal from xn to xn+ , we approximate the solution y by the straight
𝟐
line. Through (xn , yn), with slope f(xn,yn) and then we continue along the
straight line with slope f (xn+1, y*n+1), untile x reach to xn+1
Ex: Apply the improved Euler method to the initial value problem:
y’ = x + y
y(0) = 0 choosing h = 0.2 y1 → y5
sol:
h = 0.2
y*n+1 = yn + h f(xn , yn)
y*n+1 = yn +0.2 (xn+ yn)
improved Euler
yn+1 = yn + 𝒉𝟐 {f (xn , yn) + f(xn+1, y*n+1)}
𝟎.𝟐
yn+1 = yn + { xn + yn+ xn+1 + yn + 0.2 (xn + yn)}
𝟐
Sol:
𝒅𝒚
= 𝒙 + 𝒚 = 𝒇(𝒙, 𝒚)
𝒅𝒙
k2= xn + 𝟎. 𝟏 + yn + 𝟎. 𝟏 k1
𝟏 𝟏
k3= f (xn + h , yn + h k2)
𝟐 𝟐
k3= xn + 𝟎. 𝟏 + yn + 𝟎. 𝟏 k2)
k4= f (xn + h , yn + h k3)
k4= xn + 0.2 + yn + 0.2 k3)
𝟏
yn+1= yn + { (k1 + 2 k2 + 3 k3 + k4)} h
𝟔
n xn yn k1 k2 k3 k4 yn+1
0 0 0 0 0.1 0.11 0.222 0.0214
1 0.2 0.0214 0.2214 0.3435 0.3557 0.4926 0.09182
2 0.4 0.09182 0.4918 0.641 0.6559 0.823 0.2221
3 0.6 0.2221 0.8221 1.0043 1.0225 1.2266 0.4255
4 0.8 0.4255 1.2255 1.448 1.47 1.7196 0.718
5 1 0.718