Feeds:
Posts

## Leapfrog

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 $H= \frac {p_1^2 + p_2^2}{2m} - \frac{K}{r}$

where $r= \sqrt{x_1^2+x_2^2}$

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 $p_i [t+\delta t ] = p_i[t] - \partial_{x_i} V[r[t]] \delta t$

and $r_i[t+\delta t]= r_i[t]+ \frac{p_i}{m} \delta t$

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 $\delta t\to -\delta t$ 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 $p_i[t+\delta t/2] = p_i[t-\delta t/2]+ \partial_{x_i} V(r[t]) \delta t$

and $x_i[t+\delta t]= x_i[t]+ p_i[t+\delta t/2] \delta t$

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 $x_{1,2}= 0$. 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 $\delta t$ without loss of information.