Вы находитесь на странице: 1из 16

5/2/2014 http://numericalmethods.eng.usf.

edu 1
Runge 4
th
Order Method

Major: All Engineering Majors

Authors: Autar Kaw, Charlie Barker

http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates

Runge-Kutta 4
th
Order Method



http://numericalmethods.eng.usf.edu



http://numericalmethods.eng.usf.edu 3
Runge-Kutta 4
th
Order Method
where
( )h k k k k y y
i i 4 3 2 1 1
2 2
6
1
+ + + + =
+
( )
i i
y x f k ,
1
=
|
.
|

\
|
+ + = h k y h x f k
i i 1 2
2
1
,
2
1
|
.
|

\
|
+ + = h k y h x f k
i i 2 3
2
1
,
2
1
( ) h k y h x f k
i i 3 4
, + + =
For
0
) 0 ( ), , ( y y y x f
dx
dy
= =
Runge Kutta 4
th
order method is given by

http://numericalmethods.eng.usf.edu 4
How to write Ordinary Differential
Equation
Example

( ) 5 0 , 3 . 1 2 = = +

y e y
dx
dy
x
is rewritten as

( ) 5 0 , 2 3 . 1 = =

y y e
dx
dy
x
In this case

( ) y e y x f
x
2 3 . 1 , =

How does one write a first order differential equation in the form of
( ) y x f
dx
dy
, =

http://numericalmethods.eng.usf.edu 5
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

( ) ( ) K
dt
d
1200 0 , 10 81 10 2067 . 2
8 4 12
= u u =
u


Find the temperature at 480 = t
seconds using Runge-Kutta 4
th
order method.
240 = h
seconds.
( )
8 4 12
10 81 10 2067 . 2 u =
u

dt
d
( ) ( )
8 4 12
10 81 10 2067 . 2 , u = u

t f
Assume a step size of
( )h k k k k
i i 4 3 2 1 1
2 2
6
1
+ + + + =
+
u u

http://numericalmethods.eng.usf.edu 6
Solution
Step 1:
1200 ) 0 ( , 0 , 0
0 0
= = = = u u t i
( ) ( ) ( ) 5579 . 4 10 81 1200 10 2067 . 2 1200 , 0 ,
8 4 12
0 1
= = = =

f t f k
o
u
( ) ( )
( ) ( ) 38347 . 0 10 81 05 . 653 10 2067 . 2 05 . 653 , 120
240 5579 . 4
2
1
1200 , 240
2
1
0
2
1
,
2
1
8 4 12
1 0 0 2
= = =
|
.
|

\
|
+ + =
|
.
|

\
|
+ + =

f
f h k h t f k u
( ) ( )
( ) ( ) 8954 . 3 10 81 0 . 1154 10 2067 . 2 0 . 1154 , 120
240 38347 . 0
2
1
1200 , 240
2
1
0
2
1
,
2
1
8 4 12
2 0 0 3
= = =
|
.
|

\
|
+ + =
|
.
|

\
|
+ + =

f
f h k h t f k u
( ) ( ) ( ) ( )
( ) ( ) 0069750 . 0 10 81 10 . 265 10 2067 . 2 10 . 265 , 240
240 984 . 3 1200 , 240 0 ,
8 4 12
3 0 0 4
= = =
+ + = + + =

f
f h k h t f k u

http://numericalmethods.eng.usf.edu 7
Solution Cont
1
u is the approximate temperature at
240 240 0
0 1
= + = + = = h t t t
( ) K 65 . 675 240
1
= ~u u
( )
( ) ( ) ( ) ( )
( )
K
h k k k k
65 . 675
240 1848 . 2
6
1
1200
240 069750 . 0 8954 . 3 2 38347 . 0 2 5579 . 4
6
1
1200
2 2
6
1
4 3 2 1 0 1
=
+ =
+ + + + =
+ + + + =u u

http://numericalmethods.eng.usf.edu 8
Solution Cont
Step 2:
K t i 65 . 675 , 240 , 1
1 1
= = = u
( ) ( ) ( ) 44199 . 0 10 81 65 . 675 10 2067 . 2 65 . 675 , 240 ,
8 4 12
1 1 1
= = = =

f t f k u
( ) ( )
( ) ( ) 31372 . 0 10 81 61 . 622 10 2067 . 2 61 . 622 , 360
240 44199 . 0
2
1
65 . 675 , 240
2
1
240
2
1
,
2
1
8 4 12
1 1 1 2
= = =
|
.
|

\
|
+ + =
|
.
|

\
|
+ + =

f
f h k h t f k u
( ) ( )
( ) ( ) 34775 . 0 10 81 00 . 638 10 2067 . 2 00 . 638 , 360
240 31372 . 0
2
1
65 . 675 , 240
2
1
240
2
1
,
2
1
8 4 12
2 1 1 3
= = =
|
.
|

\
|
+ + =
|
.
|

\
|
+ + =

f
f h k h t f k u
( ) ( ) ( ) ( )
( ) ( ) 25351 . 0 10 81 19 . 592 10 2067 . 2 19 . 592 , 480
240 34775 . 0 65 . 675 , 240 240 ,
8 4 12
3 1 1 4
= = =
+ + = + + =

f
f h k h t f k u

http://numericalmethods.eng.usf.edu 9
Solution Cont
u
2
is the approximate temperature at
480 240 240
1 2
= + = + = h t t
( ) K 91 . 594 480
2
= ~u u
( )
( ) ( ) ( ) ( )
( )
K
h k k k k
91 . 594
240 0184 . 2
6
1
65 . 675
240 25351 . 0 34775 . 0 2 31372 . 0 2 44199 . 0
6
1
65 . 675
2 2
6
1
4 3 2 1 1 2
=
+ =
+ + + + =
+ + + + =u u

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
( ) 9282 . 2 10 22067 . 0 00333 . 0 tan 8519 . 1
300
300
ln 92593 . 0
3 1
= u
+ u
u

t
The solution to this nonlinear equation at t=480 seconds is
K 57 . 647 ) 480 ( = u

http://numericalmethods.eng.usf.edu 11
Comparison with exact results
Figure 1. Comparison of Runge-Kutta 4th order method with exact solution
-400
0
400
800
1200
1600
0 200 400 600
Time,t(sec)
T
e
m
p
e
r
a
t
u
r
e
,
h=120
Exact
h=240
h=480

(
K
)
Step size, h u (480) E
t
|
t
|%
480
240
120
60
30
90.278
594.91
646.16
647.54
647.57
737.85
52.660
1.4122
0.033626
0.00086900
113.94
8.1319
0.21807
0.0051926
0.00013419

http://numericalmethods.eng.usf.edu 12
Effect of step size
Table 1. Temperature at 480 seconds as a function of step size, h
K 57 . 647 ) 480 ( = u (exact)

http://numericalmethods.eng.usf.edu 13
Effects of step size on Runge-
Kutta 4
th
Order Method
Figure 2. Effect of step size in Runge-Kutta 4th order method
-200
0
200
400
600
800
0 100 200 300 400 500
Step size, h
T
e
m
p
e
r
a
t
u
r
e
,

(
4
8
0
)

http://numericalmethods.eng.usf.edu 14
Comparison of Euler and Runge-
Kutta Methods
Figure 3. Comparison of Runge-Kutta methods of 1st, 2nd, and 4th order.
0
200
400
600
800
1000
1200
1400
0 100 200 300 400 500
Time, t(sec)
T
e
m
p
e
r
a
t
u
r
e
,

(
K
)
Exact
4th order
Heun
Euler
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

Вам также может понравиться