Ch 8.3: The Runge-Kutta Method
Consider the initial value problem y' = f (t, y), y(t0) = y0, with
solution φ(t).
We have seen that the local truncation errors for the Euler,
backward Euler, and improved Euler methods are
proportional to h2
, h2
, and h3
, respectively.
In this section, we examine the Runge-Kutta method, whose
local truncation error is proportional to h5
.
As with the improved Euler approach, this method better
approximates the integral introduced in Ch 8.1, where we had
( )
( )( )
hfyy
ttttftt
tdttfdtt
nnn
nnnnnn
t
t
t
t
n
n
n
n
+=
−+≅
=′
+
++
∫∫
++
1
11 )(,)()(
)(,)(
11
φφφ
φφ
Runge-Kutta Method
The Runge-Kutta formula approximates the integrand
f (tn, φ(tn)) with a weighted average of its values at the two
endpoints and at the midpoint. It is given by
where
Global truncation error is bounded by a constant times h4
for a
finite interval, with local truncation error proportional to h5
.
( )43211 22
6
nnnnnn kkkk
h
yy ++++=+
),(
)2/,2/(
)2/,2/(
),(
34
23
12
1
hkyhtfk
hkyhtfk
hkyhtfk
ytfk
nnnn
nnnn
nnnn
nnn
++=
++=
++=
=
Simpson’s Rule
The Runge-Kutta formula is
where
If f(t, y) depends only on t and not on y, then we have
which is Simpson’s rule for numerical integration.
( ) ( )[ ],)2/(4
6
1 htfhtftf
h
yy nnnnn ++++=−+
( )43211 22
6
nnnnnn kkkk
h
yy ++++=+
),(
)2/,2/(
)2/,2/(
),(
34
23
12
1
hkyhtfk
hkyhtfk
hkyhtfk
ytfk
nnnn
nnnn
nnnn
nnn
++=
++=
++=
=
Programming Outline: Runge-Kutta Method
Step 1. Define f (t,y)
Step 2. Input initial values t0 and y0
Step 3. Input step size h and number of steps n
Step 4. Output t0 and y0
Step 5. For j from 1 to n do
Step 6. k1 = f (t, y)
k2 = f (t + 0.5*h, y + 0.5*h*k1)
k3 = f (t + 0.5*h, y + 0.5*h*k2)
k4 = f (t + h, y + h*k3)
y = y + (h/6)*(k1 + 2*k2 + 2*k3 + k4)
t = t + h
Step 7. Output t and y
Step 8. End
Example 1: Runge-Kutta Method (1 of 2)
Recall our initial value problem
To calculate y1 in the first step of the Runge-Kutta method for
h = 0.2, we start with
Thus
.928.10)532.11,2.00(
,532.1;66.7)69.01,1.00(
,38.1;9.6)5.01,1.00(
,0.1;5)1,0(
04
0303
0202
0101
=++=
==++=
==++=
===
fk
khfk
khfk
khfk
,1)0(,41 =+−=′ yyty
( ) 5016.2928.10)66.7(2)9.6(25
6
2.0
11 =++++=y
Example 1: Numerical Results (2 of 2)
The Runge-Kutta method (h = .05) and the improved Euler
method (h = .025) both require a total of 160 evaluations of f.
However, we see that the Runge-Kutta is far more accurate.
The Runge-Kutta method (h = .2) requires 40 evaluations of f
and the improved Euler method requires 160 evaluations of f,
and yet the accuracy at t = 2 is similar.
1)0(,41 =+−=′ yyty
Improved
Euler
Runge-
Kutta
Runge-
Kutta
Runge-
Kutta
Improved
Euler
Runge -
Kutta
Runge -
Kutta
Runge -
Kutta
t h = 0.025 h = 0.2 h = 0.1 h = 0.05 Exact
Rel Error
h = 0.025
Rel Error
h = 0.2
Rel Error
h = 0.1
Rel Error
h = 0.05
0.00 1.0000 1.0000 1.0000 1.0000 1.0000 0.0000 0.0000 0.0000 0.0000
0.10 1.6079 1.6089 1.6090 1.6090 0.0684 0.0062 0.0000
0.20 2.5021 2.5016 2.5050 2.5053 2.5053 0.1277 0.1477 0.0120 0.0000
0.30 3.8223 3.8294 3.8301 3.8301 0.2037 0.0183 0.0000
0.40 5.7797 5.7776 5.7928 5.7941 5.7942 0.2503 0.2865 0.0242 0.0017
0.50 8.6849 8.7093 8.7118 8.7120 0.3111 0.0310 0.0023
1.00 64.4979 64.4416 64.8581 64.8949 64.8978 0.6162 0.7030 0.0612 0.0045
1.50 474.8340 478.8193 479.2267 479.2592 0.9233 0.0918 0.0068
2.00 3496.6702 3490.5574 3535.8667 3539.8804 3540.2001 1.2296 1.4023 0.1224 0.0090
E x a mple 2
Adaptive Runge-Kutta Methods
The Runge-Kutta method with a fixed step size can suffer
from widely varying local truncation errors.
That is, a step size small enough to achieve satisfactory
accuracy in some parts of the interval of interest may be
smaller than necessary in other parts of the interval.
Adaptive Runge-Kutta methods have been developed,
resulting in a substantial gain in efficiency.
Adaptive Runge-Kutta methods are a very powerful and
efficient means of approximating numerically the solutions of
a large class of initial value problems, and are widely available
in commercial software packages.

Ch08 3

  • 1.
    Ch 8.3: TheRunge-Kutta Method Consider the initial value problem y' = f (t, y), y(t0) = y0, with solution φ(t). We have seen that the local truncation errors for the Euler, backward Euler, and improved Euler methods are proportional to h2 , h2 , and h3 , respectively. In this section, we examine the Runge-Kutta method, whose local truncation error is proportional to h5 . As with the improved Euler approach, this method better approximates the integral introduced in Ch 8.1, where we had ( ) ( )( ) hfyy ttttftt tdttfdtt nnn nnnnnn t t t t n n n n += −+≅ =′ + ++ ∫∫ ++ 1 11 )(,)()( )(,)( 11 φφφ φφ
  • 2.
    Runge-Kutta Method The Runge-Kuttaformula approximates the integrand f (tn, φ(tn)) with a weighted average of its values at the two endpoints and at the midpoint. It is given by where Global truncation error is bounded by a constant times h4 for a finite interval, with local truncation error proportional to h5 . ( )43211 22 6 nnnnnn kkkk h yy ++++=+ ),( )2/,2/( )2/,2/( ),( 34 23 12 1 hkyhtfk hkyhtfk hkyhtfk ytfk nnnn nnnn nnnn nnn ++= ++= ++= =
  • 3.
    Simpson’s Rule The Runge-Kuttaformula is where If f(t, y) depends only on t and not on y, then we have which is Simpson’s rule for numerical integration. ( ) ( )[ ],)2/(4 6 1 htfhtftf h yy nnnnn ++++=−+ ( )43211 22 6 nnnnnn kkkk h yy ++++=+ ),( )2/,2/( )2/,2/( ),( 34 23 12 1 hkyhtfk hkyhtfk hkyhtfk ytfk nnnn nnnn nnnn nnn ++= ++= ++= =
  • 4.
    Programming Outline: Runge-KuttaMethod Step 1. Define f (t,y) Step 2. Input initial values t0 and y0 Step 3. Input step size h and number of steps n Step 4. Output t0 and y0 Step 5. For j from 1 to n do Step 6. k1 = f (t, y) k2 = f (t + 0.5*h, y + 0.5*h*k1) k3 = f (t + 0.5*h, y + 0.5*h*k2) k4 = f (t + h, y + h*k3) y = y + (h/6)*(k1 + 2*k2 + 2*k3 + k4) t = t + h Step 7. Output t and y Step 8. End
  • 5.
    Example 1: Runge-KuttaMethod (1 of 2) Recall our initial value problem To calculate y1 in the first step of the Runge-Kutta method for h = 0.2, we start with Thus .928.10)532.11,2.00( ,532.1;66.7)69.01,1.00( ,38.1;9.6)5.01,1.00( ,0.1;5)1,0( 04 0303 0202 0101 =++= ==++= ==++= === fk khfk khfk khfk ,1)0(,41 =+−=′ yyty ( ) 5016.2928.10)66.7(2)9.6(25 6 2.0 11 =++++=y
  • 6.
    Example 1: NumericalResults (2 of 2) The Runge-Kutta method (h = .05) and the improved Euler method (h = .025) both require a total of 160 evaluations of f. However, we see that the Runge-Kutta is far more accurate. The Runge-Kutta method (h = .2) requires 40 evaluations of f and the improved Euler method requires 160 evaluations of f, and yet the accuracy at t = 2 is similar. 1)0(,41 =+−=′ yyty Improved Euler Runge- Kutta Runge- Kutta Runge- Kutta Improved Euler Runge - Kutta Runge - Kutta Runge - Kutta t h = 0.025 h = 0.2 h = 0.1 h = 0.05 Exact Rel Error h = 0.025 Rel Error h = 0.2 Rel Error h = 0.1 Rel Error h = 0.05 0.00 1.0000 1.0000 1.0000 1.0000 1.0000 0.0000 0.0000 0.0000 0.0000 0.10 1.6079 1.6089 1.6090 1.6090 0.0684 0.0062 0.0000 0.20 2.5021 2.5016 2.5050 2.5053 2.5053 0.1277 0.1477 0.0120 0.0000 0.30 3.8223 3.8294 3.8301 3.8301 0.2037 0.0183 0.0000 0.40 5.7797 5.7776 5.7928 5.7941 5.7942 0.2503 0.2865 0.0242 0.0017 0.50 8.6849 8.7093 8.7118 8.7120 0.3111 0.0310 0.0023 1.00 64.4979 64.4416 64.8581 64.8949 64.8978 0.6162 0.7030 0.0612 0.0045 1.50 474.8340 478.8193 479.2267 479.2592 0.9233 0.0918 0.0068 2.00 3496.6702 3490.5574 3535.8667 3539.8804 3540.2001 1.2296 1.4023 0.1224 0.0090 E x a mple 2
  • 7.
    Adaptive Runge-Kutta Methods TheRunge-Kutta method with a fixed step size can suffer from widely varying local truncation errors. That is, a step size small enough to achieve satisfactory accuracy in some parts of the interval of interest may be smaller than necessary in other parts of the interval. Adaptive Runge-Kutta methods have been developed, resulting in a substantial gain in efficiency. Adaptive Runge-Kutta methods are a very powerful and efficient means of approximating numerically the solutions of a large class of initial value problems, and are widely available in commercial software packages.