Suvarna Garge (Editor)

Runge–Kutta methods

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In numerical analysis, the Runge–Kutta methods are a family of implicit and explicit iterative methods, which includes the well-known routine called the Euler Method, used in temporal discretization for the approximate solutions of ordinary differential equations. These methods were developed around 1900 by the German mathematicians C. Runge and M. W. Kutta.

Contents

See the article on numerical methods for ordinary differential equations for more background and other methods. See also List of Runge–Kutta methods.

The Runge–Kutta method

The most widely known member of the Runge–Kutta family is generally referred to as "RK4", "classical Runge–Kutta method" or simply as "the Runge–Kutta method".

Let an initial value problem be specified as follows:

y ˙ = f ( t , y ) , y ( t 0 ) = y 0 .

Here y is an unknown function (scalar or vector) of time t, which we would like to approximate; we are told that y ˙ , the rate at which y changes, is a function of t and of y itself. At the initial time t 0 the corresponding y value is y 0 . The function f and the data t 0 , y 0 are given.

Now pick a step-size h > 0 and define

y n + 1 = y n + h 6 ( k 1 + 2 k 2 + 2 k 3 + k 4 ) , t n + 1 = t n + h

for n = 0, 1, 2, 3, ..., using

k 1 = f ( t n , y n ) , k 2 = f ( t n + h 2 , y n + h 2 k 1 ) , k 3 = f ( t n + h 2 , y n + h 2 k 2 ) , k 4 = f ( t n + h , y n + h k 3 ) . (Note: the above equations have different but equivalent definitions in different texts).

Here y n + 1 is the RK4 approximation of y ( t n + 1 ) , and the next value ( y n + 1 ) is determined by the present value ( y n ) plus the weighted average of four increments, where each increment is the product of the size of the interval, h, and an estimated slope specified by function f on the right-hand side of the differential equation.

  • k 1 is the increment based on the slope at the beginning of the interval, using y (Euler's method);
  • k 2 is the increment based on the slope at the midpoint of the interval, using y + h 2 k 1 ;
  • k 3 is again the increment based on the slope at the midpoint, but now using y + h 2 k 2 ;
  • k 4 is the increment based on the slope at the end of the interval, using y + h k 3 .
  • In averaging the four increments, greater weight is given to the increments at the midpoint. If f is independent of y , so that the differential equation is equivalent to a simple integral, then RK4 is Simpson's rule.

    The RK4 method is a fourth-order method, meaning that the local truncation error is on the order of O ( h 5 ) , while the total accumulated error is on the order of O ( h 4 ) .

    Explicit Runge–Kutta methods

    The family of explicit Runge–Kutta methods is a generalization of the RK4 method mentioned above. It is given by

    y n + 1 = y n + h i = 1 s b i k i ,

    where

    k 1 = f ( t n , y n ) , k 2 = f ( t n + c 2 h , y n + h ( a 21 k 1 ) ) , k 3 = f ( t n + c 3 h , y n + h ( a 31 k 1 + a 32 k 2 ) ) ,     k s = f ( t n + c s h , y n + h ( a s 1 k 1 + a s 2 k 2 + + a s , s 1 k s 1 ) ) . (Note: the above equations have different but equivalent definitions in different texts).

    To specify a particular method, one needs to provide the integer s (the number of stages), and the coefficients aij (for 1 ≤ j < is), bi (for i = 1, 2, ..., s) and ci (for i = 2, 3, ..., s). The matrix [aij] is called the Runge–Kutta matrix, while the bi and ci are known as the weights and the nodes. These data are usually arranged in a mnemonic device, known as a Butcher tableau (after John C. Butcher):

    The Runge–Kutta method is consistent if

    j = 1 i 1 a i j = c i  for  i = 2 , , s .

    There are also accompanying requirements if one requires the method to have a certain order p, meaning that the local truncation error is O(hp+1). These can be derived from the definition of the truncation error itself. For example, a two-stage method has order 2 if b1 + b2 = 1, b2c2 = 1/2, and a21 = c2.

    In general, if an explicit s -stage Runge–Kutta method has order p , then s p , and if p 5 , then s > p . The minimum s required for an explicit s -stage Runge–Kutta method to have order p is an open problem. Some values which are known are:

    p 1 2 3 4 5 6 7 8 min s 1 2 3 4 6 7 9 11

    Examples

    The RK4 method falls in this framework. Its tableau is

    A slight variation of "the" Runge–Kutta method is also due to Kutta in 1901 and is called the 3/8-rule. The primary advantage this method has is that almost all of the error coefficients are smaller than in the popular method, but it requires slightly more FLOPs (floating-point operations) per time step. Its Butcher tableau is

    However, the simplest Runge–Kutta method is the (forward) Euler method, given by the formula y n + 1 = y n + h f ( t n , y n ) . This is the only consistent explicit Runge–Kutta method with one stage. The corresponding tableau is

    Second-order methods with two stages

    An example of a second-order method with two stages is provided by the midpoint method:

    y n + 1 = y n + h f ( t n + 1 2 h , y n + 1 2 h f ( t n ,   y n ) ) .

    The corresponding tableau is

    The midpoint method is not the only second-order Runge–Kutta method with two stages; there is a family of such methods, parameterized by α and given by the formula

    y n + 1 = y n + h ( ( 1 1 2 α ) f ( t n , y n ) + 1 2 α f ( t n + α h , y n + α h f ( t n , y n ) ) ) .

    Its Butcher tableau is

    In this family, α = 1 2 gives the midpoint method, and α = 1 is Heun's method.

    Usage

    As an example, consider the two-stage second-order Runge–Kutta method with α = 2/3, also known as Ralston method. It is given by the tableau

    with the corresponding equations

    k 1 = f ( t n ,   y n ) , k 2 = f ( t n + 2 3 h ,   y n + 2 3 h k 1 ) , y n + 1 = y n + h ( 1 4 k 1 + 3 4 k 2 ) .

    This method is used to solve the initial-value problem

    y = tan ( y ) + 1 , y 0 = 1 ,   t [ 1 , 1.1 ]

    with step size h = 0.025, so the method needs to take four steps.

    The method proceeds as follows:

    The numerical solutions correspond to the underlined values.

    Adaptive Runge–Kutta methods

    The adaptive methods are designed to produce an estimate of the local truncation error of a single Runge–Kutta step. This is done by having two methods in the tableau, one with order p and one with order p 1 .

    The lower-order step is given by

    y n + 1 = y n + h i = 1 s b i k i ,

    where the k i are the same as for the higher-order method. Then the error is

    e n + 1 = y n + 1 y n + 1 = h i = 1 s ( b i b i ) k i ,

    which is O ( h p ) . The Butcher tableau for this kind of method is extended to give the values of b i :

    The Runge–Kutta–Fehlberg method has two methods of orders 5 and 4. Its extended Butcher tableau is:

    However, the simplest adaptive Runge–Kutta method involves combining Heun's method, which is order 2, with the Euler method, which is order 1. Its extended Butcher tableau is:

    The error estimate is used to control the step size.

    Other adaptive Runge–Kutta methods are the Bogacki–Shampine method (orders 3 and 2), the Cash–Karp method and the Dormand–Prince method (both with orders 5 and 4).

    Nonconfluent Runge–Kutta methods

    A Runge–Kutta method is said to be nonconfluent if all the c i , i = 1 , 2 , , s are distinct.

    Implicit Runge–Kutta methods

    All Runge–Kutta methods mentioned up to now are explicit methods. Explicit Runge–Kutta methods are generally unsuitable for the solution of stiff equations because their region of absolute stability is small; in particular, it is bounded. This issue is especially important in the solution of partial differential equations.

    The instability of explicit Runge–Kutta methods motivates the development of implicit methods. An implicit Runge–Kutta method has the form

    y n + 1 = y n + h i = 1 s b i k i ,

    where

    k i = f ( t n + c i h ,   y n + h j = 1 s a i j k j ) , i = 1 , , s .

    The difference with an explicit method is that in an explicit method, the sum over j only goes up to i − 1. This also shows up in the Butcher tableau: the coefficient matrix a i j of an explicit method is lower triangular. In an implicit method, the sum over j goes up to s and the coefficient matrix is not triangular, yielding a Butcher tableau of the form

    c 1 a 11 a 12 a 1 s c 2 a 21 a 22 a 2 s c s a s 1 a s 2 a s s b 1 b 2 b s b 1 b 2 b s = c A b T

    See Adaptive Runge-Kutta methods above for the explanation of the b row.

    The consequence of this difference is that at every step, a system of algebraic equations has to be solved. This increases the computational cost considerably. If a method with s stages is used to solve a differential equation with m components, then the system of algebraic equations has ms components. This can be contrasted with implicit linear multistep methods (the other big family of methods for ODEs): an implicit s-step linear multistep method needs to solve a system of algebraic equations with only m components, so the size of the system does not increase as the number of steps increases.

    Examples

    The simplest example of an implicit Runge–Kutta method is the backward Euler method:

    y n + 1 = y n + h f ( t n + h ,   y n + 1 ) .

    The Butcher tableau for this is simply:

    1 1 1

    This Butcher tableau corresponds to the formulae

    k 1 = f ( t n + h ,   y n + h k 1 ) and y n + 1 = y n + h k 1 ,

    which can be re-arranged to get the formula for the backward Euler method listed above.

    Another example for an implicit Runge–Kutta method is the trapezoidal rule. Its Butcher tableau is:

    0 0 0 1 1 2 1 2 1 2 1 2 1 0

    The trapezoidal rule is a collocation method (as discussed in that article). All collocation methods are implicit Runge–Kutta methods, but not all implicit Runge–Kutta methods are collocation methods.

    The Gauss–Legendre methods form a family of collocation methods based on Gauss quadrature. A Gauss–Legendre method with s stages has order 2s (thus, methods with arbitrarily high order can be constructed). The method with two stages (and thus order four) has Butcher tableau:

    1 2 1 6 3 1 4 1 4 1 6 3 1 2 + 1 6 3 1 4 + 1 6 3 1 4 1 2 1 2 1 2 + 1 2 3 1 2 1 2 3

    Stability

    The advantage of implicit Runge–Kutta methods over explicit ones is their greater stability, especially when applied to stiff equations. Consider the linear test equation y' = λy. A Runge–Kutta method applied to this equation reduces to the iteration y n + 1 = r ( h λ ) y n , with r given by

    r ( z ) = 1 + z b T ( I z A ) 1 e = det ( I z A + z e b T ) det ( I z A ) ,

    where e stands for the vector of ones. The function r is called the stability function. It follows from the formula that r is the quotient of two polynomials of degree s if the method has s stages. Explicit methods have a strictly lower triangular matrix A, which implies that det(IzA) = 1 and that the stability function is a polynomial.

    The numerical solution to the linear test equation decays to zero if | r(z) | < 1 with z = hλ. The set of such z is called the domain of absolute stability. In particular, the method is said to be A-stable if all z with Re(z) < 0 are in the domain of absolute stability. The stability function of an explicit Runge–Kutta method is a polynomial, so explicit Runge–Kutta methods can never be A-stable.

    If the method has order p, then the stability function satisfies r ( z ) = e z + O ( z p + 1 ) as z 0 . Thus, it is of interest to study quotients of polynomials of given degrees that approximate the exponential function the best. These are known as Padé approximants. A Padé approximant with numerator of degree m and denominator of degree n is A-stable if and only if mnm + 2.

    The Gauss–Legendre method with s stages has order 2s, so its stability function is the Padé approximant with m = n = s. It follows that the method is A-stable. This shows that A-stable Runge–Kutta can have arbitrarily high order. In contrast, the order of A-stable linear multistep methods cannot exceed two.

    B-stability

    The A-stability concept for the solution of differential equations is related to the linear autonomous equation y = λ y . Dahlquist proposed the investigation of stability of numerical schemes when applied to nonlinear systems that satisfy a monotonicity condition. The corresponding concepts were defined as G-stability for multistep methods (and the related one-leg methods) and B-stability (Butcher, 1975) for Runge–Kutta methods. A Runge–Kutta method applied to the non-linear system y = f ( y ) , which verifies f ( y ) f ( z ) ,   y z < 0 , is called B-stable, if this condition implies y n + 1 z n + 1 y n z n for two numerical solutions.

    Let B , M and Q be three s × s matrices defined by

    B = diag ( b 1 , b 2 , , b s ) , M = B A + A T B b b T , Q = B A 1 + A T B A T b b T A 1 .

    A Runge–Kutta method is said to be algebraically stable if the matrices B and M are both non-negative definite. A sufficient condition for B-stability is: B and Q are non-negative definite.

    Derivation of the Runge–Kutta fourth-order method

    In general a Runge–Kutta method of order s can be written as:

    y t + h = y t + h i = 1 s a i k i + O ( h s + 1 ) ,

    where:

    k i = f ( y t + h j = 1 s β i j k j ,   t n + α i h )

    are increments obtained evaluating the derivatives of y t at the i -th order.

    We develop the derivation for the Runge–Kutta fourth-order method using the general formula with s = 4 evaluated, as explained above, at the starting point, the midpoint and the end point of any interval ( t ,   t + h ) , thus we choose:

    α i β i j α 1 = 0 β 21 = 1 2 α 2 = 1 2 β 32 = 1 2 α 3 = 1 2 β 43 = 1 α 4 = 1

    and β i j = 0 otherwise. We begin by defining the following quantities:

    y t + h 1 = y t + h f ( y t ,   t ) y t + h 2 = y t + h f ( y t + h / 2 1 ,   t + h 2 ) y t + h 3 = y t + h f ( y t + h / 2 2 ,   t + h 2 )

    where y t + h / 2 1 = y t + y t + h 1 2 and y t + h / 2 2 = y t + y t + h 2 2 If we define:

    k 1 = f ( y t ,   t ) k 2 = f ( y t + h / 2 1 ,   t + h 2 ) k 3 = f ( y t + h / 2 2 ,   t + h 2 ) k 4 = f ( y t + h 3 ,   t + h )

    and for the previous relations we can show that the following equalities holds up to O ( h 2 ) :

    k 2 = f ( y t + h / 2 1 ,   t + h 2 ) = f ( y t + h 2 k 1 ,   t + h 2 ) = f ( y t ,   t ) + h 2 d d t f ( y t ,   t ) k 3 = f ( y t + h / 2 2 ,   t + h 2 ) = f ( y t + h 2 f ( y t + h 2 k 1 ,   t + h 2 ) ,   t + h 2 ) = f ( y t ,   t ) + h 2 d d t [ f ( y t ,   t ) + h 2 d d t f ( y t ,   t ) ] k 4 = f ( y t + h 3 ,   t + h ) = f ( y t + h f ( y t + h 2 k 2 ,   t + h 2 ) ,   t + h ) = f ( y t + h f ( y t + h 2 f ( y t + h 2 f ( y t ,   t ) ,   t + h 2 ) ,   t + h 2 ) ,   t + h ) = f ( y t ,   t ) + h d d t [ f ( y t ,   t ) + h 2 d d t [ f ( y t ,   t ) + h 2 d d t f ( y t ,   t ) ] ]

    where:

    d d t f ( y t ,   t ) = y f ( y t ,   t ) y ˙ t + t f ( y t ,   t ) = f y ( y t ,   t ) y ˙ + f t ( y t ,   t ) := y ¨ t

    is the total derivative of f with respect to time.

    If we now express the general formula using what we just derived we obtain:

    y t + h = y t + h { a f ( y t ,   t ) + b [ f ( y t ,   t ) + h 2 d d t f ( y t ,   t ) ] + + c [ f ( y t ,   t ) + h 2 d d t [ f ( y t ,   t ) + h 2 d d t f ( y t ,   t ) ] ] + + d [ f ( y t ,   t ) + h d d t [ f ( y t ,   t ) + h 2 d d t [ f ( y t ,   t ) + h 2 d d t f ( y t ,   t ) ] ] ] } + O ( h 5 ) = y t + a h f t + b h f t + b h 2 2 d f t d t + c h f t + c h 2 2 d f t d t + + c h 3 4 d 2 f t d t 2 + d h f t + d h 2 d f t d t + d h 3 2 d 2 f t d t 2 + d h 4 4 d 3 f t d t 3 + O ( h 5 )

    and comparing this with the Taylor series of y t + h around y t :

    y t + h = y t + h y ˙ t + h 2 2 y ¨ t + h 3 6 y t ( 3 ) + h 4 24 y t ( 4 ) + O ( h 5 ) = = y t + h f ( y t ,   t ) + h 2 2 d d t f ( y t ,   t ) + h 3 6 d 2 d t 2 f ( y t ,   t ) + h 4 24 d 3 d t 3 f ( y t ,   t )

    we obtain a system of constraints on the coefficients:

    { a + b + c + d = 1 1 2 b + 1 2 c + d = 1 2 1 4 c + 1 2 d = 1 6 1 4 d = 1 24

    which when solved gives a = 1 6 , b = 1 3 , c = 1 3 , d = 1 6 as stated above.

    References

    Runge–Kutta methods Wikipedia