THIS EXPLANATION
THE ROOM
MAT·01 Mathematics & Statistics 6 MIN · 8 STATIONS

Adaptive step size

A Socratic walk-through of adaptive step size — reasoned out one step at a time, not lectured.

abcdefgh
a

The question we started with

THE QUESTION #

Why does a solver that keeps changing its own step size beat one with a well-chosen fixed step?

You are integrating a differential equation forward in time. You could pick one step size and march. Or you could use a solver that recomputes its step at every single step, spends effort estimating its own error, and sometimes throws a completed step away and redoes it smaller.

The second sounds like pure overhead. It does extra arithmetic per step and occasionally wastes a whole step. Yet essentially every production solver — Dormand and Prince's method, the Fehlberg pair, the routines behind ode45 and solve_ivp — works that way, and they beat carefully tuned fixed-step runs on most problems. What does the adaptation buy that pays for all that?

b

Reasoning it through

REASONING #

Ask first how a fixed step gets chosen. You need the answer accurate everywhere, so you must pick a step small enough for the hardest part of the trajectory — the sharp turn, the near-collision, the moment a fast transient fires.

Now ask what that step does everywhere else. On a long smooth stretch, where the solution is nearly a straight line, the same tiny step is still being taken — thousands of them, each costing the same arithmetic, each contributing almost nothing. The total work is set by the worst point multiplied by the whole interval, even though the worst point may occupy a thousandth of it.

So the fixed-step solver is not paying for accuracy. It is paying for accuracy it does not need, over most of the domain. That already tells us where the win must come from: not from being cleverer at any one step, but from spending effort in proportion to how hard each region actually is.

But that raises the real difficulty. You cannot know in advance which regions are hard — if you knew the solution's behaviour, you would not be solving for it. So the solver must find out as it goes. How could it possibly judge a step it has just taken, with no exact answer to compare against?

The standard answer is to compute the same step twice at different accuracies and compare. An embedded Runge-Kutta pair does this economically: from one set of function evaluations it forms two estimates of the new point, one of order p and one of order p+1. The difference between them is not the true error, but it is a usable estimate of the local error committed on that step — the error introduced by this step alone, assuming you started it from an exact value.

Now the control law. For a method of order p, the local error on a step of size h scales roughly as h<sup>p+1</sup>. So if the estimate came back as err and you wanted tol, the step that would have hit the target is about h times (tol/err) raised to the power 1/(p+1), multiplied by a safety factor — around 0.9 is conventional — and clamped so the step cannot leap or collapse by more than a set ratio in one go.

That single formula does both jobs, and this is the point worth pausing on. If the estimate is comfortably under tolerance, the same expression tells the solver to grow; if it is over, the step is rejected, the formula supplies a smaller one, and the step is retried. Growth and retreat are not two mechanisms but one, driven by the measurement.

Which is why the retried steps are not the waste they look like. A rejection is how the solver discovers a feature it had no way to anticipate — and having discovered it, it shrinks only there, then expands again on the other side. The total work ends up proportional to how much resolution the trajectory genuinely demanded, not to its worst moment stretched across the whole interval. On a problem with one sharp event in a long quiet run, that is a difference of orders of magnitude.

Two honest limits. First, controlling local error does not control global error — the accumulated deviation from the true trajectory. Local control is a proxy, usually a good one, but on chaotic or long-horizon problems the global error can be far larger than the tolerance suggests. Second, for stiff problems an explicit method's step is limited by stability, not accuracy: push it up and the solution blows up rather than merely drifting. The controller then thrashes at a tiny step for reasons no tolerance setting will fix, and the correct response is an implicit method, not a better controller.

c

The analogy

THE ANALOGY #
THE FIGURE

Think of driving an unfamiliar mountain road at night. One driver picks a single speed at the start, slow enough for the tightest hairpin on the route, and holds it for three hours. The other drives by what the road is doing: fast on the straights, easing off as the camber changes, braking hard when a corner turns out sharper than expected. The second arrives sooner and no less safely, because the caution was spent where the road demanded it.

WHERE IT BREAKS DOWN

the driver has headlights and can see the corner coming, whereas the solver has none — it judges only the step it has already taken, so it learns about the hairpin by taking it badly and reversing back to try again, and that backwards-looking correction is why rejected steps are unavoidable rather than a sign of a poor controller.

d

Clarifying the model

THE MODEL #

The natural misreading is that adaptive solvers are more accurate. Usually they are not aiming to be: given the same tolerance, they aim for the same accuracy at far lower cost. The gain is efficiency, and the accuracy is what you asked for.

It is also worth being precise about the tolerance. It is a per-step budget on the local error estimate, not a promise about the final answer: two solvers at the same tolerance can deliver visibly different global accuracy.

Finally, notice the shape of the argument, because it is not really about differential equations. A fixed parameter must be sized for the worst case and therefore wastes effort in the average case; a measurement of local difficulty converts that fixed cost into a variable one. The same reasoning drives variable bit-rate encoding and congestion windows that grow until loss appears — and it fails the same way in all of them, when the measurement stops being a faithful signal of what is being controlled.

e

A picture of it

THE PICTURE #
Adaptive step size
Adaptive step size the bars are the step size the controller chooses; the line is how fast the solution is changing there. Read them against each other -- where the line rises the bars fall, and where it settles they grow again. That mirroring is the adaptation. The numbers are schematic, not a measured run. {"generator":"[email protected]","source":"../Socrates/.diagram-cache/_src/adaptive-step-size.md","sourceIndex":1,"sourceLine":4,"sourceHash":"5e00156d6e459153d2ee935c8b149b0edf9896bdbfe75fc141279bb1489150bb","diagramType":"xychart","layoutVariant":"source","repairedDuplicateIds":[],"motion":"entrance-with-reduced-motion-fallback","presentation":"editorial","attempt":1,"viewBox":{"x":0,"y":0,"width":790,"height":636},"qa":{"passed":true,"findings":[]}} Smooth Approach Sharp Settling 10 9 8 7 6 5 4 3 2 1 0 Relative size

How to readthe bars are the step size the controller chooses; the line is how fast the solution is changing there. Read them against each other — where the line rises the bars fall, and where it settles they grow again. That mirroring is the adaptation. The numbers are schematic, not a measured run.

f

What became clearer

WHAT CLEARED #
WHAT CLEARED

A fixed step must be sized for the hardest moment of the whole trajectory, so it overpays everywhere else. An adaptive solver replaces that guess with a measurement — an error estimate obtained almost free from an embedded pair — and lets one formula both shrink the step where the problem is hard and grow it where it is not. The extra arithmetic per step is trivially repaid by the steps it no longer has to take.

g

Where to go next

ONWARD #
  • Embedded Runge-Kutta pairs: how one set of evaluations yields two orders of accuracy.
  • PI and PID step-size controllers, which smooth the sequence of steps rather than reacting to one estimate.
  • Stiff equations, and why implicit methods change the whole calculation.
  • Dense output: getting values between the steps an adaptive solver actually took.
h

Key terms

TERMS #
TermWhat it means
Local errorthe error introduced by a single step, assuming its starting value was exact.
Global errorthe accumulated deviation from the true solution, which local control only bounds indirectly.
Embedded Runge-Kutta pairtwo methods of adjacent order sharing function evaluations, so their difference estimates the local error at almost no extra cost.
Step rejectiondiscarding a completed step whose error estimate exceeded tolerance, and retrying it smaller.
Stiffnessthe property that stability, not accuracy, limits the step size of an explicit method.

Every term the collection defines is gathered in the glossary.

Nearby on the shelf

4