# Comparison of velocity Verlet and leapfrog algorithms

Many sources present the Euler, Verlet, velocity Verlet, and leapfrog algorithms for integrating Newton's equations. Based on the order of accuracy, it is agreed that velocity Verlet, Verlet, and leapfrog are superior to the Euler method. It can also be shown that the Verlet and velocity methods are algebraically equivalent. What are the advantages and disadvantages of using velocity Verlet or leapfrog integrators? Is one more accurate or expensive than the other?

• Velocity Verlet provides both the positions and velocities synchronously (at the same time-steps) and also requires only the initial positions and initial velocities to initiate. Leapfrog, on the other hand, requires the 'future'/subsequent positions in order to find the current velocities, which makes things messy. Both generate identical trajectories though and I'm unaware of any difference in performance. Jun 16 '16 at 17:11
• If you need a reference on the topic, you can read "Molecular Modeling and Simulation" by Tamar Schlick. If I remember well, at one points he compares the different versions of the algorithm but I can't recall if he gives any numerical differences. Yet, the books has some discussions about resonance analysis and resonance artifacts and claims that some analytic structure are better seen with some variants of the algorithm than with others. Jun 20 '16 at 8:24

The shortest answer is that the Verlet / Leapfrog methods are symplectic and time reversible, and these are desirable numerical properties that reflect the physical reality of certain simulation problems.

Sympletic means that when the methods are guaranteed to conserve total energy (more correctly, the Hamiltonian) in conservative simulation problems. Take for instance, the simulation of the earth spinning around the sun. Without an external dissipation of energy, the earth is guaranteed to remain indefinitely in orbit. But using Euler or RK4 to perform the simulation, for example, the earth would eventually leave orbit or crash into the sun, due to a small numerical drift in the total energy that builds up over a long period of simulation. Symplectic methods like Verlet / Leakfrog explicitly preserve the total energy, so the numerical solution is also guaranteed to keep the earth indefinitely in orbit.

Time-reversibility means that the (fixed-step) method can take $k$ steps forward in time, followed by $k$ steps backwards in time, and arrive at the same initial conditions used to start the simulation. We often apply time-reversible numerical methods to time-reversible physical processes; we then expect the numerical solution to have long-time behaviour similar to that of the exact solution.

But these two properties come at a sacrifice of accuracy and stability. The RK2 method is a comparable second-order method that is significantly more accurate, and the BDF2 is a second-order method that is significantly more stable. Also, these methods are explicit (i.e. efficient, because they can be computed without solving a nonlinear system of equations) only for certain physical processes; their most general form is implicit.

Reference:

• Hairer, Lubich, Wanner, "Geometric Numerical Integration", Springer 2006

EDIT v2: the Leapfrog and Verlet methods are (theoretically) identical. The following quote is from Pg. 7 of Hairer Lubich Wanner.

This basic method, or its equivalent formulation given below, is called the Stormer method in astronomy, the Verlet method in molecular dynamics, the leap-frog method in the context of partial differential equations, and it has further names in other areas.

• Sorry, I may have misread the prompt and answered a slightly different question. My edit addresses the other possibly interpretation of the prompt. Jun 17 '16 at 15:13
• Hey Richard. Thanks, I could have been more explicit in my prompt. What I'm actually looking for is a comparison/contrast between leapfrog and velocity Verlet. I don't think these methods are identical. The first of the two algorithms you link to is not actually leapfrog. It differs from leapfrog as shown on the leapfrog Wiki page. So I'm wondering how they differ in practice. Why would I use leapfrog over velocity Verlet or vice versa?
– Ian
Jun 17 '16 at 15:29
• Isn't it (in general) a discrete Hamiltonian that's conserved, rather than necessarily the continuous system Hamiltonian? Jun 17 '16 at 15:50
• @Ian, see the second form of leapfrog in artcompsci.org/vol_1/v1_web/node34.html and also the version of Verlet after "Eliminating the half-step velocity [...]" in en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet and notice that the equations coincide Jun 19 '16 at 22:02
• @origimbo, Yes. Most of the classic symplectic methods preserve quadratic first integrals of the form $Q(x)=\dot{x}^T C x$, which may include Hamiltonians, Lagrangians, angular momentum etc. If the quantity is given in a quadratic form of this type, then it is conserved exactly. Otherwise, a discretized version of the quantity is conserved instead. Jun 19 '16 at 22:20