Leapfrog integration

From HandWiki
Short description: Mathematics concept

In numerical analysis, leapfrog integration is a method for numerically integrating differential equations of the form [math]\displaystyle{ \ddot x = \frac{d^2 x}{dt^2} = A(x), }[/math] or equivalently of the form [math]\displaystyle{ \dot v = \frac{dv}{dt} = A(x), \;\dot x = \frac{dx}{dt} = v, }[/math] particularly 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 [math]\displaystyle{ x(t) }[/math] and velocities [math]\displaystyle{ v(t)=\dot x(t) }[/math] at different interleaved time points, staggered in such a way that they "leapfrog" over each other.

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 [math]\displaystyle{ \Delta t }[/math] is constant, and [math]\displaystyle{ \Delta t \leq 2/\omega }[/math].[1]

Using Yoshida coefficients, applying the leapfrog integrator multiple times with the correct timesteps, a much higher order integrator can be generated.

Algorithm

In leapfrog integration, the equations for updating position and velocity are

[math]\displaystyle{ \begin{align} a_i &= A(x_i), \\ v_{i+1/2} &= v_{i-1/2} + a_{i}\, \Delta t, \\ x_{i+1} &= x_{i} + v_{i+1/2}\, \Delta t, \end{align} }[/math]

where [math]\displaystyle{ x_i }[/math] is position at step [math]\displaystyle{ i }[/math], [math]\displaystyle{ v_{i+1/2\,} }[/math] is the velocity, or first derivative of [math]\displaystyle{ x }[/math], at step [math]\displaystyle{ i+1/2\, }[/math], [math]\displaystyle{ a_{i}=A(x_i) }[/math] is the acceleration, or second derivative of [math]\displaystyle{ x }[/math], at step [math]\displaystyle{ i }[/math], and [math]\displaystyle{ \Delta t }[/math] is the size of each time step. These equations can be expressed in a form that gives velocity at integer steps as well:[2]

[math]\displaystyle{ \begin{align} x_{i+1} &= x_i + v_i\, \Delta t + \tfrac{1}{2}\,a_i\, \Delta t^{\,2}, \\ v_{i+1} &= v_i + \tfrac{1}{2}(a_i + a_{i+1})\,\Delta t. \end{align} }[/math]

However, in this synchronized form, the time-step [math]\displaystyle{ \Delta t }[/math] must be constant to maintain stability.[3]

The synchronised form can be re-arranged to the 'kick-drift-kick' form;

[math]\displaystyle{ \begin{align} v_{i+1/2} &= v_i + a_i \frac{\Delta t}{2}, \\ x_{i+1} &= x_i +v_{i+1/2}\Delta t,\\ v_{i+1} &= v_{i+1/2} + a_{i+1} \frac{\Delta t}{2}, \end{align} }[/math]

which is primarily used where variable time-steps are required. The separation of the acceleration calculation onto the beginning and end of a step means that if time resolution is increased by a factor of two ([math]\displaystyle{ \Delta t \rightarrow \Delta t/2 }[/math]), then only one extra (computationally expensive) acceleration calculation is required.

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]

Yoshida algorithms

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]

4th order Yoshida integrator

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

[math]\displaystyle{ \begin{align} x_i^1 &= x_i + c_1\, v_i\, \Delta t, \\ v_i^1 &= v_i + d_1\, a(x_i^1)\, \Delta t, \\ x_i^2 &= x_i^1 + c_2\, v_i^1\, \Delta t, \\ v_i^2 &= v_i^1 + d_2\, a(x_i^2)\, \Delta t, \\ x_i^3 &= x_i^2 + c_3\, v_i^2\, \Delta t, \\ v_i^3 &= v_i^2 + d_3\, a(x_i^3)\, \Delta t, \\ x_{i+1} &\equiv x_i^4 = x_i^3 + c_4\, v_i^3\, \Delta t, \\ v_{i+1} &\equiv v_i^4 = v_i^3 \\ \end{align} }[/math]

where [math]\displaystyle{ x_i, v_i }[/math] are the starting position and velocity, [math]\displaystyle{ x_i^n, v_i^n }[/math] are intermediary position and velocity at intermediary step [math]\displaystyle{ n }[/math], [math]\displaystyle{ a(x_i^n) }[/math] is the acceleration at the position [math]\displaystyle{ x_i^n }[/math], and [math]\displaystyle{ x_{i+1},v_{i+1} }[/math] are the final position and velocity under one 4th order Yoshida step.

Coefficients [math]\displaystyle{ (c_1, c_2, c_3, c_4) }[/math] and [math]\displaystyle{ (d_1, d_2, d_3) }[/math] are derived in [6] (see the equation (4.6))

[math]\displaystyle{ \begin{align} w_0 &\equiv - \frac{\sqrt[3]{2}}{2-\sqrt[3]{2}}, \\ w_1 &\equiv \frac{1}{2-\sqrt[3]{2}}, \\ c_1 &= c_4 \equiv \frac{w_1}{2}, c_2 = c_3 \equiv \frac{w_0+w_1}{2}, \\ d_1 &= d_3 \equiv w_1, d_2 \equiv w_0 \\ \end{align} }[/math]

All intermediary steps form one [math]\displaystyle{ \Delta t }[/math] step which implies that coefficients sum up to one: [math]\displaystyle{ \sum_{i=1}^{4} c_i = 1 }[/math] and [math]\displaystyle{ \sum_{i=1}^{3} d_i = 1 }[/math]. Please note that position and velocity are computed at different times and some intermediary steps are backwards in time. To illustrate this, we give the numerical values of [math]\displaystyle{ c_{n} }[/math] coefficients: [math]\displaystyle{ c_1=0.6756 }[/math], [math]\displaystyle{ c_2=-0.1756 }[/math], [math]\displaystyle{ c_3=-0.1756 }[/math], [math]\displaystyle{ c_4=0.6756. }[/math]

See also

References

  1. C. K. Birdsall and A. B. Langdon, Plasma Physics via Computer Simulations, McGraw-Hill Book Company, 1985, p. 56.
  2. 4.1 Two Ways to Write the Leapfrog
  3. Skeel, R. D., "Variable Step Size Destabilizes the Stömer/Leapfrog/Verlet Method", BIT Numerical Mathematics, Vol. 33, 1993, p. 172–175.
  4. Bishop, Christopher (2006). Pattern Recognition and Machine Learning. New York: Springer-Verlag. pp. 548–554. ISBN 978-0-387-31073-2. 
  5. "./Ch07.HTML". http://www.artcompsci.org/kali/vol/two_body_problem_2/ch07.html#rdocsect46. 
  6. 6.0 6.1 Yoshida, Haruo (1990). "Construction of higher order symplectic integrators". Physics Letters A 150 (5–7): 262–268. doi:10.1016/0375-9601(90)90092-3. 

External links

  • [1], Drexel University Physics