EEE 315: Numerical Analysis: Runge Kutta 2 Order Method
EEE 315: Numerical Analysis: Runge Kutta 2 Order Method
where,
k1 = f (xi , yi )
k 2 = f ( xi + h, yi + k1h )
http://numericalmethods.eng.usf.edu
5/3/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
Find the temperature at t=480 seconds using Heuns method.
Assume a step size of h=240 seconds
d
= 2.2067 10 12 ( 4 81 108 )
dt
f (t , ) = 2.2067 10 12 4 81 10 8
1
2
1
2
i +1 = i + k1 + k 2 h
Prof. S. M. Lutful Kabir, BUET
Solution
Step 1:
i = 0, t0 = 0, 0 = (0) = 1200K
k 2 = f (t0 + h, 0 + k1h )
k1 = f (t0 , o )
= f (0 + 240,1200 + ( 4.5579)240)
= f (0,1200)
1
2
= f (240,106.09 )
1 = 0 + k1 + k 2 h
1
1
http://numericalmethods.eng.usf.edu
5/3/2014
Solution (contd.)
Step 2: i = 1, t1 = t 0 + h = 0 + 240 = 240,1 = 655.16K
k 2 = f (t1 + h, 1 + k1h )
k1 = f (t1 , 1 )
= f (240,655.16)
1
2
2 = 1 + k1 + k 2 h
1
1
= 655.16 + ( 0.29538)240
= 584.27 K
Prof. S. M. Lutful Kabir, BUET
Temperature, (K)
1200
h=120
Exact
800
h=240
400
h=480
0
0
100
200
300
400
500
-400
Time, t(sec)
http://numericalmethods.eng.usf.edu
5/3/2014
Step size, h
(480)
Et
|t|%
480
240
120
60
30
393.87
584.27
651.35
649.91
648.21
1041.4
63.304
3.7762
2.3406
0.63219
160.82
9.7756
0.58313
0.36145
0.097625
(480) = 647.57 K
(exact)
dy
= f ( x, y ), y (0) = y0
dx
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
k4 = f (xi + h, yi + k3h )
Prof. S. M. Lutful Kabir, BUET
http://numericalmethods.eng.usf.edu
5/3/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
Find the temperature at t=480 seconds using Runge-Kutta 4th order
method. Assume a step size of h=240 seconds
d
= 2.2067 10 12 4 81 10 8
dt
f (t , ) = 2.2067 10 12 4 81108
i +1 = i +
1
(k1 + 2k 2 + 2k 3 + k 4 )h
6
Solution
Step 1:
i = 0, t 0 = 0, 0 = ( 0) = 1200
1
1
1
1
1
1
1
1
k3 = f t 0 + h, 0 + k 2 h = f 0 + (240),1200 + ( 0.38347)240
2
2
2
2
http://numericalmethods.eng.usf.edu
5/3/2014
Solution (cont)
1
(k1 + 2k 2 + 2k3 + k 4 )h
6
1
= 1200 + ( 4.5579 + 2( 0.38347) + 2( 3.8954) + (0.069750))240
6
1
= 1200 + ( 2.1848)240
6
= 675.65K
1 = 0 +
t = t1 = t0 + h = 0 + 240 = 240
(240) 1 = 675.65K
Prof. S. M. Lutful Kabir, BUET
Temperature, (K)
1600
1200
h=120
800
Exact
h=240
400
h=480
0
0
200
400
600
-400
Time,t(sec)
http://numericalmethods.eng.usf.edu
5/3/2014
Step size, h
480
240
120
60
30
(480)
Et
|t|%
90.278
737.85
113.94
594.91
52.660
8.1319
646.16
1.4122
0.21807
0.0051926
647.54
0.033626
647.57 0.00086900 0.00013419
(480) = 647.57 K
(exact)
Thanks
http://numericalmethods.eng.usf.edu