Skip to content

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 q˙=p\dot q=p, p˙=−q\dot p=-q, q(0)=1q(0)=1, p(0)=0p(0)=0. The exact solution is (cos⁡t,−sin⁡t)(\cos t,-\sin t). Form z=q+ipz=q+ip, so z˙=−iz\dot z=-iz. A midpoint step of length hh obeys

zn+1−zn=−ih(zn+1+zn)/2.z_{n+1}-z_n=-ih(z_{n+1}+z_n)/2.

Divide by 1+ih/21+ih/2. The multiplier (1−ih/2)/(1+ih/2)(1-ih/2)/(1+ih/2) has modulus one and angle −2arctan⁡(h/2)-2\arctan(h/2). Energy ∣z∣2/2|z|^2/2 is exactly constant in exact arithmetic. Since 2arctan⁡(h/2)<h2\arctan(h/2)\lt h for h>0h\gt0, 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

Choose NN equal steps over one physical period, so h=2π/Nh=2\pi/N. The positive lag is δN=2π−2Narctan⁡(π/N)\delta_N=2\pi-2N\arctan(\pi/N). At N=8,16,32N=8,16,32 the lags in radians are 0.296040.29604, 0.078930.07893, 0.020070.02007. The endpoint Euclidean distance on the unit circle is 2sin⁡(δN/2)2\sin(\delta_N/2). This test compares the physical state and has a specified observation time.

Try it. Predict the reduction factor on doubling NN once more.

Check the predicted phase lag

From arctan⁡x=x−x3/3+O(x5)\arctan x=x-x^3/3+O(x^5), δN=2π3/(3N2)+O(N−4)\delta_N=2\pi^3/(3N^2)+O(N^{-4}). The next lag should be about 0.0050.005, 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 1−ih1-ih, the forward Euler step. Now ∣zn+1∣2=(1+h2)∣zn∣2|z_{n+1}|^2=(1+h^2)|z_n|^2. 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.

Independent test. A program is meant to solve the unit oscillator but actually uses z˙=−iωz\dot z=-i\omega z. Set h0=2π/8h_0=2\pi/8 and fix ω=2tan⁡(h0/2)/h0\omega=2\tan(h_0/2)/h_0 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 h0h_0, since ωh0/2=tan⁡(h0/2)\omega h_0/2=\tan(h_0/2). The excessive frequency and the midpoint phase lag cancel on this grid, including at intermediate grid points. Under refinement ω\omega remains fixed at 1.0547861751.054786175. After NN steps over 2π2\pi the computed clockwise angle is

ΘN=2Narctan⁡(ωπ/N).\Theta_N=2N\arctan(\omega\pi/N).

Compared to the intended endpoint (1,0)(1,0), the Euclidean distance is 2∣sin⁡(ΘN/2)∣2|\sin(\Theta_N/2)|. For N=8,16,32N=8,16,32 the distances are 00, 0.2511760.251176 and 0.3193210.319321. They approach 0.3425350.342535, 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 p˙=−1\dot p=-1. Calling the program’s right-hand side gives −ω-\omega. This one-line check detects the incorrect frequency even on the grid where every trajectory sample passes.

  • E. Hairer, “Long-Time Energy Conservation,” in Foundations of Computational Mathematics, Santander 2005, Cambridge University Press (2006). Publisher