Leapfrog integration
In numerical analysis, leapfrog integration is a method for numerically integrating differential equations of the form formula_1 or equivalently of the form formula_2 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 formula_3 and velocities formula_4 at 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 formula_5 is constant, and formula_6. 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 where formula_8 is position at step formula_9, formula_10 is the velocity, or first derivative of formula_11, at step formula_12, formula_13 is the acceleration, or second derivative of formula_11, at step formula_9 , and formula_5 is the size of each time step. These equations can be expressed in a form that gives velocity at integer steps as well: However, even in this synchronized form, the time-step formula_5 must be constant to maintain stability. The synchronised form can be re-arranged to the 'kick-drift-kick' form; 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 (formula_20), 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 implies  that it conserves the (slightly modified) energy of dynamical 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. 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. 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 where formula_22 are the starting position and velocity, formula_23 are intermediary position and velocity at intermediary step formula_24, formula_25 is  the acceleration at the position formula_26, and formula_27 are the final position and velocity under one 4th order Yoshida step. Coefficients formula_28 and formula_29 are derived in (see the equation (4.6)) All intermediary steps form one formula_5 step which implies that coefficients sum up to one: formula_32 and formula_33. 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 formula_34 coefficients: formula_35, formula_36, formula_37, formula_38