RungeKutta.pdf

download RungeKutta.pdf

of 3

Transcript of RungeKutta.pdf

  • 8/10/2019 RungeKutta.pdf

    1/3

    Runge-Kutta Method

    The Runge-Kutta method, discovered by German mathematicians Carl Runge and Martin Kutta,is a powerful fourth order method (i.e. the error is at most a fixed constant times the fourth powerof the step size, h), thus a great improvement over the Improved Eulers method. To justify thisscheme, we need to review Simpsons Rule for estimating a definite integral.

    Simpsons Rule

    Suppose we have a definite integral of the form a+ha

    f(x)dx.

    Two ways of approximating this area are (1) to use a trapezoid and (2) to use a rectangle whoseheight is determined by the midpointa+h/2. If we call these approximationsTandM, respectively,then their formulas are:

    T =h

    2(f(a) +f(a+h))

    andM=hf(a+h/2).

    It can be shown that the error in the trapezoid rule is given by

    ET = 1

    24h3f(a) + O(h4)

    and the error in the midpoint rule is given by

    EM= 1

    12h3f(a) + O(h4)

    where O(h4) means the remaining error terms are proportional to at least h4. Simpsons rule isprecisely the right weighted average ofT and Mso that the leading error terms cancel. From theabove we see that this combination is

    2M+ T

    3 .

    Substituting in the formulas for M andT give2M+ T

    3 =

    2(hf(a+h/2)) + h2

    (f(a) +f(a+h))

    3

    =h

    6

    f(a) + 4f(a+h/2) +f(b)

    Thus we have Simpsons Rule: a+ha

    f(x)dx h

    6

    f(a) + 4f(a+h/2) +f(b)

    .

  • 8/10/2019 RungeKutta.pdf

    2/3

    The Runge-Kutta Method

    Recall that integrating the IVP

    y =f(x, y) y(x0) =y0

    on the interval [xk, xk+1]gives the formula

    y(xk+1) =y(xk) +

    xk+hxk

    f(x, y(x))dx

    The corresponding numerical scheme depends on an approximation for the definite integral on theRHS. We have seen that Eulers method arises from approximating this integral with a rectangleof heightf(xk)and that the Improved Eulers method arises from approximating this integral by atrapezoid. If we instead apply Simpsons Rule we get

    (1) y(xk+1) y(xk) +h

    6

    f(xk, y(xk)) + 4f(xk+h/2, y(xk+h/2)) +f(xk+h, yk+1)

    .

    On the RHS we can approximate yk = y(xk), but we are left with the problem of approximating

    f(xk+h/2, y(xk+h/2))

    and alsoyk+1.

    We will need the following definitions to make our notation simpler:

    Lk,1= f(xk, yk)

    Lk,2=f

    xk+h/2, yk+ (h/2)Lk,1

    Lk,3=f

    xk+h/2, yk+ (h/2)Lk,2

    Lk,4= f

    xk+h, yk+hLk,3

    Note thatLk,2 is the approximation offat the midpoint using Eulers method and Lk,3 is anotherapproximation off at the midpoint, using Lk,2 instead ofLk,1. We average these two to get the

    approximationf(xk+h/2, y(xk+h/2))

    Lk,2+Lk,32

    Now we use Lk,3 as our approximation offat the midpoint to approximate

    yk+1 yk+hLk,3.

    Plugging these back into equation (1) gives the Runge-Kutta method:

    yk+1= yk+h

    6

    Lk,1+ 2Lk,2+ 2Lk,3+Lk,4

    .

  • 8/10/2019 RungeKutta.pdf

    3/3

    Example

    Using the Runge-Kutta method with step size h = 0.1, determine an approximate value of thesolution atx = 1 for the initial value problem

    y = 2xy, y(0) = 2

    and compare the results with the value of the solution y(x) = 2et2

    .

    SolutionIn this case the Runge-Kutta scheme becomes

    Lk,1 = 2(xk)(yk)

    Lk,2 = 2

    xk+

    0.1

    2

    yk+

    0.1

    2 Lk,1

    Lk,3 = 2

    xk+

    0.1

    2

    yk+

    0.1

    2 Lk,2

    Lk,4= 2 (xk+ 0.1) (yk+ 0.1Lk,3)

    and lastly

    yk = h

    6

    Lk,1+ 2Lk,2+ 2Lk,3+Lk,4

    Starting with x0= 0 andy0= 2 we successively compute:

    k xk yk0 0 21 0.1 2.0201003332 0.2 2.081621543 0.3 2.1883485314 0.4 2.3470216275 0.5 2.568050511

    6 0.6 2.8666579897 0.7 3.2646303758 0.8 3.7929569359 0.9 4.4958051810 1 5.436540351

    So the Runge-Kutta method with h = 0.1 estimates y(1) y10 5.43654035. From thesolution given above we see that the actual value ofy(1) is

    y(1) = 2e12

    = 2e 5.43656366.

    Thus with only ten steps this method is already accurate to 4 decimal places!