Numerical errors & independent checks
Can an integration conserve energy perfectly and still put the particle in the wrong place? For the unit oscillator the implicit midpoint method stays on the correct circle, yet accumulates a phase lag. You can predict that error exactly and use it to design a test for an integrator.
One step is an exact rotation through the wrong angle
Section titled “One step is an exact rotation through the wrong angle”Use , , , . The exact solution is . Form , so . A midpoint step of length obeys
Divide by . The multiplier has modulus one and angle . Energy is exactly constant in exact arithmetic. Since for , the phase lags. These conclusions use the quadratic oscillator. Geometric methods have a more general long-time energy theory under additional hypotheses. Hairer, Long-Time Energy Conservation, introduction
Set an error target
Section titled “Set an error target”Choose equal steps over one physical period, so . The positive lag is . At the lags in radians are , , . The endpoint Euclidean distance on the unit circle is . This test compares the physical state and has a specified observation time.
Try it. Predict the reduction factor on doubling once more.
Check the predicted phase lag
From , . The next lag should be about , while the energy error remains zero in the analytic recurrence. Checking exact energy at a single resolution cannot estimate convergence order.
Break the method. Replace the multiplier by , the forward Euler step. Now . Energy grows even though the scheme initially rotates in the correct direction. A useful test suite checks an independent trajectory, a conserved quantity and changes with resolution; for a finite time window, each addresses a different error. Apply these checks to an evolving profile in the KdV convergence study.
An exact answer on one grid
Section titled “An exact answer on one grid”Independent test. A program is meant to solve the unit oscillator but actually uses . Set and fix once for every run. The program reports the exact endpoint and exact energy after eight midpoint steps over one unit-oscillator period. Predict whether sixteen steps improve the agreement. Which test could expose the wrong equation before a single time step?
Distinguish cancellation from convergence
With eight steps the rotation per step is precisely , since . The excessive frequency and the midpoint phase lag cancel on this grid, including at intermediate grid points. Under refinement remains fixed at . After steps over the computed clockwise angle is
Compared to the intended endpoint , the Euclidean distance is . For the distances are , and . They approach , the distance to the exact endpoint of the implemented oscillator. Measuring error against that oscillator instead recovers second-order midpoint convergence. One comparison tests the model in the program, the other its time step.
At the initial point, the prescribed derivative is . Calling the program’s right-hand side gives . This one-line check detects the incorrect frequency even on the grid where every trajectory sample passes.
References
Section titled “References”- E. Hairer, “Long-Time Energy Conservation,” in Foundations of Computational Mathematics, Santander 2005, Cambridge University Press (2006). Publisher
Connected readings