Definition · The classical Runge–Kutta method (RK4)From (tₙ, yₙ) with step h: k₁ = f(tₙ, yₙ); k₂ = f(tₙ + h/2, yₙ + h·k₁/2); k₃ = f(tₙ + h/2, yₙ + h·k₂/2); k₄ = f(tₙ + h, yₙ + h·k₃); then yₙ₊₁ = yₙ + h·(k₁ + 2k₂ + 2k₃ + k₄)/6.
Four slopes are read per step. The lab runs it in exact fractions, up to 32 steps.
“Euler's Error and the Step Size” measured Euler's method at order 1, and “The Improved Euler Method” measured the improved method at order 2. This is the next rung. Take the simplest equation for seeing the weights: y′ = t⁴ from y(0) = 0, with one step of size h = 1. Because f has no y, the trial values play no part.
y′ = t⁴, y(0) = 0, one step, h = 1
slope read at value
k₁ t = 0 0
k₂ t = 1/2 1/16
k₃ t = 1/2 1/16
k₄ t = 1 1
y₁ = (0 + 2/16 + 2/16 + 1)/6 = (5/4)/6 = 5/24
The true value is y(1) = 1/5, and 5/24 − 1/5 = 1/120. That is hand arithmetic, and it is the whole error of the step: h⁵/120 for a step of size h from t = 0. For t⁴ the fourth derivative is constant, so every step of size h misses by the same h⁵/120, and 1/h steps give h⁴/120 from t = 0 to t = 1.
Exact on a cubic
On y′ = t³ with exact solution t⁴/4, the lab prints 0 for the error at every one of the three step sizes, the ratio tile reads — because there is nothing to divide, and the order tile reads exact (error 0). The step is Simpson's rule, and Simpson's rule integrates a cubic without error, so RK4 has nothing to get wrong here.
Exactly 16 on a quartic
On y′ = t⁴ with exact solution t⁵/5, the errors at h = 1/4, 1/8 and 1/16 are 1/30720, 1/491520 and 1/7864320. Each is h⁴/120 exactly: (1/4)⁴/120 = 1/30720. The ratios are 16 and 16, and the order is 4.
Theorem · Runge–Kutta is fourth orderFor a right-hand side with continuous fourth derivatives, the error of RK4 at a fixed T is approximately C·h⁴, so halving h divides it by about 16.
The lab shows the exact ratio on y′ = t⁴, and on y′ = y, where the errors are rounded, ratios of ≈ 14.4239 and ≈ 15.1898 that climb towards sixteen; it does not prove the order for every equation.
Example · Four slopes are not four Euler stepsFour Euler steps of size h/4 also read four slopes, and they advance by only h, each step starting from the previous step's inexact value. RK4's four slopes are combined into a single advance by h.
Count the work on y′ = t⁴ to T = 1. RK4 with h = 1/4 takes four steps, sixteen slope readings, and has error 1/30720. Euler with sixteen readings is sixteen steps of h = 1/16, with error 19627/655360 ≈ 0.0299484, rounded, which is about 920 times larger. Switch the Method menu to Euler and read the third error to see it.
The third preset runs the method on y′ = y. The true value e is irrational, so every error is rounded and the observed order, ≈ 3.92503, is near 4 and marked ≈.