← Back to Differential Equations

Runge-Kutta and multistep methods

Higher-order methods sample the slope more cleverly, gaining far more accuracy per step than Euler's method.

Improving on Euler

Euler uses only the slope at the start of each step. Better methods combine slopes from several points in the step, cancelling more of the error. The payoff is dramatic: a fourth-order method can be more accurate with 10 steps than Euler with 10,000.

Heun's method

Predict with Euler, \(\tilde{y} = y_n + hf(t_n, y_n)\), then correct using the average of the start and predicted end slopes: \(y_{n+1} = y_n + \frac{h}{2}[f(t_n, y_n) + f(t_{n+1}, \tilde{y})]\). It is second order: halving \(h\) cuts the error by about four.

Classical Runge-Kutta (RK4)

RK4 computes four slopes: \(k_1 = f(t_n, y_n)\), \(k_2 = f(t_n + \frac{h}{2}, y_n + \frac{h}{2}k_1)\), \(k_3 = f(t_n + \frac{h}{2}, y_n + \frac{h}{2}k_2)\), \(k_4 = f(t_n + h, y_n + hk_3)\), and combines them as a weighted average. Its global error is proportional to \(h^4\).

y_{n+1} = y_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)

Worked example

For \(y' = y\), \(y(0) = 1\), one RK4 step of \(h = 1\) gives \(k_1 = 1\), \(k_2 = 1.5\), \(k_3 = 1.75\), \(k_4 = 2.75\), and \(y_1 = 1 + \frac{1}{6}(1 + 3 + 3.5 + 2.75) \approx 2.708\), within 0.4% of \(e\) in a single step. Euler with \(h = 1\) gives 2.

Adaptive step sizes

Modern solvers estimate the error at each step, often by comparing two methods of different order (as in the Dormand-Prince pair), and adjust \(h\) automatically: large steps where the solution is smooth, small steps where it changes rapidly. This is how software like MATLAB's ode45 and Python's solve_ivp work.

Multistep methods

Adams-Bashforth methods reuse slopes from previous steps instead of computing new intermediate ones, saving function evaluations. They need a starting method (often RK4) for the first few steps. Predictor-corrector pairs combine explicit and implicit multistep formulas.

Methods for stiff problems

Stiff systems, common in chemistry and circuits, need implicit methods such as backward differentiation formulas (BDF). Software offers dedicated stiff solvers; using a non-stiff method on a stiff problem wastes enormous time with tiny steps.

Conservation and long-time simulation

For orbits and molecular dynamics, ordinary methods slowly drift in energy. Symplectic integrators, like the velocity Verlet method, preserve the geometric structure of mechanics and keep energy errors bounded over millions of steps, which matters for simulating planets or proteins.

Key takeaways

Heun's method is second order; RK4 is fourth order and the workhorse of non-stiff problems. Adaptive solvers adjust the step automatically. Multistep methods reuse past slopes. Stiff problems need implicit methods, and symplectic integrators preserve energy in long simulations.

Flashcard

Heun's method

Predictor-corrector averaging two slopes

Second order.

Check your understanding

Halving the step size in RK4 reduces the global error by roughly a factor of:

← Previous lesson Next lesson →