Professional Documents
Culture Documents
Mws Gen Ode TXT Runge4th
Mws Gen Ode TXT Runge4th
04
Runge-Kutta 4th Order Method for
Ordinary Differential Equations
So only first order ordinary differential equations can be solved by using the Runge-Kutta 4 th
order method. In other sections, we have discussed how Euler and Runge-Kutta methods are
used to solve higher order ordinary differential equations or coupled (simultaneous)
differential equations.
How does one write a first order differential equation in the above form?
Example 1
Rewrite
dy
2 y 1.3e x , y 0 5
dx
in
dy
f ( x, y ), y (0) y 0 form.
dx
Solution
dy
2 y 1.3e x , y 0 5
dx
08.04.1
08.04.2
Chapter 08.04
dy
1.3e x 2 y , y 0 5
dx
In this case
f x, y 1.3e x 2 y
Example 2
Rewrite
ey
dy
x 2 y 2 2 sin(3 x), y 0 5
dx
in
dy
f ( x, y ), y (0) y 0 form.
dx
Solution
ey
dy
x 2 y 2 2 sin(3 x), y 0 5
dx
dy 2 sin(3 x) x 2 y 2
, y 0 5
dx
ey
In this case
2 sin(3 x) x 2 y 2
f x, y
ey
The Runge-Kutta 4th order method is based on the following
yi 1 yi a1k1 a2 k 2 a3 k 3 a4 k 4 h
(1)
4 xi , yi
4! dx
(2)
dy
f x, y and xi 1 xi h
dx
1
1
y i f xi , y i h f ' xi , y i h 2 f
2!
3!
xi , yi
xi 1 xi
Knowing that
y i 1
''
xi , y i h 3 1
4!
'''
xi , y i h 4
(3)
Based on equating Equation (2) and Equation (3), one of the popular solutions used is
y i 1 y i
1
k1 2 k 2 2 k 3 k 4 h
6
k1 f x i , y i
1
1
k2 f xi h, yi k1h
2
2
(4)
(5a)
(5b)
08.04.3
1
1
k 3 f x i h, y i k 2 h
2
2
(5c)
k 4 f x i h, y i k 3 h
(5d)
Example 3
A ball at 1200 K is allowed to cool down in air at an ambient temperature of 300 K.
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 108 , 0 1200 K
dt
where is in K and t in seconds. Find the temperature at t 480 seconds using RungeKutta 4th order method. Assume a step size of h 240 seconds.
Solution
d
2.2067 10 12 4 81 10 8
dt
f t , 2.2067 10 12 4 81 10 8
1
i 1 i k1 2k 2 2k 3 k 4 h
6
For i 0 , t 0 0 , 0 1200K
k1 f t0 , 0
f 0,1200
2.2067 10 12 1200 4 81 10 8
4.5579
1
1
k 2 f t 0 h, 0 k1h
2
2
1
1
f 120,653.05
2.2067 10 12 653.05 4 81 10 8
0.38347
1
1
k 3 f t 0 h, 0 k 2 h
2
2
1
1
f 120,1154 .0
k 4 f t0 h, 0 k3h
08.04.4
Chapter 08.04
1
1 0 ( k1 2 k 2 2 k 3 k 4 ) h
6
1
1200 4.5579 2 0.38347 2 3.8954 0.069750 240
6
1200 2.1848 240
675.65 K
0 240
240
1 240
675.65 K
k1 f t1 , 1
f 240,675.65
2.2067 10 12 675.65 4 81 10 8
0.44199
1
1
k 2 f t1 h, 1 k1h
2
2
1
1
f 360,622.61
1
1
k3 f t1 h, 1 k 2 h
2
2
1
1
f 360,638.00
2.2067 10 12 638.00 4 81 10 8
0.34775
k 4 f t1 h,1 k3h
1
2 1 ( k1 2 k 2 2 k 3 k 4 ) h
6
08.04.5
1
0.44199 2 0.31372 2 0.34775 0.25351 240
6
1
675.65 2.0184 240
6
675.65
594.91 K
2 480
594.91 K
Figure 1 compares the exact solution with the numerical solution using the Runge-Kutta 4th
order method with different step sizes.
480
240
120
60
30
size, 480
-90.278
594.91
646.16
647.54
647.57
Et
| t | %
737.85
52.660
1.4122
0.033626
0.00086900
113.94
8.1319
0.21807
0.0051926
0.00013419
08.04.6
Chapter 08.04
where
1
k1 3k 2 3k 3 k 4 h
8
(6)
k1 f xi , y i
(7a)
1
1
k 2 f xi h, y i hk1
3
3
2
1
k 3 f xi h, yi hk1 hk 2
3
3
k 4 f xi h, yi hk1 hk 2 hk 3
This formula is the same as the Simpsons 3/8 rule, if f x, y is only a function of
(7b)
(7c)
x.
(7d)
08.04.7
Figure 3 Comparison of Runge-Kutta methods of 1st (Euler), 2nd, and 4th order.
ORDINARY DIFFERENTIAL EQUATIONS
Topic
Runge-Kutta 4th order method
Summary
Textbook notes on the Runge-Kutta 4th order method for
solving ordinary differential equations.
Major
General Engineering
Authors
Autar Kaw
Last Revised March 14, 2015
Web Site
http://numericalmethods.eng.usf.edu