RUNGE-KUTTA 2nd ORDER METHOD

INTERACTIVE E-BOOK

Ordinary Differential Equations

MAJOR

GENERAL

 On non Internet Explorer browsers, the equations may not show up.

As an alternative or if you prefer,

you can see the pdf version of the ebook instead

Title

An interactive e-book for illustrating Runge-Kutta 2nd Order Method of solving ordinary differential equations

Creator

Autar K Kaw

Subject and Keywords

Runge-Kutta 2nd Order Method, Ordinary Differential Equations, Mathcad, Maple, Mathematica, Matlab, Simulations.

Description

This is an interactive E-book for illustrating Runge-Kutta 2nd Order Method for solving ordinary differential equations.  It includes links to examples, simulations in Mathcad, Maple, Mathematica, and Matlab for the algorithm, convergence, and a PowerPoint presentation.

Publisher

Holistic Numerical Methods Institute,

College of Engineering,

University of South Florida, Tampa, FL 33620-5350.

Contributors

Autar Kaw

Format

Text/HTML

Last Revised

May 4, 2006

Identifier

http://numericalmethods.eng.usf.edu/ebooks/runge2nd_08ode_ebook.pdf

Language

English

Rights

http://numericalmethods.eng.usf.edu/rights.htm

 

Table of Contents

Background

           What are ordinary differential equations?          

           A Primer on Ordinary Differential Equations

           Runge-Kutta 2nd Order Method for Ordinary Differential Equations

           PowerPoint presentation

Examples

            Example 1:  First order differential equation rewritten in dy/dx=f(x,y) form

            Example 2:  First order differential equation rewritten in dy/dx=f(x,y) form             

            Example 3:  Heat Transfer Problem Solved Using Runge-Kutta 2nd Order Method

Methods

            Heun’s Method

            Midpoint Method

            Ralston’s Method

Simulation of Runge-Kutta 2nd Order Method [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

Convergence of Runge-Kutta 2nd Order Method [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

Back to TOC

Background

This is an example of how an instructor of a Numerical Methods course can develop an E-book on a single topic by using resources that are only available at the Holistic Numerical Methods Institute (HNMI) Website.

Although one of the primary advantages of a web-based resource is that one can use documents outside of its own domain, we are particularly using this example as a way to illustrate the holistic nature of the resources available at HNMI.   You are welcome to modify and edit this e-book to suit your purpose.

Using the textbook document written in MS Word 2000 as a foundation, it was made interactive within MS Word 2000 by putting bookmarks and hyperlinks to background information, PowerPoint presentations, Mathcad simulations, historical anecdotes, multiple choice tests, problem sets, etc.   Then the MS Word 2000 file was saved as a webpage and that is what you are about to read here.

 

Back to TOC

Runge-Kutta 2nd Order Method for Ordinary Differential Equations

 

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

           

Only first order ordinary differential equations can be solved by using Runge-Kutta 2nd 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?

Back to TOC

Example 1

           

is rewritten as

           

In this case

           

Another example is given as follows:

 

Back to TOC

Example 2

           

is rewritten as

           

In this case

           

Euler’s method is given by

                                                                                                  (1)

where

           

           

           

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

           

               (2)

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

           

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

The true error in the approximation is given by

                                                                        (3)

So how 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 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, 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, Midpoint method and Ralston’s method, respectively.

 

Back to TOC

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)

 

Back to TOC

Midpoint method

Here  is chosen, giving

           

           

           

resulting in

                                                                                                           (10)

where

                                                                                                           (11a)

                                                                                   (11b)

Back to TOC

Ralston’s method

Here  is chosen, giving

           

           

           

resulting in

                                                                                          (12)

where

                                                                                                           (13a)

                                                                                   (13b)

Back to TOC

 

Simulation of Runge-Kutta 2nd Order Method [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

Convergence of Runge-Kutta 2nd Order Method [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

 

Example 3

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

             

Find the temperature at  minutes using Runge-Kutta 2nd order method.  Assume a step size of   minutes.

Solution

 

           

           

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

           

           

           

           

           

                 

                 

                 

           

                 

                 

                                   

                 

           

                 

                 

                 

           

           

                 

                 

                 

           

                 

                 

                 

                 

           

                 

                 

                 

           

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 t=480 is

           

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

 

Using smaller step size would increases 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, h