Dense output and event location
Construct continuous numerical output, locate transverse event roots, and separate interpolation error from root-solver accuracy.
On this page
The question for today
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.
Transversality controls event-time sensitivity
Let an event be a zero of . At a simple crossing, the derivative along the solution is 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.
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.
Work it through
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.
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.
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.
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.
Endpoint accuracy and root-solver accuracy do not guarantee accurate event timing unless the continuous extension is accurate between endpoints.
The living notebook
Explore the model
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.
- Midpoint after 0 refinements
- 1.5
- Bracket error bound
- 1.5
- Computed residual · x² − c
- 0.25
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.
Pause & reason
Check your understanding
Your turn
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.
Keep the idea
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.