advanced32 min studyLesson 923 in Physics

Adaptive time stepping and event detection

Control a local error estimate while separately resolving stability and the time of physical events.

On this page

What you’ll understand

  • Estimate a step error by comparing one full step with two half steps.
  • Distinguish local state error from global trajectory error.
  • Explain how event interpolation and missed sign changes limit event accuracy.

A projectile approaching the ground or an orbit passing periapsis may require much finer time resolution than its quiet portions. Adaptive stepping uses estimated local error to allocate that effort. Event detection adds a second numerical task: locating a zero of a function evaluated along the computed trajectory. A highly accurate root finder does not automatically give an accurate impact time if the trajectory between accepted steps is wrong. Both tasks also remain subject to stability restrictions and to the reliability of their error estimators.

Compare approximations over the same interval

Let a method of global order p start from the exact same state and advance through an interval h. One coarse step and two half steps share the leading solution but have different leading errors. Under a smooth asymptotic error expansion, their difference divided by two to power p minus one estimates the error remaining in the finer result, up to sign convention. This is an estimate for one interval, not a certified global bound accumulated over an entire simulation.

Here local state error means the state difference after one step begun from exact input; it is typically order p plus one. Some texts divide that defect by h when defining local truncation error, giving order p instead. A step controller often proposes an increment based on the local state-error exponent and adds a safety factor and growth limits. Near discontinuities or singular behavior, the smooth error expansion can fail and an apparently small estimate may be misleading.

efine≈yh/2,h/2−yh2p−1,hnew=sh(tol∣efine∣)1/(p+1),0<s<1e_{\rm fine}\approx\frac{y_{h/2,h/2}-y_h}{2^p-1},\qquad h_{\rm new}=s h\left(\frac{\mathrm{tol}}{|e_{\rm fine}|}\right)^{1/(p+1)},\quad 0<s<1
This signed estimate approximates exact minus fine for the usual leading global-order convention over one fixed interval. The simple controller assumes a scalar absolute tolerance and a nonzero asymptotic error estimate.↔ Scroll wide equations horizontally.

Keep tolerance, stability and stiffness distinct

Practical solvers weight each component's error by an absolute tolerance plus a relative tolerance times a characteristic component magnitude. Absolute tolerances carry the component's units; positions and velocities usually need different weights. Accepting each step against that norm does not assert that the final global error equals the tolerance. Errors propagate through the differential equation, and unstable or chaotic sensitivity can amplify earlier defects even when local estimates were reasonable.

For a rapidly decaying component, an explicit integrator can be limited by stability rather than by the desired accuracy of the slow observed motion. Explicit Euler for decay at rate one thousand per second requires a step no larger than two milliseconds for the usual absolute-stability interval; the endpoint is marginal and does not reproduce physical decay. An implicit method may remove that particular stability barrier, yet still needs sufficiently small steps to resolve transients or events. Stability alone is not accuracy.

y′=−λy:yn+1=(1−λh)yn,∣1−λh∣≤1  ⟺  0≤λh≤2y^\prime=-\lambda y:\qquad y_{n+1}=(1-\lambda h)y_n,\qquad |1-\lambda h|\le1\iff0\le\lambda h\le2
λ is a positive inverse-time decay rate. This condition applies to explicit Euler on this scalar test equation, not universally to all differential equations or time integrators.↔ Scroll wide equations horizontally.

Locate zeros on a computed trajectory

An event function can represent height above ground, a separation threshold or a turning-point condition. Sign changes between accepted endpoints bracket an odd number of crossings for a continuous function, but several crossings in one step can cancel in sign. A grazing event may touch zero without changing sign at all. Event direction, maximum step, dense-output interpolation and the physical stopping rule therefore belong in the numerical specification.

Root refinement usually acts on an interpolant of the numerical trajectory. Once that root is tightly located, remaining timing error can still come from trajectory and interpolation error; a shallow event derivative makes timing especially sensitive. The root-finding lab demonstrates bracket refinement for one monotone quadratic only. It has no adaptive differential-equation trajectory, dense output or grazing-event search. A fresh Reset and both parameter settings are required because changing its controls retains the elapsed lab clock.

g(t∗)=0,δt∗≈−δg(t∗)g′(t∗)when g′(t∗)≠0g(t_*)=0,\qquad \delta t_*\approx-\frac{\delta g(t_*)}{g^\prime(t_*)}\quad\text{when }g^\prime(t_*)\ne0
The sensitivity formula is a local first-order approximation at a simple event. δg includes numerical trajectory or interpolation error and has the units of g; δt has time units.↔ Scroll wide equations horizontally.

Step doubling for a scalar decay

In dimensionless time solve y′ = −y from y0 = 1 over h = 0.20 using explicit Euler. Compare one full step and two half steps. Estimate the fine error and propose a next interval with safety factor 0.9 and local tolerance 0.0025.

  1. One full step gives 0.80. Two half steps give 0.92=0.810.9^2=0.81, so fine minus coarse is 0.01.

  2. Euler has p = 1. The signed fine error estimate is 0.01/(2 − 1) = 0.01; Richardson correction would give 0.82. The exact endpoint is about 0.818731, demonstrating that the leading estimate is approximate.

  3. Using the local exponent two gives hnew=0.9(0.20)0.0025/0.01=0.09h_{\rm new}=0.9(0.20)\sqrt{0.0025/0.01}=0.09. This proposes a future interval under the asymptotic model; it neither retrospectively accepts the failed tolerance nor guarantees a global error of 0.0025.

The result

The coarse and fine results are 0.80 and 0.81; the estimated fine correction is 0.01 and the proposed new interval is 0.09.

Explore the model

Interactive lab

Interactive lab · root-finding

Bracket accuracy is one part of event accuracy

Reset and set BOTH Target c = 1 and Initial upper bound U = 2; one Step finds the exact midpoint root 1. Reset and set c = 4 and U = 2; the exact endpoint root 2 is recognized already at time zero. This instrument bisects x² − c only, and does not integrate a trajectory, detect grazing events or quantify trajectory error.

Bracket accuracy is one part of event accuracyBisection of x² − c on [0,U], capped at 50 iterations for floating-point resolution. The error bound is the maximum distance from the displayed midpoint to either bracket endpoint (half the width in exact arithmetic). Compensated square evaluation preserves the bracket when ordinary multiplication rounds a residual to zero. A truly exact endpoint or midpoint collapses the bracket. This is one monotone quadratic, not a general root solver. Current readings: Midpoint after 0 refinements: 1.5; Bracket error bound: 1.5; Computed residual · x² − c: 0.25. All parameters are adjustable with the labeled controls below.Bisection on x squared minus 2: bracket from 0 to 3 after 0 refinements.00.751.52.253−2.360.192.745.297.84x · bracket stays nonnegativef(x) = x² − cn = 0 · [ 0, 3 ]
Quadratic / midpointCurrent bracketPositive root
Midpoint after 0 refinements
1.5
Bracket error bound
1.5
Computed residual · x² − c
0.25
t = 0 s

Bisection of x² − c on [0,U], capped at 50 iterations for floating-point resolution. The error bound is the maximum distance from the displayed midpoint to either bracket endpoint (half the width in exact arithmetic). Compensated square evaluation preserves the bracket when ordinary multiplication rounds a residual to zero. A truly exact endpoint or midpoint collapses the bracket. This is one monotone quadratic, not a general root solver. 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 forAn exact zero of the chosen interpolating function can coexist with error in the physical trajectory.

Check your understanding

Why can an event time remain inaccurate after its interpolated root has been located to many digits?

Try it yourself

A height is exactly x(t) = 1 m − (1 m/s²)t² for t ≥ 0. Samples at 0.8 s and 1.2 s are joined by a straight line. Find the linearly interpolated ground-crossing time and its error relative to the physical crossing.

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

Give me a hint

The sampled heights are 0.36 m and −0.44 m. Interpolate the zero as a fraction of the total height change over the 0.4 s interval.

Compare with the solution

The interpolated crossing is 0.8 + 0.4(0.36/0.80) = 0.98 s. The physical zero is 1 s, so the interpolation gives a time 0.02 s early. The samples in this example are exact: all the discrepancy comes from replacing the curved height by a line. Tightening a root solver applied to that line leaves the 0.98 s answer unchanged. Refining the trajectory sampling or using a justified higher-order interpolant addresses this error; asking the root finder for more digits does not.

Take it with you

  • Step controllers estimate local errors under asymptotic assumptions.
  • Stiffness can impose a stability restriction independent of tolerance goals.
  • Event timing depends on trajectory resolution and interpolation as well as root refinement.

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.