4.8.24 · D1Numerical Methods

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

1,870 words9 min readBack to topic

This page builds every piece of vocabulary the parent note RK4 derivation leans on — starting from things a 12-year-old already knows and adding exactly one new idea at a time. Nothing here is assumed; if a symbol appears, it was defined a line earlier.


1. A function and the notation

The letter is the horizontal position (how far right we've walked). The letter is the vertical position (the height). So is a rule that, given where you are on a map (a right-distance and a height), hands you back a single number.

In our topic that returned number is a slope — how tilted the path is at that spot. Look at Figure 1: at every point of the plane, paints a little arrow showing which way to lean.

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

2. Slope, and the symbol

Picture a ramp. If for every metre you walk right you rise metres, the slope is . We give this "rate of rising" a shorthand symbol:

So the whole problem of our topic is a sentence: which reads: "the slope of my curve, at any point, is given by the machine ." We know the slope-rule everywhere; we do not know the curve itself. Our job is to reconstruct the curve.

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

3. The Initial Value Problem (IVP) and

Knowing the slope everywhere still isn't enough — infinitely many curves have the same slope-field, just shifted up or down. We must nail down one starting point.

A slope-rule plus a starting point is called an Initial Value Problem (IVP). Figure 1's arrows are the slope-rule; a single dot pins the curve. From that dot, the arrows tell you where to go next.


4. Subscripts , — marching in steps

We can't draw the curve in one smooth swoop; we take it one small hop at a time.

So is a chain of stepping-stones across the fog.


5. The step size

Figure 3 shows the same step done with small vs large : the small step hugs the true curve, the large step can drift.

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

6. The integral

The parent note writes the exact answer as an integral. Here is that symbol from zero.

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

So the exact step is "new height = old height + total rise":


7. Big-O notation: ,

  • Local error : the mistake made in one single step.
  • Global error : the total mistake after crossing a whole interval. Crossing takes about steps, so per-step errors pile up into — one power is lost. (More in Local vs Global Truncation Error.)

8. Taylor series — the "true answer" we chase

The parent note tunes RK4 to match the Taylor series of the real curve. What is that?

Here ("y double-prime") is the slope of the slope — how fast the tilt itself is changing (the curve's bending). RK4's cleverness: it reproduces those terms without ever computing — it fakes them with extra evaluations of . See Taylor Series Methods for the version that computes them directly.


9. The stage slopes

You don't need to derive these here — the parent note does. You only need to read as "a walked-height guess from one peek at the slope." Modified Euler / Heun's Method uses just two peeks (edges); RK4 uses four.


Prerequisite map

Function f x,y a slope machine

Slope y prime rise over run

IVP slope rule plus starting dot

Marching in steps counter n

Step size h how far we hop

Integral total accumulated rise

Taylor series the true answer

Big O error shrinks like h power

Stage slopes k1 k2 k3 k4

RK4 formula blends four peeks


Equipment checklist

Read the prompt, answer in your head, then reveal.

What does output in this topic?
A slope — how tilted the curve is at the point .
What does mean in plain words?
The slope of the curve : how fast height changes per step right.
Why does need two inputs and ?
The slope can depend on both where you are horizontally and how high you already are.
What turns a slope-field into a single curve?
The initial condition — one pinned starting dot.
What do the subscripts and track?
Which hop we're on; is the next stepping-stone.
What is the step size ?
How far right we hop each step: .
Why is every multiplied by ?
Slope is rise per unit run; over a run of the rise is .
What does the integral represent geometrically?
The area under the slope curve = total height gained over the step.
What does tell you?
Halving shrinks the error by ; higher power = more accurate.
Difference between local and global error?
Local = one step's mistake (); global = accumulated over steps ().
What is a Taylor series here?
The exact curve rebuilt from — the target RK4 matches to .
What is each ?
An estimate of the step's rise from a slope-peek at one chosen sample point.

Connections