What is it?
Sample the slope at several points inside the step and combine them to cancel error terms. The classic RK4 has
error : halve the step, divide the error by 16. Adaptive pairs (Dormand–Prince, ode45, solve_ivp)
adjust automatically.
Intuition
Euler trusts the slope at the start of the step. RK2 (midpoint) takes a half step, looks at the slope there, and uses that slope for the full step. RK4 does this four times and averages with weights — like Simpson's rule for integrals. The weights are chosen so the result agrees with the Taylor expansion up to .
Formulas
- classic RK4
Why does it matter?
RK methods are the default for non-stiff problems in scientific computing (MATLAB ode45, SciPy RK45), used in
orbit propagation, chemical kinetics and the adaptive solvers inside neural ODEs. Games prefer cheaper, symplectic
schemes; scientists prefer accuracy per function evaluation.
Where it shows up in computing
Adaptive Runge–Kutta pairs are the standard general-purpose ODE solvers.
High-order RK is used for accurate short-term orbits; symplectic methods for long-term stability.
Atmospheric models advance their discretized equations in time with Runge–Kutta-type schemes.
Where it shows up in AI
Neural ODE libraries (torchdiffeq, Diffrax) default to adaptive Runge–Kutta solvers.
Where is it used?
Computing topics reachable from here, through the chain of ideas that leads to them:
Exercises
RK4 costs 4 evaluations of per step, Euler 1. For error on , roughly how many evaluations does each need if the error constants are about 1?
Solution
Euler: → evaluations. RK4: → , about 32 steps → ~130 evaluations. Higher order wins by orders of magnitude.