The name leapfrog comes from one of the ways to write this algorithm, where positions and velocities `leap over' each other. Positions are defined at times , spaced at constant intervals , while the velocities are defined at times halfway in between, indicated by , where . The leapfrog integration scheme then reads:
Note that the accelerations are defined only on integer times, just like the positions, while the velocities are defined only on half-integer times. This makes sense, given that : the acceleration on one particle depends only on its position with respect to all other particles, and not on its or their velocities. Only at the beginning of the integration do we have to set up the velocity at its first half-integer time step. Starting with initial conditions and , we take the first term in the Taylor series expansion to compute the first leap value for :
We are then ready to apply Eq. 4.1 to compute the new position , using the first leap value for . Next we compute the acceleration , which enables us to compute the second leap value, , using Eq. 4.2, and so on.
A second way to write the leapfrog looks quite different at first sight. Defining all quantities only at integer times, we can write:
This is still the same leapfrog scheme, although represented in a different way. Notice that the increment in is given by the time step multiplied by , effectively equal to . Similarly, the increment in is given by the time step multiplied by , effectively equal to the intermediate value . In conclusion, although both positions and velocities are defined at integer times, their increments are governed by quantities approximately defined at half-integer values of time.
A most interesting way to see the equivalence of Eqs. 4.1, 4.2 and Eqs. 4.4, 4.5 is to note the fact that the first two equations are explicitly time-reversible, while it is not at all obvious whether the last two equations are time-reversible. For the two systems to be equivalent, they'd better share this property. Let us inspect.
Starting with Eqs. 4.1, 4.2, even though it may be obvious, let us write out the time reversibility. We will take one step forward, taking a time step , to evolve to , and then we will take one step backwards, using the same scheme, taking a time step . Clearly, the time will return to the same value since , but we have to inspect where the final positions and velocities are indeed equal to their initial values . Here is the calculation, resulting from applying Eqs. 4.1, 4.2 twice.
In an almost trivial way, we can see clearly that time reversal causes both positions and velocities to return to their old values, not only in an approximate way, but exactly. In a computer application, this means that we can evolve forward a thousand time steps and then evolve backward for the same length of time. Although we will make integration errors (remember, leapfrog is only second-order, and thus not very precise), those errors will exactly cancel each other, apart from possible round-off effects, due to limited machine accuracy.
Now the real fun comes in, when we inspect the equal-time Eqs. 4.4, 4.5:
In this case, too, we have exact time reversibility. Even though not immediately obvious from an inspection of Eqs. 4.4, 4.5, as soon as we write out the effects of stepping forward and backward, the cancellations become manifest.