Fundamentals / Numerical mathematics / Numerical ordinary differential equations

Locating a grazing event between time steps

Derive a sensitivity formula for event time, then measure how a harmless error in a trajectory can create or remove two threshold crossings.

A time is an implicitly defined output

Suppose an integrator advances \(y'=f(t,y)\) and an event occurs at \(g(t,y(t))=0\). Along the solution the derivative of the event function is \(\dot g=g_t+\nabla_y g\cdot f\). A perturbation \(\delta g\) in the computed event function shifts a simple event time by \(\delta t\simeq-\delta g/\dot g\). This estimate separates trajectory accuracy from event-time accuracy. At a tangency the denominator vanishes and the formula cannot be used.

Background · Event transversality
\[\dot g=\partial_tg+\nabla g\cdot f\]

For a simple event this directional derivative is nonzero. Near grazing, a small state error can create a much larger error in the event time.

Resolve two crossings analytically

Take \(g(t)=(t-t_0)^2-d\), a local model for a turning point relative to a sensor threshold. For \(d>0\) the events are \(t_0\pm\sqrt d\). Their separation is \(2\sqrt d\), and their slopes are \(\pm2\sqrt d\). For \(d=0\) there is only a tangent touch. If \(d<0\), the sensor is never triggered. An additive constant perturbation \(\epsilon\) changes the effective parameter from \(d\) to \(d-\epsilon\).

At \(t_0=1\), \(d=0.01\) and \(\epsilon=0.001\), the first event moves from 0.9 to about 0.90513. The linear prediction is

\[0.001/0.2=0.005.\]

At \(d=0.0004\) the same perturbation removes both crossings entirely. Reporting more digits from a polished scalar rootfinder would not recover them.

What two endpoint samples fail to tell you

With \(d=0.0025\), a step from 0.9 to 1.1 has equal positive endpoint values of 0.0075 but crosses the threshold twice. Dense interpolation followed by an extremum check can detect this pair if the interpolant resolves the turning point. A sign-change test at accepted endpoints alone cannot. An interpolant is itself an approximation, so event feasibility should be tested against an error scale at the extremum.

Tutorial on event tolerances

For a simple crossing with slope magnitude 0.04 units/s, what error in the event function is consistent with a 1 ms time tolerance to first order?

Worked solution

Multiply the slope by the desired time uncertainty. The event function should be accurate to about \(4\times10^{-5}\) units near the crossing.

A contact model needs the first event, even if it only touches the threshold and returns. How should the experiment be reported near grazing?

Worked solution

Report the minimum event-function value and an estimated error on it, in addition to any time estimates. If zero lies within that uncertainty one cannot distinguish no crossing, tangency and a nearby pair from these data alone.

Study the full derivation

Find a crossing between accepted time steps · Dynamics and numerical time integration

An integrator can approximate a trajectory accurately yet report a poor switch time. Construct a continuous interpolant, relate a state error to an event-time error and inspect what happens when a trajectory merely touches a threshold.