Computational & Experimental Physics

the Runge-Kutta method

/ ROONG-uh KOOT-tah /

Euler's method trusts the slope measured only at the start of each step and marches blindly to the end, which is why it drifts. Runge-Kutta does something smarter and more human: before committing to a step, it probes the slope at several points across the interval, including a look partway ahead, and then advances by a cleverly weighted average of those probes. It is the difference between glancing once at the road and checking a few times as you round a bend.

The classic fourth-order scheme, RK4, integrates dx/dt = f(t, x) over one step h by evaluating four slopes: k1 = f(t, x); k2 = f(t + h/2, x + h k1 / 2); k3 = f(t + h/2, x + h k2 / 2); k4 = f(t + h, x + h k3). It then updates x(t + h) = x(t) + (h/6)(k1 + 2 k2 + 2 k3 + k4). This particular weighting cancels the Taylor-series error through fourth order, giving a local error of order h^5 and a global error of order h^4. Four function evaluations per step buy a dramatic gain: to reach a target accuracy RK4 needs far larger steps than Euler.

RK4 is the general-purpose workhorse for ordinary differential equations, and adaptive-step variants (Runge-Kutta-Fehlberg, Dormand-Prince, the engine inside routines like RK45) estimate the local error on the fly and shrink or grow h automatically. The honest caveat: RK4 is not symplectic, so for a Hamiltonian system integrated over very long times its energy still slowly drifts, and there a lower-order symplectic method like Verlet is actually superior. Higher order is also not always better, since round-off error and the cost of extra evaluations eventually dominate.

Integrating a Kepler orbit, RK4 with a modest time step follows the ellipse faithfully over many revolutions, whereas forward Euler at the same step size visibly spirals; each RK4 step's local error shrinks like h^5, so halving h cuts the per-step error roughly 32-fold.

Four slope probes per step turn Euler's first-order crawl into fourth-order accuracy.

The 'fourth order' in RK4 refers to the global error scaling as h^4, not to the number of stages; and because RK4 is not symplectic, a lower-order symplectic integrator can beat it for long-time energy conservation despite RK4's higher local accuracy.

Also called
RK4fourth-order Runge-Kutta四階龍格-庫塔法RK 法