advanced34 min studyLesson 326 in Mathematics

Embedded pairs and adaptive stepping

Build a scaled local-error controller from shared Runge–Kutta stages and interpret what an embedded difference estimates.

On this page

What you’ll understand

  • Interpret a shared-stage difference as a local estimate with a specified asymptotic power.
  • Scale component errors using meaningful absolute and relative tolerances.
  • Explain acceptance, rejection, and limitations of a step controller.

A fixed small step wastes work where a trajectory is smooth and may still miss a sharp transition elsewhere. Embedded Runge–Kutta pairs estimate local error using two combinations of the same stage evaluations. A controller uses their disagreement to choose the next step. This is an efficient feedback mechanism, but the estimate is neither an exact error nor a global accuracy certificate. Its scaling, asymptotic power, acceptance rule, and failure behavior all need a clear interpretation.

Two weights, shared stages, different local defects

An embedded pair computes two endpoint approximations from one collection of stage derivatives. If the lower formula has order p minus one and the higher has order p, their exact-start defects typically begin at powers h to the p and h to the p plus one. Their difference is therefore dominated by the lower formula's defect, provided its leading coefficient does not vanish on the current problem. Propagating the higher result does not change which defect dominates that difference.

This distinction prevents an incorrect controller exponent. A difference behaving like h squared calls for a square-root step adjustment, even if the accepted endpoint uses a second-order formula with a cubic local defect. Some solvers use special estimators with different powers, so the exponent should come from the actual estimator rather than the displayed method name. Accidental cancellation, nonsmooth forcing, and unresolved fast scales can make the asymptotic model unreliable on a particular attempted step.

Δ=h∑i(bi−b^i)ki,Δ=O(hq)\Delta=h\sum_i(b_i-\widehat b_i)k_i,\qquad\Delta=O(h^q)
The power q describes this estimator's leading behavior. For a generic order-p versus order-(p−1) pair, q=p, even when the higher-order endpoint is propagated.↔ Scroll wide equations horizontally.

A tolerance must respect units and component scales

A raw error norm can be meaningless when the state mixes quantities with very different units and magnitudes. Give each component an absolute tolerance with its physical units, plus a dimensionless relative tolerance. For this lesson's illustrative controller, scale by the absolute tolerance plus the relative tolerance times the larger old or proposed component magnitude. Dividing the estimated error by that scale produces a dimensionless number. Real libraries may choose a different comparable scaling convention or a weighted root-mean-square norm.

Absolute tolerance is essential near zero, where a purely relative test would demand unrealistic precision or divide by zero. Conversely an absolute tolerance larger than the variation of a small but important component can allow that component to be poorly resolved. Choose scales from the scientific question rather than from whatever values happen to appear in the first run. An acceptance test bounds a normalized estimate, not every true component error or every accumulated error in a derived observable.

si=atoli+rtolmax⁡(∣Yn,i∣,∣Yn+1,i∗∣),E=max⁡i∣Δi∣sis_i=\mathrm{atol}_i+\mathrm{rtol}\max(|Y_{n,i}|,|Y^*_{n+1,i}|),\qquad E=\max_i\frac{|\Delta_i|}{s_i}
This example uses a maximum norm and a stated scale. An attempted step passes the illustrative local test when E≤1, with strictly positive component scales.↔ Scroll wide equations horizontally.

The controller is part of the algorithm

Assuming the error scale changes slowly and the estimate follows a power law, multiply the step by the inverse qth power of the normalized error. A safety factor below one makes the proposal conservative, and growth or shrinkage limits prevent extreme jumps. A failed step is rejected: retain the previous accepted state and retry with a shorter step. Accepting the inaccurate trial and merely choosing a shorter next step would leave the already introduced error in the trajectory.

At zero estimated error a controller uses a capped growth rule rather than dividing by zero. Repeated rejections can indicate stiffness, bad scaling, a discontinuity, or a failing nonlinear solve rather than a need for indefinitely smaller steps. Practical controllers also smooth successive estimates to reduce oscillation in step size. Final-time clipping, minimum representable increments, and event handling impose further constraints. These implementation details explain why an adaptive solver is more than a pair of coefficient vectors.

hnew=ηhE−1/q(E>0, 0<η<1)h_{\mathrm{new}}=\eta h E^{-1/q}\qquad(E>0,\ 0<\eta<1)
The formula is a local asymptotic proposal before applying step-ratio limits and problem boundaries. It is not a proof of global error control.↔ Scroll wide equations horizontally.

Euler–Heun disagreement on a decay step

Use the Euler–Heun pair on y′=−2y from y=1 with h=0.1. Take an absolute scale 0.01 and no relative term. Compute E and an uncapped new-step proposal with safety 0.9.

  1. The Euler predictor is 1−0.2=0.8. Its endpoint slope is −1.6, while the initial slope is −2. Heun therefore gives 1+0.05(−2−1.6)=0.82.

  2. The embedded difference has magnitude 0.02, so E=0.02/0.01=2 and this attempted step fails the example's test. The difference has leading power q=2.

  3. The controller proposes 0.9·0.1/√2≈0.0636396. For comparison a retried step h=0.05 gives Euler 0.9 and Heun 0.905, difference 0.005, so E=0.5 and that trial passes.

E=2,hnew=0.09 2−1/2≈0.0636396E=2,\qquad h_{\mathrm{new}}=0.09\,2^{-1/2}\approx0.0636396
The square-root exponent follows from the order-h² Euler–Heun difference, despite propagating Heun's second-order endpoint when a step passes.↔ Scroll wide equations horizontally.
The result

Reject the h=0.1 trial and retry from the accepted starting state. The difference estimates the lower-order defect; it is not the exact Heun error.

Explore the model

Interactive lab

Interactive lab · optimization

A step-size change changes the discrete map

Pause and Reset, then set η=0.2 and x₀=1. Predict the first Euler-equivalent update for y′=−y and Step once. For a fresh comparison, Reset and set η=0.1 and x₀=1, then Step once. Compare each value with the exact decay at its own interpreted time η.

A step-size change changes the discrete mapGradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Current readings: Position x0: 2; Objective x²/2: 2; Iteration behavior: Stable step. All parameters are adjustable with the labeled controls below.−4−202402.174.356.528.7Parameter xf(x) = x²/2n = 0
ObjectiveDiscrete iterate
Position x0
2
Objective x²/2
2
Iteration behavior
Stable step
n = 0 · t = 0 s

Gradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forThe values are 0.8 and 0.9, compared with exp(−0.2) and exp(−0.1). The smaller step reduces this exact-start defect, but the lab does not compute an embedded pair or choose steps automatically.

Check your understanding

An embedded difference behaves as C h³ while the accepted higher-order endpoint has local defect O(h⁴). Which exponent belongs in a simple estimator-based controller?

Try it yourself

A controller has h=0.12, E=4, estimator power q=2, and safety η=0.9, with no active caps. Find its proposed retry step. Should the rejected endpoint be used as the next starting value?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Take the square root of E, and distinguish an attempted trial from an accepted state.

Compare with the solution

The proposal is 0.9·0.12/√4=0.054. Since E=4 exceeds one, discard the failed endpoint and retry a step of the proposed size from the last accepted state. Starting from the rejected value would retain the very error the rejection was intended to prevent. The predicted reduction is asymptotic; the retry still needs a fresh estimate and acceptance test.

Take it with you

  • An embedded difference generally estimates the lower-order local defect.
  • Tolerance scaling must reflect units, near-zero behavior, and important small components.
  • Rejected trials are retried from the last accepted state, with a newly checked estimate.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.