• Home
  • About

Shores of the Dirac Sea

A blog about physics… mostly.

Feeds:
Posts
Comments
« Some HEP news
Science is a risky investment »

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

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.

 

 

 

 

 

About these ads

Rate this:

Like this:

Like Loading...

Posted in Classical mechanics, computers, Physics, puzzle | Tagged leapfrog algorithm, Physics | 7 Comments

7 Responses

  1. on November 1, 2010 at 3:32 pm matthiasr

    Another 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.


  2. on November 1, 2010 at 3:56 pm Joseph Smidt

    Ohhhh, 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 pm dberenstein

      Hi 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 ;)


  3. on November 1, 2010 at 8:25 pm Per

    Lubos, 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 pm Luboš Motl

      Happily 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?


  4. on November 6, 2010 at 1:42 pm Just Learning

    At 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.


  5. on November 13, 2010 at 6:30 am quantum probability

    Sounds like kind of a hack fix! What justifies it (besides working)?



Comments are closed.

  • Recent Posts

    • Woof Woof
    • Happy 3.1415926535… day
    • Unstable Universes
    • Bad science reporting versus good science reporting
    • If some of my students were writing problems
  • Archives

    • April 2013
    • March 2013
    • February 2013
    • January 2013
    • November 2012
    • September 2012
    • August 2012
    • July 2012
    • May 2012
    • March 2012
    • February 2012
    • January 2012
    • December 2011
    • November 2011
    • September 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
  • November 2010
    M T W T F S S
    « Oct   Dec »
    1234567
    891011121314
    15161718192021
    22232425262728
    2930  
  • Recent Comments

    Plato on Woof Woof
    Pepe on Woof Woof
    dberenstein on Woof Woof
    Lubos Motl on Woof Woof
    Wyrd Smythe on Happy 3.1415926535……
  • Physics/Math/Science Blogs

    • Asymptotia (Clifford Johnson)
    • Backreaction
    • Coctail Party Physics
    • Cosmic Variance
    • Dmitry Podolsky
    • Jeffrey Epstein Science
    • John Baez
    • Michael Nielsen
    • Musings (Jacques Distler)
    • Not even wrong
    • Resonaances
    • Robert Helling
    • Shtetl Optimized
    • Sunclipse
    • Terry Tao
    • Tomasso Dorigo
    • Uncertain Principles
  • Science Resources

    • Physics (APS journal)
    • Scientific American
  • Some More Blogs

    • Evil Inc
    • Fafblog
    • phd Comics
    • Regator
    • Scenes from a multiverse
    • Site Meter
    • WordPress.com
    • WordPress.org
  • Pages

    • About
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.com

Blog at WordPress.com.

Theme: MistyLook by WPThemes.


Follow

Get every new post delivered to your Inbox.

Join 33 other followers

Powered by WordPress.com
%d bloggers like this: