Professional Documents
Culture Documents
Introduction
The solution of an ordinary differential equation (ODE) is a specific
relation between the dependent variable and independent variable which
satisfies the original differential equation.
The general solution of a ODE of nth order has ‘n’ arbitrary
constants. So, to find the particular solution of n th order equation, ‘n’
conditions are required.
These ‘n’ conditions will be provided by the values of the dependent
variable (or) its derivative for ‘n’ specific values of the independent
variable.
If all the ‘n’ conditions are specified only for the initial value of the
independent variable ‘x’ then the problem is called an initial value
problem.(IVP)
If all the ‘n’ conditions are specified for two or more values of the
independent variable ‘x’ then the problem is called a boundary value
problem.(BVP)
𝑑2 𝑦 𝑑𝑦
Example for IVP : = 𝑓 (𝑥, 𝑦, 𝑑𝑥 ) , 𝑠𝑢𝑏𝑗𝑒𝑐𝑡 𝑡𝑜 𝑦(𝑥0 ) = 𝑎 &𝑦 ′ (𝑥0 ) = 𝑏
𝑑𝑥 2
𝑑2 𝑦 𝑑𝑦
Example for BVP : = 𝑓 (𝑥, 𝑦, 𝑑𝑥 ) , 𝑠𝑢𝑏𝑗𝑒𝑐𝑡 𝑡𝑜 𝑦(𝑥0 ) = 𝑎 & 𝑦(𝑥𝑛 ) = 𝑏
𝑑𝑥 2
Formula :
(𝑥 − 𝑥0 ) ′ (𝑥 − 𝑥0 )2 ′′ (𝑥 − 𝑥0 )3 ′′′
𝑦(𝑥 ) = 𝑦(𝑥0 ) + 𝑦 (𝑥0 ) + 𝑦 (𝑥0 ) + 𝑦 (𝑥0 ) + −
1! 2! 3!
− −(3)
(or)
(𝑥 − 𝑥0 ) ′ (𝑥 − 𝑥0 )2 ′′ (𝑥 − 𝑥0 )3 ′′′
𝑦(𝑥 ) = 𝑦0 + 𝑦0 + 𝑦0 + 𝑦0 + − − − − −
1! 2! 3!
− −(3)
𝒉 𝒉𝟐 𝒉𝟑
i.e., 𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚𝟎 + 𝒚𝟎 ′ + 𝒚𝟎 ′′ + 𝒚𝟎 ′′′ + − − − − − − −(𝟒)
𝟏! 𝟐! 𝟑!
where 𝒉 = 𝒙 − 𝒙𝟎 and 𝒙𝟏 = 𝒙𝟎 + 𝒉
ℎ ′ ℎ2 ′′ ℎ3 ′′′
𝑦2 = 𝑦(𝑥2 ) = 𝑦1 + 𝑦1 + 𝑦1 + 𝑦1 + − − − − − − −(5)
1! 2! 3!
If ‘h’ is small and the term after ‘n’ terms are neglected, the error is
ℎ𝑛
𝑓 𝑛 (𝜃) 𝑤ℎ𝑒𝑟𝑒 𝑥0 < 𝜃 < 𝑥1 𝑖𝑓 𝑥1 − 𝑥0 = ℎ.
𝑛!
Problems:
𝑑𝑦
1) Solve = 𝑥 + 𝑦 given y(1)=0 and determine y(1.1) by Taylor’s series
𝑑𝑥
method.
Solution :
𝑦 ′ = 𝑥 + 𝑦⟹ 𝑦0 ′ = 𝑥0 + 𝑦0 = 1 + 0 = 1
𝑦 ′′ = 1 + 𝑦 ′ ⟹ 𝑦0 ′′ = 1 + 𝑦0 ′ = 1 + 1 = 2
𝑦 ′′′ = 𝑦 ′′ ⟹ 𝑦0 ′′′ = 𝑦0 ′′ = 2
***********************************************************
2) Using Taylor’s series method , find the value of y(0.1), given
𝑑𝑦
= 𝑥 2 + 𝑦 2 and y(0)=1. Correct to four decimal places.
𝑑𝑥
Solution :
𝑦 ′ = 𝑥 2 + 𝑦 2 --------------------⟹ 𝑦0 ′ = 𝑥0 2 + 𝑦0 2 = 0 + 1 = 1
𝑦 ′𝑣 = 2𝑦𝑦 ′′′ + 2𝑦 ′′ 𝑦 ′ + 4𝑦 ′ 𝑦 ′′
𝑦1 = 𝑦(0.1) = 1.1115
***********************************************************
Solution :
𝑦 ′′′ = −2(𝑥𝑦 ′′ + 𝑦 ′ + 𝑦 ′ )
𝑦1 = 𝑦(0.2) = 0.1948---------------------------(2)
Therefore
ℎ ′ ℎ2 ′′ ℎ3 ′′′
𝑦2 = 𝑦(0.4) = 𝑦1 + 𝑦 + 𝑦1 + 𝑦1 + − − − − − − −(3)
1! 1 2! 3!
𝑦 ′′′ = −2(𝑥𝑦 ′′ + 𝑦 ′ + 𝑦 ′ )
𝑦 ′𝑣 = −2(𝑥𝑦 ′′′ + 𝑦 ′′ + 2𝑦 ′′ )
𝑦2 = 𝑦(0.4) = 0.3599
***********************************************************
Practice problems
𝑦2
4) Solve 𝑦 ′ = 𝑥 + 10 , y(1.8)=0 for y(2).
Euler’s method
𝑑𝑦
Aim :To find the solution of = 𝑦 ′ = 𝑓(𝑥, 𝑦) − − − − − − − − − (1)
𝑑𝑥
Problems :
***********************************************************
2) Given 𝑦 ′ = 𝑥 + 𝑦 and y(0)=1. Determine the value of y at
***********************************************************
Improved Euler’s Method
Formula:
𝒉
𝒚𝒏+𝟏 = 𝒚𝒏 + [𝒇(𝒙𝒏 , 𝒚𝒏 ) + 𝒇(𝒙𝒏 + 𝒉, 𝒚𝒏 + 𝒉𝒇(𝒙𝒏 , 𝒚𝒏 ))] -----------(II)
𝟐
𝑓 (𝑥0 , 𝑦0 ) = 𝑥0 2 − 𝑦0 = 0 − 1 = −1 -----------------------------(i)
𝟎. 𝟏
𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚(𝟎. 𝟏) = 𝟏 + [−𝟏 − 𝟎. 𝟖𝟗] = 𝟎. 𝟗𝟎𝟓𝟓
𝟐
***********************************************************
𝑓 (𝑥0 , 𝑦0 ) = 𝑦0 + 𝑒 𝑥0 = 0 + 𝑒 0 = 1 -----------------------------(i)
𝟎. 𝟐
𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚(𝟎. 𝟐) = 𝟎 + [𝟏 + 𝟏. 𝟒𝟐𝟏𝟒] = 𝟎. 𝟐𝟒𝟐𝟏𝟒
𝟐
Practice Problems:
***********************************************************
Fourth order Runge-Kutta method
Algorithm:
𝑘1 = ℎ𝑓(𝑥, 𝑦)
ℎ 𝑘1
𝑘2 = ℎ𝑓 (𝑥 + , 𝑦 + )
2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥 + , 𝑦 + )
2 2
𝑘4 = ℎ𝑓(𝑥 + ℎ, 𝑦 + 𝑘3 )
1
𝛥𝑦 = (𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 )
6
𝑦𝑛+1 = 𝑦𝑛 + 𝛥𝑦
Answer:
𝑓 (𝑥, 𝑦) = 𝑥 + 𝑦, 𝑥0 = 0, 𝑦0 = 1, 𝑥1 = 0.1, 𝑥2 = 0.2
To find 𝒚(𝟎. 𝟏)
𝑘1 = ℎ𝑓(𝑥0 , 𝑦0 ) = 0.1(𝑥0 + 𝑦0 ) = 0.1(0 + 1) = 0.1
ℎ 𝑘1 0.1 0.1
𝑘2 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1𝑓 (0 + ,1 + ) = 0.1𝑓 (0.05,1.05)
2 2 2 2
= 0.1(0.05 + 1.05) = 0.11
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1𝑓(0.05,1.055) = 0.1(0.05 + 1.055) = 0.1105
2 2
𝑘4 = ℎ𝑓(𝑥0 + ℎ, 𝑦0 + 𝑘3 ) = 0.1𝑓(0.1,1.1105) = 0.1(0.1 + 1.1105) = 0.12105
1 1
𝛥𝑦 = (𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ) = (0.1 + 2(0.11) + 2(0.1105) + 0.12105) = 0.1103
6 6
∴ 𝑦(0.1) = 𝑦1 = 𝑦0 + 𝛥𝑦 = 1 + 0.1103 = 1.1103
To find 𝒚(𝟎. 𝟐)
𝑓(𝑥, 𝑦) = 𝑥 + 𝑦, 𝑥1 = 0.1, 𝑦1 = 1.1103, ℎ = 0.1
Answer:
𝑓 (𝑥, 𝑦) = 𝑦 − 𝑥 2 , 𝑥0 = 0.6, 𝑦0 = 1.7379, 𝑥1 = 0.7, 𝑥2 = 0.8, h = 0.1
To find 𝒚(𝟎. 𝟕)
𝑘1 = ℎ𝑓 (𝑥0 , 𝑦0 ) = 0.1𝑓(0.6, 1.7379) = (0.1)[1.7379 − (0.6)2 ] = 0.1378
ℎ 𝑘1
𝑘2 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1𝑓 (0.65, 1.8068) = 0.1[1.8068 − 0.652 ] = 0.1384
2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1𝑓 (0.65,1.8071) = 0.1(1.8071 − 0.652 ) = 0.1385
2 2
𝑘4 = ℎ𝑓(𝑥0 + ℎ, 𝑦0 + 𝑘3 ) = 0.1𝑓(0.7,1.8764) = 0.1(1.8764 − 0.72 ) = 0.1386
1
𝑦(0.7) = 𝑦1 = 1.7379 + (0.1378 + 2(0.1384) + 2(0.1385) + 0.1386) = 1.8763
6
To find 𝒚(𝟎. 𝟖)
𝑓(𝑥, 𝑦) = 𝑦 − 𝑥 2 , 𝑥1 = 0.7, 𝑦1 = 1.8763, ℎ = 0.1
𝑑𝑦 𝑦 2 −𝑥 2
3. Using Runge-Kutta method of fourth order, solve = 𝑦 2 +𝑥 2 , at 𝑥 =
𝑑𝑥
0.2, 0.4given 𝑦(0) = 1.
Answer:
𝑦2 − 𝑥2
𝑓(𝑥, 𝑦) = , 𝑥 = 0, 𝑦0 = 1, 𝑥1 = 0.2, 𝑥2 = 0.4, ℎ = 0.2
𝑦2 + 𝑥2 0
To find 𝒚(𝟎. 𝟐)
12 − 02
𝑘1 = ℎ𝑓(𝑥0 , 𝑦0 ) = 0.2 ( ) = 0.2 (1) = 0.2
12 + 02
ℎ 𝑘1 1. 12 − 0.12
𝑘2 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.2𝑓(0.1, 1.1) = 0.2 ( 2 ) = 0.1967
2 2 1.1 + 0.12
ℎ 𝑘2 1. 09832 − 0.12
𝑘3 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.2𝑓(0.1,1.0983) = 0.2 ( ) = 0.1967
2 2 1.09832 + 0.12
1.1967 2 − 0.22
( ) ( )
𝑘4 = ℎ𝑓 𝑥0 + ℎ, 𝑦0 + 𝑘3 = 0.2𝑓 0.2,1.967 = 0.2 ( ) = 0.1891
1.19672 + 0.22
1
∆𝑦 = (𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ) = 0.1959
6
𝑦(0.2) = 𝑦1 = 𝑦0 + 𝛥𝑦 = 1 + 0.1959 = 1.1959
To find 𝒚(𝟎. 𝟒)
𝑦2 − 𝑥2
𝑓 (𝑥, 𝑦) = , 𝑥 = 0.2, 𝑦1 = 1.1959 , ℎ = 0.2
𝑦2 + 𝑥2 1
1.19592 − 0.22
𝑘1 = ℎ𝑓(𝑥1 , 𝑦1 ) = 0.2 ( ) = 0.1891
1.19592 + 0.22
ℎ 𝑘1 1.1290552 − 0.32
𝑘2 = ℎ𝑓 (𝑥1 + , 𝑦1 + ) = 0.2𝑓(0.3,1.29055) = 0.2 ( ) = 0.17949
2 2 1.1290552 + 0.32
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥1 + , 𝑦1 + ) = 0.2𝑓(0.3,1.28572) = 0.1793
2 2
𝑘4 = ℎ𝑓 (𝑥1 + ℎ, 𝑦1 + 𝑘3 ) = 0.2𝑓(0.4, 1.37528) = 0.1687
∴ 𝑦(0.4) = 𝑦2 = 𝑦1 + 𝛥𝑦 = 1.1959 + 0.1792 = 1. 3751
Answer
𝑓 (𝑥, 𝑦) = −(𝑥𝑦 2 + 𝑦), 𝑥0 = 0, 𝑦0 = 1, 𝑥1 = 0.1, 𝑥2 = 0.2
To find 𝒚(𝟎. 𝟏)
𝑘1 = ℎ𝑓 (𝑥0 , 𝑦0 ) = 0.1(−(𝑥0 𝑦0 2 + 𝑦0 )) = −0.1
ℎ 𝑘1
𝑘2 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1𝑓 (0.05, 0.95) = −0.1((0.05)(0.95)2 + 0.95 ) = −0.0995
2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1𝑓 (0.05,0.9502) = −0.1((0.05)(0.9502)2 + 0.9502 )
2 2
= −0.0995
𝑘4 = ℎ𝑓(𝑥0 + ℎ, 𝑦0 + 𝑘3 ) = 0.1𝑓(0.1,0.9005) = −0.0982
1
𝑦1 = 𝑦0 + 𝛥𝑦 = 1 + (𝑘 + 2𝑘2 + 2𝑘3 + 𝑘4 )
6 1
1
= 1 + (−0.1 + 2(−0.0995) + 2(−0.0995) − 0.0982) = 0.9006
6
To find 𝒚(𝟎. 𝟐)
𝑓(𝑥, 𝑦) = −(𝑥𝑦 2 + 𝑦), 𝑥1 = 0.1, 𝑦1 = 0.9006, ℎ = 0.1
Answer
Put 𝑦 ′ = 𝑧 and 𝑦 ″ = 𝑧 ′ .
Then the given equation reduces to
𝑑𝑦 𝑑𝑧
= 𝑧, = 𝑥𝑧 2 − 𝑦 2
𝑑𝑥 𝑑𝑥
Given 𝑥0 = 0, 𝑦0 = 1, 𝑧0 = 𝑦0 ′ = 0, ℎ = 0.2
Let 𝑓1 (𝑥, 𝑦, 𝑧) = 𝑧
𝑓2 (𝑥, 𝑦, 𝑧) = 𝑥𝑧 2 − 𝑦 2
Using Runge-Kutta formula,
1 1
𝛥𝑦 = 6 (𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ) =6 (0 + 2(−0.02) + 2(−0.01998) − 0.03916) =
−0.01985
1 1
𝛥𝑧 = 6 (𝑙1 + 2𝑙2 + 2𝑙3 + 𝑙4 ) =6 (−0.2 + 2(−0.1998) + 2(−0.1958) − 0.1905) =
−0.1970
𝒚(𝟎. 𝟐) = 𝒚𝟏 = 𝒚𝟎 + 𝜟𝒚 = 𝟏 − 𝟎. 𝟎𝟏𝟗𝟖𝟓 = 𝟎. 𝟗𝟖𝟎𝟐
𝒛(𝟎. 𝟐) = 𝒛𝟏 = 𝒛𝟎 + 𝜟𝒛 = 𝟎 − 𝟎. 𝟏𝟗𝟕𝟎 = 𝟎. 𝟏𝟗𝟕𝟎
𝑑2 𝑦 𝑑𝑦 𝑑𝑦
2. Given + 𝑥 𝑑𝑥 + 𝑦 = 0, 𝑦(0) = 1, (𝑑𝑥 ) = 0, find the value of 𝑦 for 𝑥 =
𝑑𝑥 2 𝑥=0
0.1, applying
Runge-Kutta method.
Answer
Put 𝑦 ′ = 𝑧 and 𝑦 ″ = 𝑧 ′ .
Then the given equation reduces to
𝑑𝑦 𝑑𝑧
= 𝑧, = −𝑥𝑧 − 𝑦
𝑑𝑥 𝑑𝑥
Given 𝑥0 = 0, 𝑦0 = 1, 𝑧0 = 𝑦0 ′ = 0, ℎ = 0.1
Let 𝑓1 (𝑥, 𝑦, 𝑧) = 𝑧
𝑓2 (𝑥, 𝑦, 𝑧) = −𝑥𝑧 − 𝑦
1
𝒚(𝟎. 𝟏) = 𝒚𝟏 = 𝒚𝟎 + 𝜟𝒚 = 𝟏 + (𝑘 + 2𝑘2 + 2𝑘3 + 𝑘4 )
6 1
1
=𝟏 +(0 + 2(−0.005) + 2(−0.00499) − 0.00995)
6
= 0.9950
PRACTICE PROBLEMS
1. Apply Runge-Kutta method of order 4 to find an approximate value of
𝑑𝑦
𝑦 for 𝑥 = 0.2 in steps of 0.1, if = 𝑥 + 𝑦 2 , given that 𝑦 = 1when𝑥 = 0.
𝑑𝑥
2. Given 𝑦 ″ + 𝑥𝑦 ′ + 𝑦 = 0, 𝑦(0) = 1, 𝑦 ′ (0) = 0, find the value of 𝑦(0.1) by
Runge-Kutta method.