We are trying to approximate an ODE of the form $y'=f(y)$ using the method $y_{n+1} =y_n + hf(\frac{1}{2}(y_n+y_{n+1}))$. It is a Hamiltonian flow and is separable with $H(x,p) = T(p) + V(x)$ and $T,V$ are three time continuously differentiable. We have the sequence $(x_n,p_n)$ from the approximation and e want to show that $H(x_n,p_n) = H(x_0,p_0) +O(h^2)$
It is suggested that we try to show $H_{n+1}=H_n+O(h^3)$ where $H_n=H(x_n,p_n)$.
I'm quite stuck and would appreciate any help
There are a variety of methods for showing the stability of a numerical scheme. Essentially, they all make use of the Taylor expansion. You are meant to use the fact that $H(x,p) = T(p) + V(x)$ is three times continuously differentiable. Below I provide a proof of the order and consistency of the midpoint method.
consider the IVP $$\begin{cases} y' = f(y) \\ y(0) = y_0 \end{cases}$$ where $y'''$ is continuous on some interval. We wish to approximate via the midpoint method: $y_{n+1} = y_n + h\phi(t_n,y_n,h)$, where $\phi(t_n,y_n,h) = f(2^{-1}(y_n + y_{n+1}))$.
By construction this method is clearly consistent. We therefore proceed to show the order of accuracy. For convenience let the local truncation error be denoted by $d(y,h) := y(t+h) - y(t) - h\phi(t,y,h)$. Applying Taylor's theorem in two variables we find $$\begin{equation} \begin{split} \phi(t,y(t),h) &= f\left(t+\frac{h}{2},y+\frac{h}{2}f(t,y)\right) \\ &= f(t,y) + \frac{h}{2}f_t(t,y) + \frac{h}{2}f_y(t,y)f(t,y) + \mathcal{O}(h^2) \\ &= f(t,y) + \frac{h}{2}\frac{d}{dt}f(t,y) + \mathcal{O}(h^2) \\ &= f(t,y) + \frac{h}{2}y''(t) + \mathcal{O}(h^2) \end{split} \end{equation} $$ Substituting this result into our expression for $d$ we find $$\begin{equation} \begin{split} d(y(t), h) &= y(t) + hy'(t) + \frac{h^2}{2}y''(t) + \mathcal{O}(h^3) \\ &= \mathcal{O}(h^3) \end{split} \end{equation}$$ It follows that the method is second order accurate.