Numerical Methods for ODEs

adaptive step-size control

A fixed step size is a blunt compromise. Where the solution is barely changing you waste effort taking needlessly small steps; where it suddenly curves sharply your steps are too big and the error spikes. The sensible thing is to let the step breathe — small and careful through difficult, rapidly-changing stretches, large and economical across calm, smooth ones. Adaptive step-size control does exactly this automatically, adjusting h on the fly to keep the error within a tolerance you set.

Precisely, at each step the solver estimates the local error it just made (typically by comparing two methods of different order on the same step, as embedded Runge-Kutta pairs do, or by comparing a step with two half-steps). If the estimated error exceeds your tolerance, the step is rejected and retried with a smaller h. If the error is comfortably below tolerance, the step is accepted and h is grown for next time. The new step size is chosen by a formula based on how the error scales with h — for an order-p estimate, h_new is roughly h * (tolerance / estimated_error)^(1/(p+1)) — so the solver homes in on the largest step that still meets your accuracy target.

This is what every modern ODE solver does, and it is why you can hand a solver a hard problem and a tolerance and simply trust it. You control accuracy directly (you ask for an error level, not a step size), and the solver spends effort only where the problem demands it — which can be orders of magnitude faster than a fixed step fine enough for the worst spot. The honest caveat: the error ESTIMATE is itself approximate, the tolerance controls local not global error, and an extremely tight tolerance eventually runs into the round-off floor where smaller steps no longer help.

RKF45 takes a step, computes both a 4th- and a 5th-order estimate, and uses their difference as the local error. If that exceeds tolerance the step is redone smaller; if it is tiny, the next step grows. On a problem that is flat then suddenly spikes, the solver glides with big steps over the flat part and shrinks h automatically at the spike.

Estimate the error each step, then grow or shrink h to hit your tolerance.

The tolerance controls the LOCAL error per step, not the global error of the final answer — accumulated error can still exceed your tolerance. And the error estimate is itself approximate, so adaptivity is a sensible heuristic, not a guarantee.

Also called
variable step sizestep-size adaptation可變步長步長自動調節