On this page
You have y′ = f(t, y), a starting value, and no formula for y. Euler's method follows the tangent line and drifts off the true curve. The classical Runge–Kutta method, RK4, measures the slope four times inside each step and takes a weighted average.
What is the Runge–Kutta method RK4?
The Runge–Kutta methods were developed around 1900 by the German mathematicians Carl Runge and Wilhelm Kutta (Runge–Kutta methods, Wikipedia). The classical fourth-order member, RK4, takes a step of size h from (tₙ, yₙ) using four slopes:
k1 = f(tₙ, yₙ), the slope at the start of the step
k2 = f(tₙ + h/2, yₙ + h·k1/2), the slope at the midpoint, reached by following k1 for half a step
k3 = f(tₙ + h/2, yₙ + h·k2/2), the midpoint slope again, reached by following k2 for half a step
k4 = f(tₙ + h, yₙ + h·k3), the slope at the end of the step, reached by following k3 for a full step
The new value is yₙ₊₁ = yₙ + (h/6)(k1 + 2k2 + 2k3 + k4), and tₙ₊₁ = tₙ + h. Each slope is a trial run that feeds the next.
Why are the RK4 slopes weighted 1, 2, 2, 1?
The cleanest answer comes from integration. If f does not depend on y, the equation is just an integral, and in that case RK4 is Simpson's rule (Runge–Kutta methods, Wikipedia). Simpson's rule approximates the integral from a to b as (b − a)/6 times [f(a) + 4f(midpoint) + f(b)] (Simpson's rule, Wikipedia).
So the start gets weight 1, the end gets weight 1, and the midpoint gets weight 4. RK4 has two midpoint slopes, k2 and k3, so it splits that 4 into 2 + 2. The weights add to 6, so dividing by 6 gives an average slope, and h times that slope is the rise over one step. Our trapezoidal rule and Simpson's rule worked example shows the 1, 4, 1 pattern on a plain integral.
Worked example: one RK4 step for y′ = y
Take y′ = y with y(0) = 1, so f(t, y) = y and the exact answer is y = eᵗ. Use h = 0.1, so h/2 = 0.05.
k1 = f(0, 1) = 1
k2 = 1 + 0.05 × 1 = 1.05
k3 = 1 + 0.05 × 1.05 = 1.0525
k4 = 1 + 0.1 × 1.0525 = 1.10525
Weighted sum: 1 + 2(1.05) + 2(1.0525) + 1.10525 = 6.31025
y(0.1) ≈ 1 + (0.1/6) × 6.31025 = 1.10517083
The exact value is e^0.1 = 1.10517092, so RK4 is off by about 0.000000085 after one step. Euler's method gives 1 + 0.1 × 1 = 1.1, which is off by about 0.0052. For this equation the RK4 step reproduces the Taylor series of e^h up to the h⁴/24 term, which is why it lands so close.
To practise the exact methods first, try these differential equations JEE Main numerical value questions.
How accurate is RK4 compared with Euler's method?
Euler's method is first order: its error per step is proportional to h², and its global error at a fixed time is proportional to h (Euler method, Wikipedia). RK4 is fourth order: its local truncation error is of order h⁵ and its total accumulated error is of order h⁴ (Runge–Kutta methods, Wikipedia).
So once h is small enough, halving h roughly halves Euler's error but cuts RK4's error by about 2⁴ = 16. Carry y′ = y from t = 0 to t = 1 and compare with e:
Euler, h = 0.1 (10 steps): about 2.5937, error about 0.125
Euler, h = 0.05 (20 steps): about 2.6533, error about 0.065
RK4, h = 0.1 (10 steps): error about 0.0000021
RK4, h = 0.05 (20 steps): error about 0.00000014
RK4 costs four evaluations of f per step instead of one, a small price for that gain.
When should you choose a smaller step size?
The order tells you how error scales, not how big it is. Use this checklist:
Run twice, with h and h/2. If the answers agree to the digits you need, keep the larger h.
To test the h⁴ behaviour, run a third time with h/4. If the change from h/2 to h/4 is about 1/16 of the change from h to h/2, the h⁴ behaviour has set in; if not, h is still too large.
Shrink h where the solution rises steeply or bends sharply, because one averaged slope cannot follow a big change within a step.
Shrink h for long intervals, since error builds up over every step.
Halving is also the core move of the bisection method for finding a root.
If local versus global error still feels shaky, the Fermi Concept Library has a lesson for every concept in mathematics. To check your own RK4 steps, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer.
Next, redo the worked example with h = 0.2 and see how much the error grows.



