Textbook Notes for Runge-Kutta 2Nd Order Method for Ordinary Differential Equations

Textbook Notes for Runge-Kutta 2Nd Order Method for Ordinary Differential Equations

Runge-Kutta 2nd Order Method 08.03.1

Chapter 08.03
Runge-Kutta 2nd Order Method for
Ordinary Differential Equations

After reading this chapter, you should be able to:

  1. understand the Runge-Kutta 2nd order method for ordinary differential equations and how to use it to solve problems.

What is the Runge-Kutta 2nd order method?

The Runge-Kutta 2nd order method is a numerical technique used to solve an ordinary differential equation of the form

Only first order ordinary differential equations can be solved by using the Runge-Kutta 2nd order method. In other sections, we will discuss how the 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

in

form.

Solution

In this case

Example 2

Rewrite

in

form.

Solution

In this case

Runge-Kutta 2nd order method

Euler’s method is given by

(1)

where

To understand the Runge-Kutta 2nd order method, we need to derive Euler’s method from the Taylor series.

(2)

As you can see the first two terms of the Taylor series

are Euler’s method and hence can be considered to be the Runge-Kutta 1st order method.

The true error in the approximation is given by

(3)

So what would a 2nd order method formula look like. It would include one more term of the Taylor series as follows.

(4)

Let us take a generic example of a first order ordinary differential equation

Now since y is a function of x,

(5)

The 2nd order formula for the above example would be

However, we already see the difficulty of having to find in the above method. What Runge and Kutta did was write the 2nd order method as

(6)

where

(7)

This form allows one to take advantage of the 2nd order method without having to calculate.

So how do we find the unknowns , , and . Without proof (see Appendix for proof), equating Equation (4) and (6) , gives three equations.

Since we have 3 equations and 4 unknowns, we can assume the value of one of the unknowns. The other three will then be determined from the three equations. Generally the value of is chosen to evaluate the other three constants. The three values generally used for are, and, and are known as Heun’s Method, the midpoint method and Ralston’s method, respectively.

Heun’s Method

Here is chosen, giving

resulting in

(8)

where

(9a)

(9b)

This method is graphically explained in Figure 1.

Figure 1 Runge-Kutta 2nd order method (Heun’s method).

Midpoint Method

Here is chosen, giving

resulting in

(10)

where

(11a)

(11b)

Ralston’s Method

Here is chosen, giving

resulting in

(12)

where

(13a)

(13b)

Example 3

A ball at K is allowed to cool down in air at an ambient temperature of K. Assuming heat is lost only due to radiation, the differential equation for the temperature of the ball is given by

where is in Kand in seconds. Find the temperature at seconds using Runge-Kutta 2nd order method. Assume a step size of seconds.

Solution

Per Heun’s method given by Equations (8) and (9)

K

K

K

The results from Heun’s method are compared with exact results in Figure 2.

The exact solution of the ordinary differential equation is given by the solution of a non-linear equation as

The solution to this nonlinear equation at s is

K

Figure 2 Heun’s method results for different step sizes.

Using a smaller step size would increase the accuracy of the result as given in Table 1 and Figure 3 below.

Table 1 Effect of step size for Heun’s method

Step size, / / /
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
Figure 3 Effect of step size in Heun’s method.

In Table 2, Euler’s method and the Runge-Kutta 2nd order method results are shown as a function of step size,

Table 2 Comparison of Euler and the Runge-Kutta methods

Step size,
/
Euler / Heun / Midpoint / Ralston
480
240
120
60
30 / -987.84
110.32
546.77
614.97
632.77 / -393.87
584.27
651.35
649.91
648.21 / 1208.4
976.87
690.20
654.85
649.02 / 449.78
690.01
667.71
652.25
648.61

while in Figure 4, the comparison is shown over the range of time.


Figure 4 Comparison of Euler and Runge Kutta methods with exact
results over time.

How do these three methods compare with results obtained if we found directly?

Of course, we know that since we are including the first three terms in the series, if the solution is a polynomial of order two or less (that is, quadratic, linear or constant), any of the three methods are exact. But for any other case the results will be different.

Let us take the example of

.

If we directly find , the first three terms of the Taylor series gives

where

For a step size of, using Heun’s method, we find

The exact solution

gives

Then the absolute relative true error is

For the same problem, the results from Euler’s method and the three Runge-Kutta methods are given in Table 3.

Table 3 Comparison of Euler’s and Runge-Kutta 2nd order methods

y(0.6)
Exact / Euler / Direct 2nd / Heun / Midpoint / Ralston
Value / 0.96239 / 0.4955 / 1.0930 / 1.1012 / 1.0974 / 1.0994
% / 48.514 / 13.571 / 14.423 / 14.029 / 14.236

Appendix A

How do we get the 2nd order Runge-Kutta method equations?

We wrote the 2nd order Runge-Kutta equations without proof to solve

, (A.1)

as

(A.2)

where

(A.3a)

(A.3b)

and

(A.4)

The advantage of using 2nd order Runge-Kutta method equations is based on not having to find the derivative of symbolically in the ordinary differential equation

So how do we get the above three Equations (A.4)? This is the question that is answered in this Appendix.

Writing out the first three terms of Taylor series are

(A.5)

where

Since

we can rewrite the Taylor series as

(A.6)

Now

. (A.7)

Hence

(A.8)

Now the term used in the Runge-Kutta 2nd order method for can be written as a Taylor series of two variables with the first three terms as

(A.9)

Hence

(A.10)

Equating the terms in Equation (A.8) and Equation (A.10), we get

ORDINARY DIFFERENTIAL EQUATIONS
Topic / Runge 2nd Order Method for Ordinary Differential Equations
Summary / Textbook notes on Runge 2nd order method for ODE
Major / General Engineering
Authors / Autar Kaw
Last Revised / February 3, 2019
Web Site /