Runge-Kutta methods achieve higher order accuracy by evaluating at multiple points within each step—no derivatives of required. Embedded pairs compute two approximations of different orders using (nearly) the same work, enabling automatic error estimation. This powers adaptive time-stepping: adjust to maintain accuracy while minimizing computational cost.
Beyond Euler: The Need for Higher Order¶
Euler’s method has local truncation error —first order. To achieve 10-6 accuracy might require millions of steps.
The challenge: Higher-order Taylor methods require derivatives of :
Computing , , , etc. is tedious and error-prone.
The Runge-Kutta idea: Evaluate at cleverly chosen intermediate points and combine to cancel error terms—no derivatives needed.
Second-Order Runge-Kutta (RK2)¶
The Method¶
Given the initial value problem , we proceed in two stages:
Here are fractional values to be determined. The update is:
When and , this reduces to forward Euler. Our goal is to find that give second-order accuracy.
Derivation: Matching Taylor Series¶
Goal: Choose parameters so the local truncation error is instead of .
Step 1: Taylor expand the exact solution.
Using and the chain rule :
Step 2: Taylor expand .
Since :
Step 3: Expand the numerical method.
Substituting into the update formula:
Step 4: Match coefficients.
Equating terms of equal order in on both sides:
| Order | Exact solution | Numerical method | Condition |
|---|---|---|---|
| , term | |||
| , term |
Three equations, four unknowns — a one-parameter family of solutions!
Common RK2 Methods¶
Definition 1 (RK2 Midpoint Method)
With , , and :
Interpretation: Take half an Euler step, evaluate the slope there, use that slope for the full step.

Midpoint method () solving with . Step 1: Compute slope at the current point. Step 2: Euler step with step-size . Step 3: Compute slope at the intermediate point. Step 4: Full step uses slope . The diamond shows Euler’s result for comparison.
Definition 2 (Heun’s Method (Averaging))

Heun’s method () solving with . Step 1: Compute slope at initial point. Step 2: Full Euler step. Step 3: Compute slope at the new point. Step 4: Final step uses the average of the two slopes. The diamond shows Euler’s result for comparison.
Both methods have local truncation error , i.e. second order.
Embedded Pairs and Error Estimation¶
Fixed step sizes are inefficient: too small wastes work, too large loses accuracy. To adapt locally, we need an estimate of the local truncation error at each step. But depends on the unknown exact solution, so we cannot compute it directly. The key idea is to obtain a cheap error estimate by comparing two methods of different order.
The Embedded Pair Idea¶
Compute two approximations of different orders using the same evaluations:
Higher-order method (order ) gives
Lower-order method (order ) gives
The difference estimates the local error of the lower-order method:
RK12: Euler-Midpoint Pair¶
Embed Euler (order 1) with RK2 midpoint (order 2):
Definition 3 (RK12 Embedded Pair)
Error estimate:
Cost: 2 function evaluations per step (same as plain RK2), plus we get an error estimate!
Why This Works¶
The difference between the methods is approximately:
This is (up to sign) the leading error term in Euler’s method.
Adaptive Time-Stepping¶
With an error estimate, we can adjust automatically.
Algorithm 1 (Adaptive Step-Size Control)
Input: Tolerance parameters atol, rtol; current step size ; current state
Output: New state and updated step size
Compute the step using RK12:
(Euler)
(Midpoint)
Estimate scaled error:
Accept or reject:
If : accept step, set
If : reject step, keep
Update step size:
where (safety factor), , .
Repeat from step 1 (with rejected step) or continue to next time step (if accepted).
Generalizations to Higher Order Methods¶
The RK2 derivation extends to higher orders:
Remark 1 (Higher-Order Runge-Kutta Methods)
RK4 (Classical 4th-order): Uses 4 stages, local error . The most popular “hand-coded” method.
RK45 (Dormand-Prince): A 5th-order method with embedded 4th-order for error estimation. Used in scipy.integrate.solve_ivp with method='RK45'.
The derivation follows the same pattern: Taylor expand, match coefficients. But the algebra becomes increasingly complex; these methods are derived once and tabulated.