Comparing Leapfrog Methods with Other Numerical Methods for Differential Equations
This Demonstration shows the exact and the numerical solution of some ODEs using a variety of numerical methods. Four of these methods are well-known simple standard methods. Additional methods are the well-known leapfrog method and the less-known asynchronous leapfrog method. Further, a straightforward derivative of each of these two methods is considered. Use the dropdown menus to vary the differential equation and the method. Use the sliders to vary the initial value or to change the number and size of the integration steps.
In comparing the performance of numerical methods for differential equations, one has to take into account the computational complexity of the underlying algorithms. A simple measure (and for many practical applications the most relevant one) counts how often the right-hand side of the differential equation has to be evaluated in one integration step. The leapfrog and asynchronous leapfrog methods excel in needing only one such evaluation and thus compare directly only with the explicit Euler method, which they outperform in a spectacular way. Since the leapfrog methods are second-order methods, they are most naturally compared with the second-order Runge–Kutta method, which is also known as Heun's method. Since Heun's method does two right-hand side evaluations, it is fair to compare one Heun step with a composition of two leapfrog steps of half the step size. To allow such a fair comparison without having to change the step size, such combined half-steps are implemented. They are referred to as densified methods.
Snapshots 1 and 2: behavior for a stiff differential equation; here, the Runge–Kutta methods are superior to the leapfrog methods
Snapshots 3 and 4: behavior for non-stiff differential equations; the densified asynchronous leapfrog method seems to be in most cases more accurate than Heun's method
The leapfrog methods were added by the present author to a program by Edda Eich-Soellner (see Related Links). Apart from additions, virtually no changes have been made to the program of this instructive Demonstration.