Transcript Runge-Kutta 4th Order Method for Solving Ordinary
Runge 4
th
Order Method
4/27/2020 Major: All Engineering Majors Authors: Autar Kaw, Charlie Barker http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM Undergraduates http://numericalmethods.eng.usf.edu
1
Runge-Kutta 4
th
Order Method
http://numericalmethods.eng.usf.edu
3
Runge-Kutta 4
th
Order Method
For
dy
f dx
Runge Kutta 4 th (
x
,
y
),
y
( 0 )
y
0 order method is given by
y i
1
y i
where
k
1
f
x i
6 1 ,
k
1
y i
2
k
2 2
k
3
k
4
h k
2
f x i
1 2
h
,
y i
1 2
k
1
h k
3
f k
4
x i
1 2
h
,
y i
1 2
k
2
h f
x i
h
,
y i
k
3
h
http://numericalmethods.eng.usf.edu
4
How to write Ordinary Differential Equation
How does one write a first order differential equation in the form of
dy dx
f
Example
dy dx
2
y
1 .
3
e
x
,
y
is rewritten as
dy dx
1 .
3
e
x
2
y
,
y
In this case 5 5
f
1 .
3
e
x
2
y
http://numericalmethods.eng.usf.edu
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 , 1200
K dt
5 Find the temperature at Assume a step size of
t
480 seconds using Runge-Kutta 4 th order method.
h
240 seconds.
f d
2 .
2067 10 12 4 81 10 8
dt
2 .
2067 10 12 4 81 10 8
i
1
i
1 6
k
1 2
k
2 2
k
3
k
4
h
http://numericalmethods.eng.usf.edu
6
Solution
Step 1:
i
0 ,
t
0 0 , 0 ( 0 ) 1200
k
1
f
t
0 ,
o
f
0 , 1200 2 .
2067 10 12 1200 4 81 10 8 4 .
5579
k
2
f f t
0 1
h
, 0 2 120 , 653 .
05 1 2
k
1
h
2 .
2067
f
0 10 1 12 2 653 .
05 , 1200 4 81 1 2 10 8 4 .
5579 240 0 .
38347
k
3
k
4
f f t
0 1 2
h
, 0 120 , 1154 .
0 1 2
k
2
h
2 .
2067
f
10 0 12 1 2 1154 .
0 4 , 1200 1 2 81 10 8 0 .
38347 3 .
8954 240
f f
t
0
h
, 0 240 , 265 .
10
k
3
h
f
0 2 .
2067 10 12 , 1200 265 .
10 4 3 .
984 81 240 10 8 0 .
0069750 http://numericalmethods.eng.usf.edu
7
Solution Cont
1 0 1 6
k
1 2
k
2 2
k
3
k
4
h
1200 1 6 4 .
5579 2 0 .
38347 1200 1 6 675 .
65
K
2 .
1848 240 3 .
8954 0 .
069750 240 1 is the approximate temperature at
t
t
1
t
0
h
0 240 240 1 675 .
65
K
http://numericalmethods.eng.usf.edu
8
Solution Cont
Step 2:
k
1
f
t
1 , 1
i
1 ,
t
1 240 , 1 675 .
65
K
240 , 675 .
65 2 .
2067 10 12 675 .
65 4 81 10 8 0 .
44199
k
2
f f t
1 1
h
, 1 2 360 , 622 .
61 1 2
k
1
h
2 .
2067
f
240 10 12 1 , 2 622 .
61 4 675 .
65 81 10 8 1 2 0 .
44199 0 .
31372 240
k
3
k
4
f f t
1 360 , 1
h
, 1 2 638 .
00 1 2
k
2
h
2 .
2067
f
240 10 12 1 2 638 .
00 4 , 675 .
65 81 10 8 2 1 0 .
31372 240 0 .
34775
f f
t
1
h
, 1 480 , 592 .
19
k
3
h
f
240 2 .
2067 10 12 , 675 .
65 592 .
19 4 81 0 .
34775 240 10 8 0 .
25351 http://numericalmethods.eng.usf.edu
9
Solution Cont
2 1 1 6
k
1 2
k
2 2
k
3
k
4
h
675 .
65 1 6 0 .
44199 2 0 .
31372 675 .
65 1 6 594 .
91
K
2 .
0184 240 2 is the approximate temperature at
t
2
t
1
h
240 240 480 2 594 .
91
K
0 .
34775 0 .
25351 240 http://numericalmethods.eng.usf.edu
10
Solution Cont
The exact solution of the ordinary differential equation is given by the solution of a non-linear equation as 0 .
92593 ln 300 300 1 .
8519 tan 1 0 .
00333 0 .
22067 10 3
t
2 .
9282 The solution to this nonlinear equation at t=480 seconds is ( 480 ) 647 .
57
K
http://numericalmethods.eng.usf.edu
Comparison with exact results
1600 1200 h=120 800 Exact h=240 400 h=480 0 0 -400 200 400 600
Time,t(sec)
11 Figure 1. Comparison of Runge-Kutta 4th order method with exact solution http://numericalmethods.eng.usf.edu
12
Effect of step size
Table 1. Temperature at 480 seconds as a function of step size, h
Step size, h 480 240 120 60 30 (480) E t |є t |% −90.278
594.91
646.16
647.54
647.57
737.85
52.660
1.4122
0.033626
0.00086900
( 480 ) 647 .
57
K
(exact) 113.94
8.1319
0.21807
0.0051926
0.00013419
http://numericalmethods.eng.usf.edu
Effects of step size on Runge Kutta 4
th
Order Method
13 800 600 400 200 0 -200 0 100 200 300 400 500
Step size, h
Figure 2. Effect of step size in Runge-Kutta 4th order method http://numericalmethods.eng.usf.edu
Comparison of Euler and Runge Kutta Methods
1400 1200 1000 800 600 400 200 0 0 4th order Heun Euler Exact 100 200 300
Time, t(sec)
400 500 14 Figure 3. Comparison of Runge-Kutta methods of 1st, 2nd, and 4th order. http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/runge_kutt a_4th_method.html
THE END
http://numericalmethods.eng.usf.edu