anthropocene
Computational Physics / Structure-Preserving Integrators
◆ advanced30 min

Why a worse method gives a better orbit

RK4 is fourth order. Velocity Verlet is second. Over a long orbit Verlet wins comprehensively, and the reason has nothing to do with accuracy.

Everything so far has ranked methods by order of accuracy. Higher order, smaller error, better method. That ranking is about to fail badly.

Take a harmonic oscillator — the cleanest conservative system there is — and integrate it for a long time with RK4 (fourth order) and velocity Verlet (second order). Then look not at the trajectory but at the energy, which the true dynamics conserves exactly.

predictcommit first

Integrating a harmonic oscillator for 4000 time units at h = 0.1. What happens to the energy under RK4 (order 4) versus velocity Verlet (order 2)?

Two qualitatively different behaviours. RK4's energy error is smaller at first and then keeps growing. Verlet's is larger at first and then stops.

That distinction — bounded versus secular — matters more than order for any long integration, and it is the difference between a solar-system model that stays a solar system and one where the planets slowly spiral into the sun.

One line of code

Here is what makes Verlet different. Forward Euler, on a system with position and velocity :

const vNext = v + h * a(q);      // both updates use the OLD position
const qNext = q + h * v;         // and the OLD velocity

Symplectic Euler:

const vNext = v + h * a(q);      // update velocity first
const qNext = q + h * vNext;     // then use the NEW velocity for position

That is the entire difference. One variable is updated before the other instead of both being updated from the old state. The order of accuracy is unchanged — both are first order — and yet one has bounded energy error forever and the other does not.

Velocity Verlet is the second-order member of the same family:

const a  = accel(q);
const qNext = q + h * v + 0.5 * h * h * a;      // half-step-aware position
const aNext = accel(qNext);
const vNext = v + 0.5 * h * (a + aNext);        // average the accelerations
recallscheduled for review
What is the only difference between forward Euler and symplectic Euler, and why does it matter so much?

Why bounded, not just small

The explanation is the deepest idea in this path, and it reframes what a numerical method is.

A symplectic integrator does not approximately solve your problem. It exactly solves a nearby one. There exists a modified Hamiltonian — the shadow Hamiltonian

such that the numerical trajectory lies (to exponentially small error, over exponentially long times) on exact orbits of .

Everything follows from that. is conserved exactly because it is a Hamiltonian and the method is its exact flow. And differs from the true by . So the true energy along the numerical trajectory stays within of its initial value — forever. It oscillates as the trajectory moves around the shadow orbit, but it cannot wander off, because it is pinned to a conserved quantity.

RK4 has no shadow Hamiltonian. It is not a symplectic map, so there is nothing pinning its energy, and the per-step error — though far smaller — accumulates in one direction.

That is the whole story:

  • RK4: small error, no constraint → error accumulates linearly in time.
  • Verlet: larger error, but bounded by a conserved quantity → error never grows.

Over ten periods RK4 wins easily. Over ten million, it is not close.

The orbit you can see it in

The harmonic oscillator is clean but forgiving. A Kepler orbit with real eccentricity is where the difference becomes visceral: the perihelion passage is fast and tightly curved, and a fixed-step method has to survive it.

Kepler orbit (e = 0.6)
-1.6-1.4-1.2-1-0.8-0.6-0.4-0.200.20.4-0.8-0.6-0.4-0.200.20.40.60.8XY
RK4Velocity Verlet
steps8,000
integrators
RK432,000 evals
Velocity Verlet16,000 evals
An e = 0.6 orbit in the x–y plane. Verlet's ellipse closes on itself. RK4's spirals inward as it bleeds energy. Forward Euler's spirals outward and escapes. Increase h and watch which one degrades gracefully.

Verlet's ellipse precesses slightly — a phase error, which is second order and expected — but it stays an ellipse of the right size. RK4's ellipse shrinks. Given long enough, RK4's planet falls into the star, for no physical reason whatsoever.

What to carry forward

  • Order of accuracy is not a total ordering of methods. It measures short-term error and says nothing about long-term qualitative behaviour.
  • Ask what the system conserves, and whether your method knows about it.
  • Bounded error and small error are different goals. Long integrations want the first.
  • The next chapter takes this further: methods that abandon time-stepping altogether.