All courses › Numerical Methods › Runge–Kutta (RK4)

Runge–Kutta (RK4)

The classic Runge–Kutta method (RK4) is a fourth-order method that uses four function evaluations per step to estimate the slope more accurately than Euler. Global error is O(h4)O(h^4), so a small reduction in hh gives a large gain in accuracy.

yn+1=yn+h6(k1+2k2+2k3+k4)y_{n+1} = y_n + \tfrac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)the RK4 update

Symbols

k1,…,k4k_1,\ldots,k_4four slopes evaluated at different points within the step

Example

Dividing the step size by 10 in an order-2 method (Heun) makes the error roughly 102=10010^2 = 100 times smaller; for RK4 it becomes 10410^4 times smaller.

RK4 is more expensive per step than Euler (four evaluations versus one), but it almost always pays off in accuracy.
Practise differential equations and stability for free →

← Euler's method · Stiffness and stability →

Part of Numerical Methods: Differential equations and stability.