Many times in physics one wants to solve systems of ordinary second order differential equations (equations of motion for example). If the dynamics comes from a Lagrangian, it is standard to try to put them into first order formalism by going to the Hamiltonian formalism and working in “phase space”. Once you get to this stage, hyou can try putting the system on a computer by evolving the equations of motion discretely. Many times this destroys certain aspects of the dynamics. However, if you do things right, you can get some things to work better then expected.
For example, in the Hamiltonian formalism of the Kepler problem, one would have a Hamiltonian of the form
where
The sign indicates that one has smaller energy where $r$ gets smaller (the potential energy is attractive).
A naive implementation of the evolution of the system is given by evolving
and
However, after staring at this for a while, one notices that the dynamics is not reversible: both x,p have changed, so going back by changing does not get you exactly back to where you started.
There is a very nice fix to this problem: you think of momenta as being evaluated at half times, and positions at full times. This is, we get
and
and even though this looks almost identical to what we had before, it is now time reversible (just send $\delta t\to -\delta t$ and do appropriate shifts to check that you really get back to where you started).
This is called the leap-frog algorithm. For problems like the one above, it has rather nice properties. The most important one is that it preserves Liouville’s theorem (it keeps the volume element of phase space constant).
In examples like the one above, it does something else that is quite amazing. If you remember Kepler’s second law (sweeping equal areas in equal time intervals), it is the law of angular momentum conservation. I’ll leave it to you to find a proof that the above system sweeps equal areas in equal times around the origin . I learned this fact recently in a conversation in my office and I was quite pleased with it, so I thought it would be nice to share it.
This algorithm does quite well on a lot of other systems (like the one I’m studying now for my research). If you have a system with a lot of symmetries, sometimes the leapfrog algorithm will preserve a lot of these symmetries and also the conserved quantities, so that you can evolve the system for much larger values of without loss of information.