0% found this document useful (0 votes)
63 views

Numerical Analysis For Engineer - 1

The document discusses numerical analysis techniques including: 1) The Newton Raphson method for finding roots of equations using iteration, starting with an initial guess and updating the guess using the slope of the tangent line. 2) Taylor series approximations which represent a function as a polynomial by determining coefficients from the values and derivatives of the function evaluated at a specific point. 3) Examples are provided to demonstrate applying Newton Raphson method to find roots of equations and using Taylor series to approximate functions near a given point.

Uploaded by

Nazli Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Numerical Analysis For Engineer - 1

The document discusses numerical analysis techniques including: 1) The Newton Raphson method for finding roots of equations using iteration, starting with an initial guess and updating the guess using the slope of the tangent line. 2) Taylor series approximations which represent a function as a polynomial by determining coefficients from the values and derivatives of the function evaluated at a specific point. 3) Examples are provided to demonstrate applying Newton Raphson method to find roots of equations and using Taylor series to approximate functions near a given point.

Uploaded by

Nazli Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Numerical analysis

Numerical analysis for engineer by Stephen Chapra


Newton Raphson- method ( solution of equation by iteration)

Newton Raphson- method:

Is a method of root location formula?

Xi= is initial guess at the root

f ’(Xi)= is the tangent of the curve at the

point [Xi , f (Xi) ]

′(
𝑓 ′ (𝑥𝑖 − 0)
𝑓 𝑥𝑖 ) = tan 𝜃 =
𝑥𝑖 − 𝑥𝑖+1
𝑓(𝑥𝑖 )
𝑥𝑖+1 − 𝑥𝑖 = − … … . (∗)
𝑓 ′ (𝑥𝑖 )
𝐸𝑥: 𝑏𝑒𝑔𝑖𝑛𝑖𝑛𝑔 𝑤𝑖𝑡ℎ 𝑎𝑛 𝑖𝑛𝑖𝑡𝑖𝑎𝑙 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒 𝑜𝑓 𝑥𝑖 = 5 , 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒 𝑡ℎ𝑒 𝑠𝑖𝑛𝑔𝑙𝑒
𝑟𝑜𝑜𝑡 𝑜𝑓 𝑡ℎ𝑒 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛
𝑒 𝑥 − 10 cos 𝑥 − 100 = 0
𝑠𝑜𝑙: 𝑓 (𝑥𝑖 ) = 𝑒 𝑥 − 10 𝑐𝑜𝑠 𝑥 − 100 … … . . (1)
𝑓 ′ (𝑥𝑖 ) = 𝑒 𝑥 + 10 sin 𝑥 … … … (2)

𝑖 𝑥𝑖 𝑓 (𝑥𝑖 ) 𝑓 ′ (𝑥𝑖 ) 𝑥𝑖+1 − 𝑥𝑖


1 5 45.5765 138.823 −0.3283
2 4.67169 7.28509 96.88 -0.0752
3 4.596 0.292 89.2 -0.00328
4 4.593 0.00052 88.882 -0.000006
5 4.593 −2 ∗ 10−8 88.881 2.25 ∗ 10−10
𝐸𝑥: 𝑢𝑠𝑒 𝑡ℎ𝑒 𝑛𝑒𝑤𝑡𝑜𝑛 𝑅𝑎𝑝ℎ𝑠𝑜𝑛 𝑚𝑒𝑡ℎ𝑜𝑑 𝑡𝑜 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒 𝑡ℎ𝑒 𝑟𝑜𝑜𝑡 𝑜𝑓 𝑒 −𝑥 − 𝑥
𝑒𝑚𝑝𝑙𝑜𝑦𝑖𝑛𝑔 𝑎𝑛 𝑖𝑛𝑖𝑡𝑖𝑎𝑙 𝑔𝑢𝑒𝑠𝑠 𝑜𝑓 𝑥𝑖 = 0
𝑠𝑜𝑙: 𝑓 (𝑥 ) = 𝑒 −𝑥 − 𝑥 ……..(1)

𝑓 ′(𝑥) = −𝑒 −𝑥 − 1…………..(2)
𝑓(𝑥𝑖 )
𝑥𝑖+1 − 𝑥𝑖 = − … … . (∗)
𝑓 ′ (𝑥𝑖 )

𝑖 𝑥𝑖 𝑓 (𝑥𝑖 ) 𝑓′(𝑥𝑖 ) 𝑥𝑖+1 − 𝑥𝑖


1 0 1 -2 0.5
2 0.5 0.10653 -2.64872 -0.0402
Taylor series
𝑃𝑘 (𝑥 ) = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ + 𝑎𝑘 𝑥 𝑘 (𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑎𝑙)
𝑤ℎ𝑒𝑟𝑒; 𝑎0 , 𝑎1 , 𝑎2 , … , 𝑎𝑘 : 𝑎𝑟𝑒 𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡
𝑙𝑒𝑡 𝑘 = 3 → 𝑃3 (𝑥 ) = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3
𝑤ℎ𝑒𝑟𝑒 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 , … , 𝑎𝑘 : 𝑎𝑟𝑒 𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑤ℎ𝑖𝑐ℎ 𝑎𝑟𝑒 𝑒𝑣𝑎𝑙𝑢𝑎𝑡𝑒𝑑
𝑓𝑟𝑜𝑚 𝑝𝑜𝑖𝑛𝑡 [0, 𝑓(0)]
𝑃3 (0) = 𝑎0 = 𝑓 (0)
𝑃′3 (𝑥 ) = 𝑎1 + 2𝑎2 𝑥 + 3𝑎3 𝑥 2
𝑃′3 (0) = 𝑎1 = 𝑓 ′ (0)
𝑓 ′ (0) = 𝑎1
𝑃′′3 (𝑥 ) = 2𝑎2 + 6𝑎3 𝑥

′′ (
𝒇′′ (𝟎)
𝑃′′3 (0) = 2𝑎2 = 𝑓 0 ) → 𝒂𝟐 =
𝟐!
𝑃′′′3 (𝑥 ) = 6𝑎3

′′′ (
𝒇′′′ (𝟎)
𝑃′′′3 (0) = 6𝑎3 = 𝑓 0) → 𝒂𝟑 =
𝟑!

′(
𝒇′′ (𝟎) 𝟐 𝒇′′′ (𝟎) 𝟑
𝑷𝟑 (𝒙) = 𝒇(𝟎) + 𝒇 𝟎)𝒙 + 𝒙 + 𝒙
𝟐! 𝟑!

𝑤ℎ𝑒𝑛 𝑥 → ∞ 𝑡ℎ𝑒 𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑎𝑙 𝑐𝑎𝑙𝑙𝑒𝑑 𝑚𝑎𝑐𝑙𝑢𝑟𝑖𝑎𝑛 𝑠𝑒𝑟𝑖𝑒𝑠


𝐸𝑥: 𝑓𝑖𝑛𝑑 𝑇𝑎𝑦𝑙𝑜𝑟 𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑎𝑙 𝑝𝑛 (𝑥 )𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑑 𝑏𝑦 𝑓 (𝑥 ) = 𝑒 𝑥 𝑎𝑡 𝑥 = 0
𝑠𝑜𝑙: 𝑇𝑎𝑦𝑙𝑜𝑟 𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑎𝑙

𝑓 ′ (0) 𝑓 ′′ (0) 2 𝑓 ′′′ (0) 3


𝑓(𝑥 ) = 𝑓(0) + 𝑥+ 𝑥 + 𝑥 +⋯
1! 2! 3!
𝑓(𝑥 ) = 𝑒 𝑥 , 𝑓 (0) = 1
𝑓 ′ (𝑥 ) = 𝑒 𝑥 , 𝑓 ′ (0) = 1
𝑓 ′′ (𝑥 ) = 𝑒 𝑥 , 𝑓 ′′ (0) = 1
𝑓 ′′′ (𝑥 ) = 𝑒 𝑥 , 𝑓 ′′′ (0) = 1

𝑥
𝑥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!
𝑓 𝑛 (𝑎)
…+ (𝑥 − 𝑎)𝑛
𝑛!
𝑤ℎ𝑒𝑛 𝑥 → ∞ 𝑡ℎ𝑒 𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑎𝑙 𝑐𝑎𝑙𝑙𝑒𝑑 𝑡𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠.
𝐸𝑥: 𝑢𝑠𝑒 𝑧𝑒𝑟𝑜 𝑡ℎ𝑟𝑜𝑢𝑔ℎ 𝑓𝑜𝑢𝑟𝑡ℎ 𝑜𝑟𝑑𝑒𝑟 . 𝑇𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠 𝑒𝑥𝑝𝑎𝑛𝑠𝑖𝑜𝑛 𝑡𝑜 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑡ℎ𝑒

𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛:

𝑓(𝑥 ) = −0.1 𝑥 4 − 0.15 𝑥 3 − 0.5 𝑥 2 − 0.25 𝑥 + 1.2


𝑓𝑟𝑜𝑚 𝑥𝑖 = 0 𝑤𝑖𝑡ℎ ℎ = 1
𝑡ℎ𝑎𝑡 𝑝𝑟𝑒𝑑𝑖𝑐𝑡 𝑡ℎ𝑒 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑣𝑎𝑙𝑢𝑒 𝑎𝑡 𝑥 = 1
𝑠𝑜𝑙: 𝑓𝑟𝑜𝑚 𝑡𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠 ∶
𝑓 ′ (𝑎) 𝑓 ′′ (𝑎) 2
𝑓 ′′′ (𝑎)
𝑓(𝑥 ) = 𝑓(𝑎) + (𝑥 − 𝑎) + (𝑥 − 𝑎) + (𝑥 − 𝑎)3 +
1! 2! 3!
𝑓 ′′′′ (𝑎)
(𝑥 − 𝑎)4 + ⋯
4!
𝑓(𝑎) = 𝑓(0) = 1.2
𝑓 ′ (𝑎) = 𝑓 ′ (0) = −0.25
𝑓 ′′ (𝑎) = 𝑓 ′′ (0) = −1
𝑓 ′′′ (𝑎) = 𝑓 ′′′ (0) = −0.9
𝑓 ′′′′ (𝑎) = 𝑓 ′′′′ (0) = −2.4
𝑓 ′′′′′ (𝑎) = 𝑓 ′′′′′ (0) = 0
𝑓𝑟𝑜𝑚 𝑡𝑎𝑦𝑙𝑒𝑟 𝑠𝑒𝑟𝑖𝑒𝑠
0.25 1 0.9 2.4
𝑓(𝑥 ) = 1.2 − (1 − 0) − (1 − 0)2 − (1 − 0)3 − (1 − 0)4
1! 2! 3! 4!
𝑓(𝑥 ) = 0.2
𝐸𝑥: 𝑢𝑠𝑒 𝑇𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠 𝑡𝑜 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 √17 𝑏𝑒𝑔𝑖𝑛𝑖𝑔 𝑓𝑟𝑜𝑚 √16

𝑠𝑜𝑙: 𝑒𝑥𝑎𝑐𝑡 √17 = 4.1231056


𝑇𝑎𝑦𝑙𝑜𝑟 𝑠𝑒𝑟𝑖𝑒𝑠
𝑓 ′ (𝑎) 𝑓 ′′ (𝑎) 2
𝑓 ′′′ (𝑎)
𝑓(𝑥 ) = 𝑓(𝑎) + (𝑥 − 𝑎) + (𝑥 − 𝑎) + (𝑥 − 𝑎)3 + ⋯
1! 2! 3!
𝑓(𝑥 ) = √𝑥 → 𝑓(0) = 0

𝑓(𝑎) = √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.

1. Newton’s Divided – Difference Interpolation

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 = 1 → 𝑙𝑛1 = 0
𝑥1 = 4 → 𝑙𝑛4 = 1.3863
𝑥2 = 6 → 𝑙𝑛6 = 1.7917
𝑠𝑜𝑙: 𝑏0 = 𝑓(𝑥0 ) = ln 1 = 0
𝑓(𝑥1 ) − 𝑓(𝑥0 ) 1.3863 − 0
𝑏1 = → 𝑏1 =
𝑥1 − 𝑥0 4−1
𝑏1 = 0.46209

𝑓 (𝑥2 ) − 𝑓(𝑥1 ) 𝑓(𝑥1 ) − 𝑓(𝑥0 )



𝑥2 − 𝑥1 𝑥1 − 𝑥0
𝑏2 =
𝑥2 − 𝑥0

1.7917 − 1.3863 1.3863 − 0


− 4−1
𝑏2 = 6 − 4
6−1

𝑏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:

Step by step method

Euler Method İmproved Euler method Runge-kutta method

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 ≌ 𝑦𝑛 + ℎ 𝑓(𝑥𝑛 , 𝑦𝑛 )

Ex: Apply Euler method to initial value problem


𝑦 ′ − 𝑥 − 𝑦 = 0, 𝑦(0) = 0
Choosing, h=0.2, and computing 𝑦1 → 𝑦5
Sol
𝑑𝑦
= 𝑥 + 𝑦 = 𝑓(𝑥, 𝑦)
𝑑𝑥
𝑥0 = 0, 𝑦0 =0
𝑦𝑛+1 ≌ 𝑦𝑛 + ℎ 𝑓(𝑥𝑛 , 𝑦𝑛 )
𝑦𝑛+1 = 𝑦𝑛 + ℎ (𝑥𝑛 + 𝑦𝑛 )
𝑦𝑛+1 = 𝑦𝑛 + 0.2 (𝑥𝑛 + 𝑦𝑛 )

n 𝑥𝑛 𝑦𝑛 0.2 (𝑥𝑛 + 𝑦𝑛 ) 𝑦𝑛+1


0 0 0 0 0
1 0.2 0 0.04 0.04
2 0.4 0.04 0.088 0.128
3 0.6 0.128 0.1456 0.274
4 0.8 0.274 0.215 0.489
5 1 0.489
Improved Euler method
𝑑𝑦
= 𝑓(𝑥, 𝑦)
𝑑𝑥

𝒉
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

y*n+1 = yn + h f(xn , yn)


yn+1 = yn + 𝒉𝟐 {f (xn , yn) + f(xn+1, y*n+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)}
𝟐

yn+1 = 1.22 yn + 0.12 xn + 0.1 xn+1

n xn yn 0.12 xn 0.1 xn+1 1.22 yn yn+1


0 0 0 0 0.02 0 0.02
1 0.2 0.02 0.024 0.04 0.0244 0.0884
2 0.4 0.0884 0.048 0.06 0.1078 0.2158
3 0.6 0.2158 0.072 0.08 0.2633 0.4153
4 0.8 0.4153 0.096 0.1 0.5067 0.7027
5 1 0.7027
Fourth order Runge-kutta Method:
𝟏
yn+1= yn + { (k1 + 2 k2 + 3 k3 + k4)} h
𝟔

where : k1= f (xn , yn)


𝟏 𝟏
k2= f (xn + h , yn + h k1)
𝟐 𝟐
𝟏 𝟏
k3= f (xn + h , yn + h k2)
𝟐 𝟐
k4= f (xn + h , yn + h k3)

Ex: Apply the Runge-kutta method to the initial value problem


𝒅𝒚
= 𝒙 + 𝒚, y(0)=0, choosing h= 0.2 and computing five step.
𝒅𝒙

Sol:
𝒅𝒚
= 𝒙 + 𝒚 = 𝒇(𝒙, 𝒚)
𝒅𝒙

k1= f (xn , yn)


k1= xn + yn
𝟏 𝟏
k2= f (xn + h , yn + h k1)
𝟐 𝟐
𝟎.𝟐 𝟎.𝟐
k2= xn + + yn + (xn + yn)
𝟐 𝟐

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

You might also like