The Leapfrog Integrator

For second-order problems like the Harmonic Oscillator in which f depends only on x, the second-order Leapfrog integration scheme is widely used. Its simplicity makes it an attractive alternative. However, it requires us to make a modification to the way we have been thinking about how -- and when -- our data are defined.

Up to now, we have assumed (quite reasonably) that all data are synchronous -- that is, all the components of the vector are defined at the same time . However, in second-order systems at least, it is often advantageous to define the velocities ( v = dx/dt) at the mid-points of the intervals -- the velocities are said to be staggered with respect to the positions x. Setting aside for the moment how this is accomplished in practice, let us define, following our earlier convention,

With this definition, we can write down a statement of the Leapfrog scheme that advances to and to :

 

It is depicted graphically below. Notice the symmetry between the ways x and v are advanced in time. You can easily verify by expanding out the Taylor series

that this scheme does indeed give second-order accuracy in x. In fact, it is formally equivalent to the Mid-point or second-order predictor-corrector methods.

Of course, initial conditions are rarely specified at the staggered times required by the leapfrog scheme! Typically, we must use a so-called ``self-starting'' scheme (like Euler, Mid-point or Runge-Kutta-4) to take the first half step and establish the value of . The program simple_leapfrog.c applies leapfrog to the 1-D harmonic oscillator. It uses the Euler method to offset the initial velocity. You should verify that this integrator really is second-order.