## Leapfrog

November 1, 2010 by dberenstein

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.

### Like this:

Like Loading...

*Related*

on November 1, 2010 at 3:32 pmmatthiasrAnother nice property of Leap Frog Integration is that it is “stable for oscillatory motion”, as Wikipedia calls it, i.e. the numerical errors because of the finite δt add up to zero for closed orbits.

on November 1, 2010 at 3:56 pmJoseph SmidtOhhhh, the leap frog algorithm! Though I admit it is a nice solution, I have scares from this algorithm since as an undergraduate our numerical methods professor wouldn’t not stop assigning problems requiring it. I was all leap-frogged out. 🙂

on November 1, 2010 at 4:22 pmdberensteinHi Joseph:

“He wouldn’t not stop” befuddles my mind with a double negation that makes me wonder wether he did or did not stop assigning problems with it. I’ll assume that in the end he did stop asking, if anything because the course ended.

I still think your professor did well by insisting that you learn a good method for solving problems the old fashioned way: by endless repetition until you can’t stand it 😉

on November 1, 2010 at 8:25 pmPerLubos, please note that you are NOT allowed to give away the answer immediately.

At least wait a day or two. OK? 🙂

Per

on November 6, 2010 at 2:34 pmLuboš MotlHappily enough, Per, I have missed the question if there has been any. In fact, my search device indicates that the only question mark on this page is the question mark after “OK” in your comment. 😉

As a kid with a Commodore 64, I was always using the leapfrog method of integrating equations – and it may be fair to say that much like many other people, I independently invented the method. 😉 It’s good that it just reduces the numerical inaccuracies to the higher order.

But where’s the question?

on November 6, 2010 at 1:42 pmJust LearningAt first glance, it looks like the moral equivalent of including terms with a phase shift, much like representing a system with sin’s and cos’s. Information is temporarily stored in the out of phase, or orthogonal, components.

I think an analogy to the problem is similar to gimbal locking

http://en.wikipedia.org/wiki/Gimbal_lock

Leap frog basically adds and additional degree of freedom, or space, that is used to inform the action of past behavior.

on November 13, 2010 at 6:30 amquantum probabilitySounds like kind of a hack fix! What justifies it (besides working)?