Runge-Kutta-Fehlberg Method — Definition, Formula & Example
The Runge-Kutta-Fehlberg method (RKF45) is a Runge-Kutta solver for differential equations that sets its own step size. On each step it builds a fourth-order and a fifth-order estimate from the same six slope evaluations. It treats their difference as an error estimate and grows or shrinks the step to keep that error below a tolerance.
RKF45 is a six-stage explicit embedded Runge-Kutta pair of orders 4 and 5, published by Erwin Fehlberg in 1969. For the initial value problem , it computes stages at nodes with . Two weight vectors then produce (order 4) and (order 5). The local error estimate is . You accept the step if , and you set the next step size from the ratio .
Key Formula
Where:
- = Current approximation of the solution at time
- = Current step size
- = Slope evaluations of at the nodes . Both formulas share these six values.
- = Fourth-order estimate. Fehlberg's original method advances with this one.
- = Fifth-order estimate. Many codes advance with this more accurate value instead.
- = Estimated local error, used to accept or reject the step and to choose the next h
Worked Example
Problem: Take one trial RKF45 step for , , with and tolerance . The exact solution is , so . Because depends only on , each stage reduces to . This lets you see clearly how the two embedded formulas differ.
Step 1: Evaluate the six stages at the nodes .
Step 2: Apply both weight sets to the same six stages. The fifth-order formula reproduces the exact value, but the fourth-order formula does not.
Step 3: Estimate the error and compare it with the tolerance. Since , reject the step. One common update rule uses a safety factor of 0.9 and the exponent .
Answer: Reject the trial step, because exceeds . Retry with . For this problem the error scales exactly as , so the new estimate is about , and the retried step passes.
Why It Matters
RKF45 is the standard first example of adaptive step-size control in numerical analysis courses, for instance in Burden and Faires. It also appears in classic library routines, such as the Shampine–Watts RKF45 code. Adaptive solvers like this take small steps where the solution changes rapidly and large steps where it is smooth, which is essential when you simulate orbits, chemical reactions, or circuits.
Common Mistakes
Mistake: Running a separate RK4 step and a separate RK5 step to get the two estimates.
Correction: The two estimates in RKF45 come from one shared set of six stages. Only the final weights differ. This sharing is the reason the error estimate costs almost nothing extra.
