Professional Documents
Culture Documents
by
Dr. Md. Rajibul Islam
CSE, UAP
10/11/22 1
Runge-Kutta 4th Order Method
For dy
f ( x, y ), y (0) y0
dx
1 1 1
yi 1 yi f ( xi , yi )xi 1 xi f ' ( xi , yi )xi 1 xi f ' ' ( xi , yi )xi 1 xi f ' ' ' ( xi , yi )xi 1 xi ...
2 3 4
2! 3! 4!
Runge-Kutta took this particular expression and equated it to the second-order . . .
the first five terms of the Taylor series expansion for y
Runge Kutta 4th order method is given by
1
yi 1 yi k1 2k2 2k3 k 4 h
6
where
k1 f xi , yi
1 1
k 2 f xi h, yi k1h
2 2
1 1
k3 f xi h, yi k2 h
2 2
k 4 f xi h, yi k3h
2
How to write Ordinary Differential
Equation
How does one write a first order differential equation in the form of
dy
f x , y
dx
Example
dy
2 y 1.3e x , y 0 5
dx
is rewritten as
dy
1.3e x 2 y, y 0 5
dx
In this case
f x, y 1.3e x 2 y
3
Example
A ball at 1200K is allowed to cool down in air at an ambient temperature
of 300K. Assuming heat is lost only due to radiation, the differential
equation for the temperature of the ball is given by
d
2.2067 10 12 4 81 10 8 , 0 1200 K
dt
Find the temperature at t 480 seconds using Runge-Kutta 4th order method.
k1 f t0 , o f 0,1200 2.2067 1012 12004 81108 4.5579
1 1 1 1
k 2 f t0 h, 0 k1h f 0 240,1200 4.5579240
2 2 2 2
f 120,653.05 2.2067 10 12 653.054 81108 0.38347
1 1 1 1
k3 f t0 h, 0 k 2 h f 0 240,1200 0.38347240
2 2 2 2
f 120,1154.0 2.2067 1012 1154.0 4 81 108 3.8954
5
Solution Cont
1
1 0 k1 2k2 2k3 k4 h
6
1
1200 4.5579 2 0.38347 2 3.8954 0.069750240
6
1
1200 2.1848240
6
675.65K
t t1 t0 h 0 240 240
240 1 675.65K
6
Solution Cont
Step 2: i 1, t1 240,1 675.65 K
k1 f t1 ,1 f 240,675.65 2.2067 1012 675.654 81108 0.44199
1 1 1 1
k 2 f t1 h, 1 k1h f 240 240, 675.65 0.44199240
2 2 2 2
f 360,622.61 2.2067 1012 622.614 81108 0.31372
1 1 1 1
k3 f t1 h,1 k 2 h f 240 240,675.65 0.31372240
2 2 2 2
f 360, 638.00 2.2067 1012 638.004 81108 0.34775
7
Solution Cont
1
2 1 k1 2k 2 2k3 k 4 h
6
1
675.65 0.44199 2 0.31372 2 0.34775 0.25351240
6
1
675.65 2.0184 240
6
594.91K
is the approximate temperature at
480 2 594.91K
8
Solution Cont
(480) 647.57 K
9
Test 1
K1=1
K2=-0.8829
K3=-0.3180
K4=-1.140
10
Test 1
K1=-1.076
K2=-1.107
K3=-1.098
K4=-0.9379
y2=2.759
x2=X1+h=1.5+1.5=3.0
y2=y(x2)
=y(3)~=2.759
11
Comparison with exact results
1600
θ(K )
1200
Tem perature,
h=120
800 Exact
h=240
400
h=480
0
0 200 400 600
-400
Time,t(sec)
600
400
200
0
0 100 200 300 400 500
-200
Step size, h
14
Comparison of Euler and Runge-
Kutta Methods
1400
Temperature, θ(K)
1200
4th order
1000
800
Exact
600
Heun
400
200 Euler
0
0 100 200 300 400 500
Time, t(sec)