Runge-Kutta Activity4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Computational Methods for Mechatronics (EMEng 6441)

Chapter 1 Notes Continued: Runge-Kutta’s Methods

Note: Runge-Kutta methods are widely applied in latter chapters.

Recall that the general solution for the first-order ODE:

can be expressed as:

where φ(xi, yi) is an increment function and is essentially a suitable slope over the interval [xi,
xi+1] that is used for extrapolating yi+1 from yi.

Runge–Kutta methods generate solution estimates with the accuracy of Taylor methods without
having to calculate the derivative of f(x,y). The order of the Runge–Kutta method is the number
of points that are used in [xi, xi+1] to determine this suitable slope. For example, second-order
Runge–Kutta methods use two points in each subinterval to find the representative slope, and so
on.

For the second-order Runge–Kutta (RK2) method, the increment function is expressed as

(1)

where

(2)

where a1, a2, b1, and c11 are constants. These constants are evaluated by setting the Taylor series
expansion equal to the first three terms.

(3)

(4)

Using Chain rule:


(5)

Substituting (4) and (5) into (3) gives:

(6)

Taylor expansion of k2 about (xi,yi) gives (considering only the first two terms):

(7)

Substituting Equation (7) and k1 = f(xi, yi) in Equation (1), we find

(8)

Comparing Equations (6) and (8), we find that:

Since there are four unknowns and only three equations, a unique set of solutions does not
exist. But if a value is assigned to one of the constants, the other three can be calculated.

Assuming the values for the other constants will be:


Hence:

Higher-Order Runge-Kutta Methods are summarized as follows without derivation for the
values of the coffiecients. (You don’t have to memorize any of these formulas. You will be
provided with them whenever needed).

Third-Order Runge-Kutta Method (RK3)

For the third-order Runge–Kutta (RK3) methods, the increment function is expressed as

So that

After the coefficients are calculated in a similar manner as the second-order Runge-Kutta
formula, RK3 formula is described by:

with
Fourth-Order Runge-Kutta Method (RK4)

For the fourth-order Runge–Kutta (RK4) methods, the increment function is expressed as:

So that:

Again, after the coefficients are calculated in a similar manner as the second-order Runge-
Kutta formula, RK4 formula is described by:

where
Activity 4

Consider the following ODE:

4.1. Show that the exact solution for the above ODE is

4.2.Write a Matlab function called RK4 that implements the Fourth-Order Runge-Kutta
method (RK4) with output parameter yRK4 and three input parameters f, x, and y0, where
f represents f(x,y), x represents an input vector representing the mesh points, y0 is a scalar
representing the initial value of y, and yRK4 is a vector of solution estimates at each mesh
point.
4.3.Write a Matlab script that uses the RK4 function implemented in (4.2) to find solution
estimates to the above ODE using step size of h=0.1.
4.4.Repeat activities 4.1 and 4.2 for second-order (RK2) and third-order (RK3) Runge-Kutta
methods and compare the error performances of the three methods.

You might also like