In numerical analysis, leapfrog integration is a method for numerically integrating differential equations of the formor equivalently of the formparticularly in the case of a dynamical system of classical mechanics.
The method is known by different names in different disciplines. In particular, it is similar to the velocity Verlet method, which is a variant of Verlet integration. Leapfrog integration is equivalent to updating positions
x(t)
v(t)=x(t) |
Leapfrog integration is a second-order method, in contrast to Euler integration, which is only first-order, yet requires the same number of function evaluations per step. Unlike Euler integration, it is stable for oscillatory motion, as long as the time-step
\Deltat
\Deltat<2/\omega
Using Yoshida coefficients, applying the leapfrog integrator multiple times with the correct timesteps, a much higher order integrator can be generated.
In leapfrog integration, the equations for updating position and velocity are
\begin{align} ai&=A(xi),\\ vi+1/2&=vi-1/2+ai\Deltat,\\ xi+1&=xi+vi+1/2\Deltat, \end{align}
where
xi
i
vi+1/2
x
i+1/2
ai=A(xi)
x
i
\Deltat
\begin{align} xi+1&=xi+vi\Deltat+\tfrac{1}{2}ai\Deltat2,\\ vi+1&=vi+\tfrac{1}{2}(ai+ai+1)\Deltat. \end{align}
\Deltat
The synchronised form can be re-arranged to the 'kick-drift-kick' form;
\begin{align} vi+1/2&=vi+ai
\Deltat | |
2 |
,\\ xi+1&=xi+vi+1/2\Deltat,\\ vi+1&=vi+1/2+ai+1
\Deltat | |
2 |
, \end{align}
\Deltat → \Deltat/2
One use of this equation is in gravity simulations, since in that case the acceleration depends only on the positions of the gravitating masses (and not on their velocities), although higher-order integrators (such as Runge–Kutta methods) are more frequently used.
There are two primary strengths to leapfrog integration when applied to mechanics problems. The first is the time-reversibility of the Leapfrog method. One can integrate forward n steps, and then reverse the direction of integration and integrate backwards n steps to arrive at the same starting position. The second strength is its symplectic nature, which sometimes allows for the conservation of a (slightly modified) energy of a dynamical system (only true for certain simple systems). This is especially useful when computing orbital dynamics, as many other integration schemes, such as the (order-4) Runge–Kutta method, do not conserve energy and allow the system to drift substantially over time.
Because of its time-reversibility, and because it is a symplectic integrator, leapfrog integration is also used in Hamiltonian Monte Carlo, a method for drawing random samples from a probability distribution whose overall normalization is unknown.[4]
The leapfrog integrator can be converted into higher order integrators using techniques due to Haruo Yoshida. In this approach, the leapfrog is applied over a number of different timesteps. It turns out that when the correct timesteps are used in sequence, the errors cancel and far higher order integrators can be easily produced.[5] [6]
One step under the 4th order Yoshida integrator requires four intermediary steps. The position and velocity are computed at different times. Only three (computationally expensive) acceleration calculations are required.
The equations for the 4th order integrator to update position and velocity are
\begin{align}
1 | |
x | |
i |
&=xi+c1vi\Deltat,\\
1 | |
v | |
i |
&=vi+d1
1) | |
a(x | |
i |
\Deltat,\\
2 | |
x | |
i |
&=
1 | |
x | |
i |
+c2
1 | |
v | |
i |
\Deltat,\\
2 | |
v | |
i |
&=
1 | |
v | |
i |
+d2
2) | |
a(x | |
i |
\Deltat,\\
3 | |
x | |
i |
&=
2 | |
x | |
i |
+c3
2 | |
v | |
i |
\Deltat,\\
3 | |
v | |
i |
&=
2 | |
v | |
i |
+d3
3) | |
a(x | |
i |
\Deltat,\\ xi+1&\equiv
4 | |
x | |
i |
=
3 | |
x | |
i |
+c4
3 | |
v | |
i |
\Deltat,\\ vi+1&\equiv
4 | |
v | |
i |
=
3 | |
v | |
i |
\\ \end{align}
where
xi,vi
n, | |
x | |
i |
n | |
v | |
i |
n
n) | |
a(x | |
i |
n | |
x | |
i |
xi+1,vi+1
Coefficients
(c1,c2,c3,c4)
(d1,d2,d3)
\begin{align} w0&\equiv-
\sqrt[3]{2 | |
All intermediary steps form one
\Deltat
cn
c1=0.6756
c2=-0.1756
c3=-0.1756
c4=0.6756.