The motivation for the following is to convert the integro-differential equation

\begin{equation} \kappa\ddot x+\dot x=-kx+\beta\int_{-\infty}^t W'(x(t)-x(s))e^{s-t}ds, \end{equation}

into a system of nonlinear ODEs

\begin{equation} \begin{split} \dot{x}&=v,\\ \dot{v}&=\frac{1}{\kappa}(\beta M_0-v-kx),\\ \dot{M}_n&=-M_n+W^{(n+1)}(0)+vM_{n+1}. \end{split} \end{equation}

Let

$$M_n=\int_{-\infty}^t W^{(n+1)}(x(t)-x(s))e^{s-t}ds,$$

for all $n\in\mathbb{N}$ where $W^{(n+1)}(z)$ is the $n+1$-th derivative of $W$ with respect to $z$. I can't see how the last line of the proof below is equivalent to $-M_{n+1}+W^{(n+2)}(0)+vM_{n+2}$? Perhaps I made the wrong substitution on line 3. Any help would be much appreciated.

Applying the Leibniz integral rule, observe that for $n=0$, \begin{equation*} \begin{split} \dot{M_0}&=\frac{\partial}{\partial t}\int_{-\infty}^t W^{(1)}(x(t)-x(s))e^{s-t}ds\\ &=W^{(1)}(0)+\int_{-\infty}^t e^{s-t}\left(\dot{x}W^{(2)}(x(t)-x(s))-W^{(1)}(x(t)-x(s))\right)ds,\\ &=-M_0+W^{(1)}(0)+\dot{x}M_1. \end{split} \end{equation*} The inductive step is then \begin{equation*} \begin{split} \dot{M}_{n+1} &= \frac{\partial}{\partial t} \left(\frac{\dot{M}_n+M_n-W^{(n+1)}(0)}{v}\right),\\ &=\frac{v\frac{\partial}{\partial t}\left(\dot{M}_n+M_n-W^{(n+1)}(0)\right)-\dot{v}(\dot{M}_n+M_n-W^{(n+1)}(0))}{v^2},\\ &=\frac{v\ddot{M}_n+v\dot{M}_n-\dot{v}\dot{M}_n-\dot{v}M_n-vW^{(n+2)}(0)+\dot{v}W^{(n+1)}(0)}{v^2},\\ &=\frac{\ddot{M}_n+\dot{M}_n-\dot{v}M_{n+1}-W^{(n+2)}(0)}{v}.\\ \end{split} \end{equation*}