4.8.24 · D4Numerical Methods

Exercises — Runge-Kutta 4th order (RK4) — derivation

2,257 words10 min readBack to topic

This page is a self-testing ladder. Work each problem before opening its solution. The levels climb from "can you spot RK4?" up to "can you build and prove things with it?". Every symbol used here is defined on the parent note RK4 derivation — keep it open as your reference.

Figure — Runge-Kutta 4th order (RK4) — derivation

Level 1 — Recognition

Goal: can you read the recipe and identify its parts?

L1.1

In the RK4 recipe, at which -value is evaluated, and which previous slope does it reuse?

Recall Solution

. So it is sampled at the midpoint , and it reuses (a refined midpoint slope). Look at figure s01: the two amber arrows ( and ) share the same vertical dashed line at the midpoint; only the height of the estimated differs.

L1.2

A student writes using . Is the extra correct here, or should it be ?

Recall Solution

It should be , not . In our convention each already contains one factor of (because ). Putting would multiply by twice, giving an step — wrong dimensions. The form is only correct in the other convention where is a pure slope (no ).


Level 2 — Application

Goal: turn the crank on real numbers.

L2.1

Solve , for one step to find using . (Different step size from the parent's example.)

Recall Solution

Here , , , .

  • — slope at left edge.
  • — midpoint, using .
  • — refined midpoint, using .
  • — right edge, using full . Exact: . Error .

L2.2

Solve , for one step to with . (Note: has no -dependence, so all stages use the same shift trivially.)

Recall Solution

, , .

  • .
  • .
  • .
  • . Let's check the bracket: , and . Exact: . Here the step is large for a fast-decaying equation, so the error () is visible — a reminder that "4th order" is a statement about small .

Level 3 — Analysis

Goal: reason about behaviour, not just numbers.

L3.1

For (right-hand side depends on only), show that the RK4 update collapses into Simpson's rule for .

Recall Solution

When depends only on , the -arguments are irrelevant, so: Substituting into the update: That last line is exactly Simpson's rule for the integral over . So RK4 is Simpson's rule, generalized to allow -dependence. This is why the weights are : the two midpoint samples merge into the single "" of Simpson.

L3.2

The local (per-step) error of RK4 is . Explain why the global error over a fixed interval is only .

Recall Solution

To cross a fixed length you take steps — that is, .

What "each step adds " means. On a single step the method's answer differs from the true curve by an amount bounded by (some constant) . Call that constant : it packages together how curvy the solution is (roughly, the size of its 5th derivative over the interval) and the fixed numerical factor that RK4 leaves behind. does not shrink as shrinks — it depends on the problem, not the step — so the whole -dependence of one step's error lives in the . That is why we write "local error ".

Why the errors add up (error propagation). Picture the calculation as a relay: each step starts from the previous step's (already slightly wrong) answer and adds its own fresh mistake. So two things happen at every step — (i) a new error is committed, and (ii) the errors already present get carried forward. For a well-behaved (stable) equation the carried-forward errors don't blow up; they grow at most by a bounded factor. In that case the total is dominated by simply summing the fresh contributions, one per step: One power of is "eaten" by the growing number of steps: you make more steps when is small, so more little errors pile up, cancelling one factor of . See Local vs Global Truncation Error. This is why RK4 is called 4th order (the global statement), even though each step is th-order accurate.


Level 4 — Synthesis

Goal: combine RK4 with other ideas and run more than one step.

L4.1

Solve , using two RK4 steps of size to estimate . Compare with the single-step-of- result ( from the parent) and the exact .

Recall Solution

, .

Step 1 ():

Step 2 ():

  • The bracket sum , so . Exact ; error . The single big step gave (error ). Halving the step cut the error by roughly — the signature of a 4th-order method.

L4.2

Using the observation in L4.1, predict the error if you instead used four steps of for the same problem, without computing them. State the reasoning.

Recall Solution

Global error . Going from to halves , so the error scales by . So we predict . (Direct computation gives error — the rule works.)


Level 5 — Mastery

Goal: prove and build.

L5.1

Show algebraically that RK4 applied to , with a single step of size gives i.e. the first five terms of . (This is the direct proof that RK4 matches Taylor to .)

Recall Solution

With , :

Now combine with weights : Collect by power of :

  • : → contributes .
  • : → contributes .
  • : → contributes .
  • : → contributes .

So . Divide by : These are exactly the first five terms of . The first term RK4 misses is — confirming local error . See Taylor Series Methods.

L5.2

Solve the coupled system with using one RK4 step to estimate . (This is , simple harmonic motion; exact answer .) Use vector RK4: treat and .

Recall Solution

Vector RK4 is identical to scalar RK4, just applied componentwise. Let , , .

: , so .

: argument ; ; so .

: argument ; ; so .

: argument ; ; so .

Combine componentwise, :

  • :
  • :

So . Exact: . Both match to about — RK4 handles systems with the same 4th-order accuracy, no new machinery needed.


Connections

Active Recall