`assert_eq`

bit, because it's much the same as before.
**xs**- is the starting point,
*x*_{0} **htot**- is the total step to be taken, but it's going to be split into multiple shorter steps
**nstep**- is the number of those shorter steps to be used

We begin by evaluating the length of a mid-point step by
dividing our input value of
by `nstep`

:

h = htot / nstepThus . Then we set

ym = y yn = y + h * dydx x = xs + hSo that at this stage

The next step is to evaluate the right hand side of the
differential equation at *x*_{1} and
**y**_{1}:

CALL derivs(x, yn, yout) h2 = 2.0_sp * hNow we are ready to start the leapfrog.

`DO`

loop within which:
- 1.
- we swap the roles of
**y**_{m}and**y**_{n}, so that the guy that has become an endpoint as the result of the last step, becomes the midpoint point now, whereas the guy that was a midpoint before becomes a starting point now. Time, i.e.,*x*, in the meantime becomes advanced by half-step, i.e.,*h*:CALL swap(ym, yn) yn = yn + h2 * yout x = x + h

- 2.
- having gone through these preparations we evaluate
the right hand side of the equation at the new
end-point that is going to become a mid-point
for the next jump:
CALL derivs(x, yn, yout)

The last step, just before leaving the subroutine,
is to wind down the process by taking the average
of the *implicitly* evaluated last value of
**y**, i.e., `ym + h * yout`

and
*explicitly* evaluated value, i.e., `yn`

,
and return that average in `yout`

:

yout = 0.5_sp * (ym + yn + h * yout)