Professional Documents
Culture Documents
Numerical Solution of ODE
Numerical Solution of ODE
Numerical Solution of ODE
⎛ yn′ + yn′ +1 ⎞
yn +1 = yn + Δh ⎜ ⎟ + O ( )
Δh 2
⎝ 2 ⎠
⎝ 2 ⎠
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 7
Runge-Kutta Methods
Runge-Kutta methods are very popular because of their
good efficiency; and are used in most computer
programs for differential equations. They are single-
step methods, as the Euler methods.
yn +1 = yn + ak1 + bk 2
k1 = Δhf ( xn , yn )
k 2 = Δhf (xn + αΔh, yn + βk1 )
yn +1 = yn + Δhf + Δh ⎢ ( f x + f y f )⎥
⎡1 2⎤
⎣2 ⎦
1 1
Use the coefficients a = b = , α = β =1
2 2
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 15
Runge-Kutta Method
(2nd Order) Example
The values are
k1 = Δhf (xi , yi )
k 2 = Δhf ( xi + Δh, yi + k1 )
yi +1 = yi + [k1 + k 2 ]
1
2
k1 = Δhf ( xi , yi )
k 2 = Δhf ( xi + αΔh, yi + βk1 )
yi +1 = yi + ak1 + bk 2
Euler Δy = k1
(Error of the order Δh2)
k1 = Δh[ f ( x, y )]
Modified Euler
(Error of the order Δh3) Δy =
1
[k1 + k 2 ]
2
k1 = Δh[ f ( x, y )]
k 2 = Δh[ f (x + Δh, y + k1 )]
Heun
Δy = [k1 + 3k 3 ]
1
(Error of the order Δh4)
4
k1 = Δh[ f (x, y )]
Runge-Kutta ⎡ ⎛ 1 1 ⎞⎤
k 2 = Δh ⎢ f ⎜ x + Δh, y + k1 ⎟ ⎥
Methods ⎣ ⎝
⎡ ⎛
3
2
3 ⎠⎦
2 ⎞⎤
k 3 = Δh ⎢ f ⎜ x + Δh, y + k 2 ⎟ ⎥
⎣ ⎝ 3 3 ⎠⎦
4th order Runge Kutta
(Error of the order Δh5) Δy =
1
[k1 + 2k 2 + 2k 3 + k 4 ]
6
k1 = Δh[ f ( x, y )]
⎡ ⎛ 1 1 ⎞⎤
k 2 = Δh ⎢ f ⎜ x + Δh , y + k 1 ⎟ ⎥
⎣ ⎝ 2 2 ⎠⎦
⎡ ⎛ 1 1 ⎞⎤
k 3 = Δh ⎢ f ⎜ x + Δ h , y + k 2 ⎟ ⎥
⎣ ⎝ 2 2 ⎠⎦
k 4 = Δh[ f ( x + Δh, y + k 3 )]
f3
f1 f
f = ( f1 + 2 f 2 + 2 f 3 + f 4 )
1
6
xi xi + h/2 xi + h
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 24
Runge-Kutta Method
(4th Order) Example
dx
The initial condition is: y (0 ) = 1
The step size is:
Δh = 0.1
(
k1 = Δh[ f ( x, y )] = 0.1 f (0,1) = 0.1 1 − 0 2 = 0.1 )
⎡ ⎛ 1 ⎞⎤
k 2 = Δh ⎢ f ⎜ x + Δh, y + k1 ⎟⎥ = 0.1 f (0.05,1.05) = 0.10475
1
⎣ ⎝ 2 2 ⎠⎦
⎡ ⎛ 1 ⎞⎤
k3 = Δh ⎢ f ⎜ x + Δh, y + k 2 ⎟⎥ = 0.1 f (0.05,1. + k 2 / 2 ) = 0.104988
1
⎣ ⎝ 2 2 ⎠⎦
k 4 = Δh[ f ( x + Δh, y + k3 )] = 0.1 f (0.1,1.104988) = 0.109499
solution. If we were to 0
0 1 2 3 4
go out to x=5. -2
Y Value
-4
y(5) = -111.4129 (-111.4132)
-6 Exact
4 10.00
Absolute |Error|
0
0 1 2 3 4 6.00
Y Value
-2
-4 4.00
-6 Exact 2.00
2nd order
-8 0.00
4th order
-10 0 1 2 3 4 5
X Value X Value
Δy = [k1 + k 2 + k3 ]
1
3
Δy′ =
1
[k1 + 2k2 + 2k3 + k4 ]
3Δh
The next step would be:
y ( x + Δh ) = y (x ) + Δh y′( x ) + Δy
y′( x + Δh ) = y′( x ) + Δy′
xi+1
= f (x )
dy
dx ⇒ yi +1 = yi + ∫ f (x )dx
dy = f ( x )dx xi
xi+1
∫ dy =y i +1 − yi = ∫ f (x )dx
xi
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 36
Multi-Step Methods
The integral can be represented.
xi+1
Δh
∫ f ( x )dx = [3 f i − f i−1 ] Two Point
xi 2
Three Point Adam Bashforth
Δh
= [23 f i − 16 f i−1 + 5 f i−2 ]
12
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 37
Multi-Step Methods
The integral can be represented.
xi+1
∫ f ( x )dx
Four Point Adam Bashforth
xi
Δh
= [55 f i − 59 f i−1 + 37 f i−2 − 9 f i−3 ]
24
dx
The initial condition is: y (0 ) = 1
The step size is:
Δh = 0.1
Δy =
0.1
[55 f 0.3 − 59 f 0.2 + 37 f 0.1 − 9 f 0 ]
24
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 41
4 Point Adam Bashforth
The results are:
Y Value
go through large number -4
Adam Bashforth
-6
of calculations. -8
4th order Runge-Kutta
Exact
-10
X Value
Δh
Δy = [5 f i+1 + 8 f i − f i−1 ]
12
Four Point Adam-Moulton Method
Δh
Δy = [9 f i+1 + 19 f i − 5 f i−1 + f i−2 ]
24
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 46
Implicit Multi-Step Methods
The method uses what is known as a Predictor-Corrector
technique. It uses the explicit scheme to estimate the
initial guess and uses the value to guess the future y* and
dy/dx= f*(x,y*) values. Using these results, the Adam
Moulton method can be applied.
dx
The initial condition is: y (0 ) = 1
The step size is:
Δh = 0.1
f (0,1) = 1.0000
f (0.1,1.104829 ) = 1.094829
f (0.2,1.218597 ) = 1.178597
Δy =
0.1
[23 f 0.2 − 16 f 0.1 + 5 f 0.0 ]
12
KSU, CE 745, Related to Set 7, (Dr. Asad Esmaeily) 50
3 Point Adam Moulton
Predictor-Corrector Method
The results of explicit scheme is:
Δy =
0.1
[23(1.178597 ) − 16(1.094829) + 5(1)]
12
= 0.121587
The functional values are:
y * (0.3) = 1.218597 + 0.121587 = 1.340184
f * (0.3,1.340184 ) = 1.250184
2
solution gives good 0
Y Value
more than a three points. -4
4th order Runge-Kutta
Exact
-6
Adam Moulton
-8 Adam Bashforth
-10
X Value