advanced34 min studyLesson 328 in Mathematics

Dense output and event location

Construct continuous numerical output, locate transverse event roots, and separate interpolation error from root-solver accuracy.

On this page

What you’ll understand

  • Distinguish requested output times from accepted integration steps.
  • Translate state-interpolation error into event-time sensitivity for a transverse crossing.
  • Identify sign-change detection failures and the need to restart after a state reset.

A solver's accepted time steps rarely coincide with every time at which a plot, measurement, or control action is needed. Dense output supplies a continuous approximation inside those steps. Event location then solves a scalar root problem along that approximation. These two tasks introduce distinct errors: an accurate root of an inaccurate interpolant can still predict the wrong physical event time. Reliable event handling checks the interpolation, crossing geometry, and the behavior of the model after the event.

A continuous extension needs its own accuracy

A dense-output formula usually combines stage information into a polynomial or another continuous extension over one accepted step. Its degree and accuracy are method-specific and need not equal the endpoint order. Merely joining accepted endpoints with straight lines can lose substantial information: even exact endpoint values do not determine the curve between them. For the exact solution y=t squared on the unit interval, the line through its endpoints gives one half at the midpoint instead of one quarter.

Requested output times describe where values should be returned, not necessarily the internal step schedule. A solver can take a longer accepted step and evaluate its dense extension at several requested times inside it. Increasing the number of saved points therefore need not improve the underlying integration. To improve accuracy, control the integration and interpolation tolerances or the maximum step, then verify the quantity of interest. A smooth-looking densely sampled plot is not by itself evidence that small-scale dynamics were resolved.

y~(tn+θh)=Yn+h∑ibi(θ)ki,0≤θ≤1\widetilde y(t_n+\theta h)=Y_n+h\sum_i b_i(\theta)k_i,\qquad0\le\theta\le1
This illustrates a Runge–Kutta continuous extension. Its coefficient functions and error order must be designed and analyzed, rather than inferred from how densely the plot is sampled.↔ Scroll wide equations horizontally.

Transversality controls event-time sensitivity

Let an event be a zero of g(t,y(t))g(t,y(t)). At a simple crossing, the derivative along the solution is gt+gyfg_t+g_y f and is nonzero. A small perturbation in the event function then shifts the root by approximately the perturbation divided by this crossing speed. A nearly tangent crossing is poorly conditioned: a small state error may produce a large time error or eliminate the crossing. A tight scalar root tolerance cannot fix that sensitivity.

Separate the error in the dense state from the residual left by the scalar root finder. If the true event function is monotone with derivative magnitude at least gamma on an interval containing both roots, a uniform event-function approximation error epsilon bounds the root shift by epsilon divided by gamma, with a scalar root residual added to epsilon when needed. This argument requires a nearby isolated root and the derivative bound; it does not apply unchanged to multiple roots or arbitrary discontinuous event functions.

ddtg(t,y(t))=gt+gyf,∣t^−t∗∣≤ε+εrootγ\frac{d}{dt}g(t,y(t))=g_t+g_yf,\qquad |\widehat t-t_*|\le\frac{\varepsilon+\varepsilon_{\mathrm{root}}}{\gamma}
The bound assumes a nonvanishing true crossing derivative of magnitude at least γ between the true and computed event times, event-function approximation error at most ε, and approximate-root residual at most εroot.↔ Scroll wide equations horizontally.

Detecting a bracket is not detecting every event

Many solvers detect a candidate event by a sign change across an accepted step, then refine its time using dense output. Two crossings within one step can leave equal signs at the endpoints and be missed. A tangential root can touch zero without changing sign at all. A direction filter selects upward or downward crossings once found; it does not prove that no unobserved crossing occurred. Known bounds on event frequency or a suitable maximum step can help, but the model must supply that information.

An event that changes the state or the differential equation creates a new initial-value problem. Locate the event, apply the specified jump or mode switch, and restart with consistent state and fresh solver history. Continuing an old smooth interpolant through a discontinuous reset gives a curve for the wrong dynamics. Likewise a zero at the initial time may require a convention to avoid repeatedly rediscovering the same event. Event semantics belong to the modeled system as well as to the root-finding algorithm.

g(t)=(t−0.4)2≥0,g(0)>0,g(1)>0,g(0.4)=0g(t)=(t-0.4)^2\ge0,\qquad g(0)>0,\quad g(1)>0,\quad g(0.4)=0
A tangential event can occur without any endpoint sign change, even if the trajectory and event function are evaluated exactly.↔ Scroll wide equations horizontally.

A root accurate for the wrong curve

Suppose y′=2t, y(0)=0, has exact accepted endpoints at times zero and one. Locate the event y=0.25 using a linear endpoint interpolant and then using the exact quadratic extension.

  1. The true solution is y=t². Its exact endpoint values are zero and one, so the straight-line interpolant through them is P(t)=t.

  2. Solving P(t)=0.25 gives a computed event time 0.25, and the scalar root can be found with zero algebraic residual on this line.

  3. The correct quadratic extension gives t²=0.25 and the event at t=0.5. Thus the event-time error is 0.25 despite exact endpoints and an exactly solved interpolant root.

tlinear=0.25,ttrue=0.25=0.5t_{\mathrm{linear}}=0.25,\qquad t_{\mathrm{true}}=\sqrt{0.25}=0.5
The discrepancy is interpolation error, so tightening the scalar root tolerance on P(t) cannot remove it.↔ Scroll wide equations horizontally.
The result

Endpoint accuracy and root-solver accuracy do not guarantee accurate event timing unless the continuous extension is accurate between endpoints.

Explore the model

Interactive lab

Interactive lab · root-finding

An event bracket with a known curve

Pause and Reset, then set c=2 and U=2. Interpret the scalar root as the zero of the known event curve t²−2. Predict the bracket and midpoint after three bisections, and Step three times. Compare the reported bound with the distance from 1.375 to √2.

An event bracket with a known curveBisection 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 forThe midpoint is 1.375 with bracket bound 0.125. This exact-curve root exercise isolates scalar localization; it does not assess dense-output error or detect hidden ODE events.

Check your understanding

Why may saving a solution at a thousand requested output times fail to reveal two missed event crossings inside one accepted step?

Try it yourself

For y=t² and the event y=0.25, a dense approximation has state error at most 0.001 on [0.4,0.6]. A root of its event function is found in that interval with zero root residual. Bound its time error using the true derivative on this interval.

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 true event derivative is 2t. Use its minimum on the interval containing both the exact and approximate roots.

Compare with the solution

The true derivative is at least 0.8 throughout [0.4,0.6]. Since the event subtracts only the constant 0.25, its approximation error is at most the same 0.001. The true root is 0.5 and the computed root is assumed in the interval, so the mean-value bound gives time error at most 0.001/0.8=0.00125. A nonzero scalar root residual would be added to the numerator.

Take it with you

  • Dense output has its own approximation order and cannot be judged from endpoint values alone.
  • A transverse crossing converts event-function error into time error through its crossing speed.
  • Sign-change detectors can miss tangencies and multiple crossings, and state resets require a restart.

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.