Ordinary Differential Equations: Runge-Kutta 2 Order Method
Ordinary Differential Equations: Runge-Kutta 2 Order Method
12/8/201
4
where
k1 f xi , yi
k2 f xi p1h, yi q11k1h
Rokiah @ Rozita Ahmad, Assoc.. Prof. Dr
12/8/2014
Heuns Method
Heuns method
1
2
p1 1
a1
.
Slope f xi h, y i k1h
Slope f xi , yi
q11 1
resulting in
1
1
yi 1 yi k1 k 2 h
2
2
Average Slope
yi
1
f xi h, yi k1h f xi , yi
2
x
xi
where
Figure 1.
k1 f x i , y i
k 2 f x i h, y i k1 h
Rokiah @ Rozita Ahmad, Assoc.. Prof. Dr
yi+1, predicted
xi+1
Midpoint Method
Here a2 1 is chosen, giving
a1 0
1
p1
2
resulting in
1
q11
2
yi 1 yi k 2 h
where k f x , y
1
i i
1
1
k 2 f x i h , y i k1 h
2
2
12/8/2014
Ralstons Method
2
is chosen, giving
3
Here a 2
1
a1
3
3
p1
4
resulting in
y i 1
where
3
q11
4
1
2
y i ( k1 k 2 ) h
3
3
k1 f xi , yi
3
3
k 2 f x i h , y i k1 h
4
4
12/8/2014
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
h 240 seconds.
d
2.2067 10 12 4 81 10 8
dt
f t , 2.2067 10 12 4 81 10 8
1
1
i 1 i k1 k 2 h
2
2
Rokiah @ Rozita Ahmad, Dr
12/8/20
14
Solution
i 0, t0 0, 0 (0) 1200 K
Step 1:
k1 f t 0 , o f 0,1200
2.2067 10 12 1200 4 81 10 8
4.5579
2.2067 10 12 106.09 4 81 10 8
0.017595
1
1
1 0 k1 k 2 h
2
2
1
1
1200 2.2702240
655.16 K
12/8/20
14
Solution Cont
Step 2: i 1, t1 t 0 h 0 240 240,1 655.16 K
k1 f t1 ,1 f 240,655.16 2.2067 10 12 655.16 4 81 10 8 0.38869
k 2 f t1 h,1 k1 h f 240 240,655.16 0.38869 240 f 480,561.87
2.2067 10 12 561.87 4 81 10 8
0.20206
1
1
2 1 k1 k 2 h
2
2
1
1
655.16 0.29538240
584.27 K
Rokiah @ Rozita Ahmad, Dr
12/8/20
14
Solution Cont
0.92593 ln
300
1.8519 tan 1 0.0033333 0.22067 10 3 t 2.9282
300
(480) 647.57 K
12/8/20
14
10
Temperature, (K)
1200
h=120
Exact
800
h=240
400
h=480
0
0
100
200
300
400
500
-400
Time, t(sec)
12/8/20
14
11
480
-393.87
584.27
651.35
649.91
648.21
Et
1041.4
63.304
-3.7762
-2.3406
-0.63219
(480) 647.57 K
Rokiah @ Rozita Ahmad, Dr
|t | %
160.82
9.7756
0.58313
0.36145
0.097625
(exact)
12/8/20
14
12
Temperature, (480)
800
600
400
200
0
0
100
-200
200
300
Step size, h
400
500
-400
12/8/20
14
13
480
240
120
60
30
( 480 )
Euler
Heun
Midpoint
Ralston
-987.84
110.32
546.77
614.97
632.77
-393.87
584.27
651.35
649.91
648.21
1208.4
976.87
690.20
654.85
649.02
449.78
690.01
667.71
652.25
648.61
12/8/20
14
14
480
240
120
60
30
Rokiah @ Rozita Ahmad, Dr
t %
Euler
Heun
Midpoint Ralston
252.54
82.964
15.566
5.0352
2.2864
160.82
9.7756
0.58313
0.36145
0.097625
86.612
50.851
6.5823
1.1239
0.22353
30.544
6.5537
3.1092
0.72299
0.15940
12/8/20
14
15
1200
Temperature, (K)
1100
Midpoint
1000
900
Ralston
800
Heun
700
Analytical
600
Euler
500
0
100
200
300
400
500
600
Time, t (sec)
Figure 4. Comparison of Euler and Runge Kutta 2nd order methods with
12/8/20
exact
results.
Rokiah @ Rozita Ahmad, Dr
14