Back to the on-screen lesson ·

Runge-Kutta methods

Several slope samples inside one step, weighted so the error terms cancel, why the classical four-stage method is Simpson's rule in disguise, and what an order costs.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

By the end of this lesson you will be able to carry out a classical Runge-Kutta step stage by stage, say where its weights come from, state what fourth order does and does not promise, and compare solvers at equal evaluation cost.

2. What you already know

You have seen a second slope sample raise Euler's method by an order, and you know that Simpson's rule integrates a cubic exactly using three samples. Runge-Kutta methods are those two ideas together: more samples inside one step, weighted so that more error terms cancel.

3. The words this lesson uses

A stage is one slope evaluation inside a step; a method is $s$-stage when it uses $s$ of them. The weights say how the stages are combined and the nodes say where in the step each is sampled. The classical Runge-Kutta method is the four-stage, fourth-order one. A Butcher barrier is a theorem saying how many stages an order needs.

4. Runge-Kutta methods

Take several slope samples inside a single step and weight them so that the leading error terms cancel. Euler is the one-stage member and Heun a two-stage one; the classical method takes four: $k_1 = f(t_n, y_n)$; $k_2 = f(t_n + \tfrac{h}{2}, y_n + \tfrac{h}{2}k_1)$; $k_3 = f(t_n + \tfrac{h}{2}, y_n + \tfrac{h}{2}k_2)$; $k_4 = f(t_n + h, y_n + hk_3)$; and $y_{n+1} = y_n + \tfrac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)$. It is fourth order: halving the step divides the global error by sixteen. Where those weights come from is worth seeing once — for an equation whose slope depends on $t$ alone, $k_2$ and $k_3$ coincide and the combination becomes $\tfrac{h}{6}(f(t_n) + 4f(t_n + \tfrac h2) + f(t_n + h))$, which is Simpson's rule. Two cautions. Up to order four an extra order costs one extra stage, and after that the deal collapses: order five needs six stages and order eight needs eleven, which is why the four-stage method is the one in every library. And order is not stability — the classical method's stability region is bounded and barely larger than Heun's, so a step chosen for accuracy alone can still produce a solution that grows without limit.

Another way: picture

One step, four soundings: one at the near edge, two in the middle taken from slightly different guesses, and one at the far edge reached using the third. The step is taken along a weighted average of the four directions, with the middle pair counting double because the middle of the step is where the average slope most nearly lives.

Another way: steps

  1. $k_1$ at the current point.
  2. $k_2$ at the midpoint, reached with $k_1$.
  3. $k_3$ at the midpoint again, reached with $k_2$.
  4. $k_4$ at the far end, reached with $k_3$; then step by $\tfrac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)$.

5. The mistake to watch for

'Fourth order' is often heard as 'accurate'. It is a statement about a rate, and it carries two conditions: the step must be small enough for the asymptotic regime, and the solution must actually have the fifth derivative the error term names. On a problem with a kink, a fourth-order method delivers whatever order the kink allows and the extra three stages are simply wasted — which is why a serious solver measures the order it is getting rather than assuming the one it was sold.

6. Where the weights come from

  1. For $y' = f(t)$ the stages do not depend on $y$, so $k_2 = k_3$.

    Both sample the midpoint.

  2. The combination becomes $\tfrac{h}{6}(f_0 + 4f_{1/2} + f_1)$.

    Simpson's rule.

  3. So the fourth order is quadrature's fourth order, arriving by a different road.

    One idea, two subjects.

7. When four stages are not worth it

  1. A solution with a corner has no fifth derivative there.

    The error term does not exist.

  2. Measured order across the corner falls to one, whatever the method claims.

    Four stages, first-order results.

  3. The cure is to stop the step at the corner and restart, not to raise the order further.

    Match the method to the solution.

8. Your turn: the four stages for $y' = t$ from $t = 0$ with $h = 2$

  1. $k_1 = 0$, and the midpoint is at $t = 1$, so $k_2 = k_3 = 1$.

  2. $k_4 = 2$, at the far end.

  3. Your turn: work this step out. Its working is at the end of the packet.

    The combination is $\tfrac{0 + 2 + 2 + 2}{6} = 1$, so the step adds $2 \times 1 = 2$ — and the exact answer is $\tfrac{2^{2}}{2} = 2$.

9. Guided practice

Take one classical Runge-Kutta step on $y' = t$ from $t = 6$, $y = 3$, with step $1$. Fill in the four stage slopes and the value the step produces.

Value
First stage
Second stage
Third stage
Fourth stage
Value after the step

10. Guided practice

A solver advertises the classical Runge-Kutta method: four stages a step, fourth order. A run of $15$ steps is planned. What does the claim actually establish?

11. Practice

Consider the classical Runge-Kutta method, which is order $4$ and uses $4$ slope evaluation(s) a step, and three others. Match each method to its order and cost.

Order 1, for one slope evaluation a stepOrder 2, for two slope evaluations a stepOrder 4, for four slope evaluations a stepOrder 8, but eleven evaluations: order and stage count have parted company
Euler's method
Heun's method
The classical Runge-Kutta method
An eighth-order Runge-Kutta method

12. Practice

Put one step of the classical Runge-Kutta method, inside a loop of $44$ steps, into order.

Number the steps in order (write the number in the box):

13. Somewhere new

The classical Runge-Kutta method with step $0.25$ costs the same number of slope evaluations as Euler's method with step $\tfrac{0.25}{4}$. Runge-Kutta's error is proportional to the fourth power of its step and Euler's to the first power of its step, with the same constant. What is the ratio of the Runge-Kutta error to Euler's? Give a fraction.

Answer:

14. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

15. Test question

Take one classical Runge-Kutta step on $y' = t$ from $t = 7$, $y = 0$, with step $2$. What is the value after the step?

Answer:

16. What you can do now

You can run a four-stage step and state the order and cost of each solver you have met. Say in your own words why order and stage count stop matching above order four.

Working for the steps left to you

8. Your turn: the four stages for $y' = t$ from $t = 0$ with $h = 2$, step 3