Leapfrog holds a planet's energy for 100,000 orbits
Leapfrog's energy error is the same after 100,000 periods as after 10,000, while RK4's grows 10 times.
RK4leapfrog
| Quantity | Viv | Checked by |
|---|---|---|
leapfrog growth | 1 | leapfrog: the energy error over the last 10,000 periods is within a factor of 1.5 of the first 10,000's |
rk4 growth | 10.364 | RK4: the energy error is 5 to 15 times larger at 100,000 periods than at 10,000 |
kepler_leapfrog_rk4.viv
Output · native build · Oct 14, 2026 · 10.6 s
lf_first: 0.00134469 lf_last: 0.00134469 rk_at_window: 0.00464954 rk_at_end: 0.0481878 leapfrog_growth: 1 rk4_growth: 10.364
- ✓ leapfrog: the energy error over the last 10,000 periods is within a factor of 1.5 of the first 10,000's
- ✓ RK4: the energy error is 5 to 15 times larger at 100,000 periods than at 10,000
Open in the workbenchAtlasMore math claims
- Full statement
- Integrating a Kepler orbit of eccentricity 0.5 for 100,000 periods with 200 steps per period, the leapfrog (velocity Verlet) energy error stays bounded (its largest value over the last 10,000 periods is within a factor of 1.5 of its largest over the first 10,000), while classical fourth-order Runge-Kutta's energy error grows in proportion to time (it is between 5 and 15 times larger at 100,000 periods than at 10,000).
- Scope
- One orbit, one step size, Kepler problem in the plane. The claim is about growth over time, not size: at this step size RK4's energy error is already larger than leapfrog's after 10,000 periods, and a smaller step would delay that, not prevent it. Round-off over 2 × 107 steps also adds a slow random walk to both.
- Reference
- The exact energy -1/(2a) = -0.5 of the orbit (G M = 1, a = 1); Hairer, Lubich and Wanner, Geometric Numerical Integration (2nd ed., 2006), chapters I and IX: a symplectic method conserves a modified energy, so its energy error does not drift, while a non-symplectic method's energy error drifts linearly.
claims/math/kepler_leapfrog_rk4.viv#31e8cda704