# Find/Implement Leapfrog method in DifferentialEquations/OrdinaryDiffEq

I am taking a class on computational physics. Instead of implementing everything myself, I figured I should use (and learn to use) existing frameworks.

One of the class problems involves using Leapfrog integration (Wiki). I can not find a leapfrog solver in the DifferentialEquations/OrdinaryDiffEq packages. I guess this is because in reality, one would rarely use this method.

It is however not the first time I encounter the Leapfrog method in teaching contexts, so perhaps it is worth implementing it. Not to solve differential equations well, but to perform “numerical experiments” and learn about numerical differential equation solving.

My concrete questions are:

1. Is there any existing solver that implements the Leapfrog method, but that goes by a different name?
2. If not, is it feasible to implement it myself (Lets say ~less than 50 LOC)? I started looking into the `src` of `OrdinaryDiffEq`, but there were a lot of lines of code specifying formalities (Order, beta-coefficients and so on), and I could not even find where the instructions for doing the calculations were defined.
1 Like

Hi,

I think there are quite some people using it.

You can find it in the section of symplectic solvers here:
Dynamical, Hamiltonian, and 2nd Order ODE Solvers · DifferentialEquations.jl (sciml.ai)

If you want to learn how to implement a sympletic method, I would recommend to do it without `OrdinaryDiffEq`. Just define your problem in a suitable way and write your own `solve` function.

PS: I will just use this as an excuse to share these very nice and short notes from one of my favourite mathematician pcam-ode.pdf (uni-tuebingen.de)
Leapfrog and symplectic integration is part of section 5. There is also this nice classical test problem for sympletic methods to simulate the orbits, see SciMLTutorials.jl/07-outer_solar_system.jmd at v1.0.0 · SciML/SciMLTutorials.jl · GitHub

2 Likes

Leapfrog is just VelocityVerlet.

The updated link is Simulating the Outer Solar System · DifferentialEquations.jl

1 Like