y′ = y, y(0) = 1, h = 0.1
y₁ = 1.105171
Matches e^0.1.
The classical Runge–Kutta method (RK4) advances by where , , , .
This page is easier if you are comfortable with:
For , , : , , , , so against : error of order in a single step, versus for Euler's method (Euler's method). For : , , , , vs the exact . For , : , matching the exact solution .
The weights are those of Simpson's rule (Simpson's rule error) applied to the slope at the start, midpoint (twice) and end. The local error is of order and the global error of order : halving cuts the error by about 16. It needs four function evaluations per step.
RK4 is the default general-purpose solver for non-stiff problems, improving the midpoint method (the midpoint method) and Euler (stability of Euler's method). The solutions it approximates are those of separable and linear equations, and systems are treated in coupled first-order systems.
RK4 takes four slope samples per step and averages them to follow the solution very accurately.
After one step RK4 agrees with e^0.1 to seven digits.
These examples are worked by hand, step by step, so you can compare your own working.
Find one RK4 step with from .
Find one RK4 step with from .
Find one RK4 step with from .
A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.
y₁ = 1.105171
Matches e^0.1.
k₁ = 1, k₂ = 1.05, k₃ = 1.0525, k₄ = 1.10525
k₂, k₃ at the midpoint.
e^0.1 = 1.105171
Error ~ 8 × 10⁻⁸.
1 + 0.1 = 1.1
Error 0.005.
The classical fourth-order Runge–Kutta method: yₙ₊₁ = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄), with k₁ = f(xₙ, yₙ), k₂ = f(xₙ + h/2, yₙ + hk₁/2), k₃ = f(xₙ + h/2, yₙ + hk₂/2), k₄ = f(xₙ + h, yₙ + hk₃).
For y′ = y, y(0) = 1, h = 0.1 find k₁, k₂, k₃, k₄.
Find y₁.
Compare with e^0.1.
Find the Euler error for the same step.
(k₁ + k₂ + k₃ + k₄)/4 ✗
(k₁ + 2k₂ + 2k₃ + k₄)/6 ✓
Midpoint slopes count double.
k₃ from yₙ + hk₁/2 ✗
from yₙ + hk₂/2 ✓
Use the latest slope.
adding weighted slopes only ✗
multiply by h/6 ✓
Scale by the step.
like Euler ✗
O(h⁴) ✓
Fourth-order accurate.
Try each one on paper, then open the answer. Use the solver above to see the full working.
1.05
1.0525
1.10525
1.051708
1.221403
1.2
Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.
Solve: …
A fourth-order Runge–Kutta method using four slopes per step.
1, 2, 2, 1 over 6.
Global error O(h⁴).
Much smaller error for the same h.
Euler method stability.
More in Numerical methods and optimisation and the formula sheets.