Modified Hamiltonian in symplectic Euler method Now I consider the harmonic oscillator problem.
The ordinal differential equation is
\begin{align*}
\dot{q} &= p \\ \dot{p} &= -q 
\end{align*}
In symplectic Euler method, where
\begin{align*}
\cfrac{p^{(m+1)} - p^{(m)}}{\Delta t} &= -q^{(m)} \\
\cfrac{q^{(m+1)} - q^{(m)}}{\Delta t} &= p^{(m+1)}
\end{align*}
the flow operator $\psi_{{\rm d}, \Delta} = ((1-\Delta t^2)q + \Delta t \cdot p, -\Delta t \cdot q + p)$ is symplectic.

Here, the textbook suggests that this flow operator stricktly integrates 
the modified Hamiltonian and this Hamiltonian is invariant. This modified hamiltonian is
\begin{align*}
\tilde{H} = \cfrac{q^2+p^2}{2}  - \cfrac{qp}{2} \Delta t
\end{align*}

I cannot understand how to derive $\tilde{H}$.
 A: Compare the energy levels at the intermediate point
$$
(p^{(m)})^2+(q^{(m)})^2=(p^{(m+1)}+q^{(m)}Δt)^2+(q^{(m)})^2\\
=(p^{(m+1)})^2+(q^{(m)})^2+2p^{(m+1)}q^{(m)}Δt+(q^{(m)})^2Δt^2
$$
and
$$
(p^{(m+1)})^2+(q^{(m+1)})^2=(p^{(m+1)})^2+(q^{(m)}+p^{(m+1)}Δt)^2\\
=(p^{(m+1)})^2+(q^{(m)})^2+2p^{(m+1)}q^{(m)}Δt+(p^{(m+1)})^2Δt^2
$$
The terms of first order in $Δt$ are equal and can be compensated for by subtracting $2pqΔt$, as the additional terms that introduces are of the order $Δt^2$ and higher.
\begin{align}
(p^{(m)})^2+(q^{(m)})^2-2p^{(m)}q^{(m)}Δt
&=(p^{(m)}-q^{(m)}Δt)^2+(q^{(m)})^2-(q^{(m)})^2Δt^2
\\
&=(p^{(m+1)})^2+(q^{(m)})^2-(q^{(m)})^2Δt^2
\\[0.5em]
(p^{(m+1)})^2+(q^{(m+1)})^2-2p^{(m+1)}q^{(m+1)}Δt
&=(p^{(m+1)})^2+(q^{(m+1)}-p^{(m+1)}Δt)^2-(p^{(m+1)})^2Δt^2
\\
&=(p^{(m+1)})^2+(q^{(m)})^2-(p^{(m+1)})^2Δt^2
\end{align}

In the more general case with a Hamiltonian $H=\frac12p^2+V(q)$ and thus
$$
p^{(m+1)}=p^{(m)}-V'(q^{(m)})Δt
$$
the same approach gives the modified Hamiltionian
$$
\tilde H=\frac12p^2+V(q)-pV'(q)Δt,
$$
as also $V(q)-pV'(q)Δt=V(q-pΔt)+O(Δt)^2$.
