M.
RABEEL IMRAN CE-II 2021-ME-72
Numerical Methods for Solving ODEs
1. Euler's Method
A simple, first-order method that approximates the solution of ODEs by taking small steps
forward in time. It has limited accuracy but is easy to implement.
Formula
y n= y n−1+ hf ( x o + n−1 h , y n−1)
Example
Using Euler’s method, find an approximate value of y corresponding to x 1, given that dy/dx
x y and y 1 when x 0.
Solution
We take n 10 and h 0.1 which is sufficiently small. The various calculations are arranged as
follows:
X Y X+y = dy/dx Old y +0.1(dy/dx)=new
y
0.0 1.00 1.00 1.00 + 0.1 (1.00) = 1.10
0.1 1.10 1.20 1.10 + 0.1 (1.20) = 1.22
0.2 1.22 1.42 1.22 + 0.1 (1.42) = 1.36
0.3 1.36 1.66 1.36 + 0.1 (1.66) = 1.53
0.4 1.53 1.93 1.53 + 0.1 (1.93) = 1.72
0.5 1.72 2.22 1.72 + 0.1 (2.22) = 1.94
0.6 1.94 2.54 1.94 + 0.1 (2.54) = 2.19
0.7 2.19 2.89 2.19 + 0.1 (2.89) = 2.48
0.8 2.48 3.29 2.48 + 0.1 (3.29) = 2.81
0.9 2.81 3.71 2.81 + 0.1 (3.71) = 3.18
1.0 3.18
1
M.RABEEL IMRAN CE-II 2021-ME-72
2. Improved Euler Method (Heun's Method)
A second-order method that improves the accuracy of Euler's method by using a predictor-
corrector approach.
Formula
h
y 2= y 1 +
2
[ f ( x o +h , y 1 ) +f ( x o +2 h , y 2 ) ]
Example
Using modified Euler’s method, find an approximate value of y when x 0.3, given that dy/dx
x y and y 1 when x 0.
Solution:
The various calculations are arranged as follows taking h 0.1:
x X+y = y’ Mean slope Old y + 0.1 (mean slope) =
new y
0.0 0+1 — 1.00 + 0.1 (1.00) = 1.10
0.1 0.1 + 1.1 1/ 2 ( 1+1.2) 1.00 + 0.1 (1.1) = 1.11
0.1 0.1 + 1.11 1/ 2 ( 1+1.21) 1.00 0.1 (1.105) 1.1105
0.1 0.1 + 1.1105 1/ 2 ( 1+1.2105) 1.00 0.1 (1.1052)
1.1105
0.1 1.2105 ____ 1.1105 0.1 (1.2105)
1.2316
0.2 0.2 1.2316 1/ 2 (1.2105 1.4316) 1.1105 0.1 (1.3211)
1.2426
0.2 0.2 1.2426 1/ 2 (1.2105 1.4426) 1.1105 0.1 (1.3266)
1.2432
0.2 0.2 1.2432 1/ 2 (1.2105 1.4432) 1.1105 0.1 (1.3268)
1.2432
0.2 1.4432 _____ 1.2432 0.1 (1.4432)
1.3875
0.3 0.3 1.3875 1/ 2 (1.4432 1.6875) 1.2432 0.1 (1.5654)
1.3997
0.3 0.3 1.3997 1/ 2 (1.4432 1.6997) 1.2432 0.1 (1.5715)
1.4003
0.3 0.3 1.4003 1/ 2 (1.4432 1.7003) 1.2432 0.1 (1.5718)
1.4004
0.3 0.3 1.4004 1/ 2 (1.4432 1.7004) 1.2432 0.1 (1.5718)
1.4004
2
M.RABEEL IMRAN CE-II 2021-ME-72
Hence y (0.3) = 1.4004 approximately.
3. Runge-Kutta Methods
A family of iterative methods that includes different orders of accuracy:
RK3 (Third-order Runge-Kutta)
Formula
1
y 1= y o+ (k 1+ 4 k 2+ k 3 )
6
Where k 1=hf (x o , y o)
1 1
k 2=hf (x o + h , y o + k 1 )
2 2
k 3=hf (x o +h , y o + k ')
'
k =hf (x o +h , y o +k 1)
Example
Apply Runge’s method to find an approximate value of y when x 0.2, given that dy/dx x
y and y 1 when x 0.
Solution
Here we have x0 0, y0 1, h 0.2, f(x0 , y0 ) 1
k 1=hf ( x o , y o ) =0.2 ( 1 )=0.200
( 1
2
1
)
k 2=hf x o + h , y o + k 1 =0.2 f ( 0.1 , 1.1 )=0.240
2
'
k =hf ( x o+ h , y o+ k 1 )=0.2 f ( 0.2, 1.2 )=0.280
k 3=hf ( x o +h , y o +k ' ) =0.2 f ( 0.1 , 1.28 )=0.296
1
k = (k 1 +4 k 2 +k 3 ) = 1/6(0.2+0.96+0.296) = 0.2426
6
Hence the required approximate value of y is 1.2426.
3
M.RABEEL IMRAN CE-II 2021-ME-72
RK4 (Fourth-order Runge-Kutta) is the most widely used method due to its balance between
accuracy and computational effort.
Formula
y 1= y o+ k
1
Where k = (k +2 k 2 +2 k 3 +k 4 )
6 1
Where k 1=hf (x o , y o)
1 1
k 2=hf (x o + h , y o + k 1 )
2 2
1 1
k 3=hf (x o + h , y o + k 2)
2 2
k 4=hf (x o +h , y o +k 3)
Example
Apply the Runge-Kutta fourth order method to find an approximate value of y when x 0.2
given that dy/dx x y and y 1 when x 0.
Solution
x0 0, y0 1, h 0.2, f(x0 , y0 ) 1
k 1=hf (x o , y o) = 0.2* 1= 0.2000
( 1
2
1
)
k 2=hf x o + h , y o + k 1 =¿ 0.2 f ( 0.1 , 1.1 )=0.240 0
2
( 1
2
1
)
k 3=hf x o + h , y o + k 2 =¿ 0.2 f ( 0.1 , 1.12 )=0.2440
2
k 4=hf ( x o+ h , y o+ k 3 )=0.2 f ( 0.2 ,1.244 )=0.2888
1
k= ( k + 2 k 2+ 2 k 3 +k 4 )=0.2428
6 1
Hence the required approximate value of y is 1.2428
4
M.RABEEL IMRAN CE-II 2021-ME-72
4. Predictor-Corrector Methods
These methods use multiple previous steps to calculate the solution at the next point and are
designed for higher accuracy. They first predict a solution with an explicit method and then
correct it with an implicit method.
Example
Using Milne’s method find y(4.5) given 5xy y2 2 0 given y(4) 1, y(4.1) 1.0049,
y(4.2) 1.0097, y(4.3) 1.0143; y(4.4) 1.0187
Solution
2
' 2− y
y=
5x
x 1=4.1 , y 1=1.0049 , f 1=0.0485
x 2=4.2 , y 2=1.0097 , f 2=0.0467
x 3=4.3 , y 3=1.0143 , f 3=0.0452
x 4 =4.4 , y 4 =1.0187 , f 4=0.0437
x o=0 , y o =1 , f o=0.05
(p ) h '
y 5 = y 1 +4 (2 f 2−f 3+2 f 4 )
3
(p )
y 5 =1.023
2
2− y 5
f 5=
5 x5
f 5=0.0424
5
M.RABEEL IMRAN CE-II 2021-ME-72
(c) h '
y 5 = y 3 + ( f 3−4 f 4 +2 f 5)
3
(c)
y 5 =1.023
Y(4.5) = 1.023