Three numerical integrators solve the same planar two-body gravity problem with the same Δt, revealing how
integration method affects long-term accuracy (energy conservation) independent of the physics itself.
Euler: x += v·dt; v += a(x)·dt
Semi-implicit: v += a(x)·dt; x += v·dt (symplectic)
RK4: weighted average of 4 slope estimates per step
a = −G·M·x / |x|³
- Time step Δt — larger steps accumulate more numerical error per orbit, especially for Euler.
- Central mass — sets gravitational strength, changing orbital period and speed.
- Sim speed — how many simulated seconds pass per real second.
- Euler / Semi-implicit / RK4 — switches which integrator advances the orbiting body; watch the trail spiral for the least accurate methods.
Symplectic integrators like semi-implicit Euler are preferred in real orbital-mechanics and molecular-dynamics
codes because they don't leak energy the way plain (explicit) Euler does.