Assume we have a second-order ordinary differential equation

with initial conditions $x(0)$ and $v(0)$.

Assume there is no analytical equation for $x(t)$ that satisfied the differential equation. We can use a numerical integration algorithm to compute values of $x(t)$ on discrete time steps $\Delta t$. We’ll focus on explicit integrators which extrapolate $x(t + \Delta t)$ from the previous value $x(t)$.

The Leapfrog method is commonly-used in molecular dynamics. Here, we’ll walk through the steps of deriving the Leapfrog method.

We begin by finding the Taylor series of $a(t + \Delta t)$, $x(t + \Delta t)$, and $v(t + \Delta t)$ around $t$:

We need to re-arrange and make substitutions of the terms in the Taylor series for $x(t + \Delta t)$ and $v(t + \Delta t)$ so that they only contain the values $x(t)$, $v(t)$, $a(t)$, and $a(t + \Delta t)$. We begin by truncating the Taylor series of $a(t + \Delta t)$ after the first-order term and re-arrange:

We then note the following relationships:

By truncating the Taylor series for $x(t + \Delta t)$ and $v(t + \Delta t)$ at the second-order terms and applying the above substitutions, we get a variation of the Leapfrog integrator:

Since we truncated the equations for $x(t + \Delta t)$ and $v(t + \Delta t)$ at the second-order terms, the Leapfrog integrator is third-order accurate for a single update of the velocities and positions. This means that if we half the time step, the per-step error is divided by eight. The global error for the method is $\mathcal{O}(\Delta t^2)$, making it a secord-order method.

In a future blog post, we’ll compare the analytical model for the harmonic oscillator to approximations made with the Leapfrog integrator. This comparison will allow us to verify the order of the error of the Leapfrog integrator.