Solution (source code)

= Solution

For an autonomous <Hamiltonian function>, the <chain rule> and <Hamilton's equations> give
$$
\frac d{dt}H(X(t),V(t))
=\nabla_xH\cdot\nabla_vH-\nabla_vH\cdot\nabla_xH=0.
$$
Thus \b[the <energy> is constant along each characteristic]:
$$
\boxed{H(X(t),V(t))=H(x,v).}
$$
The time-independent hypothesis is implicit in the displayed expression in this subpart. For the time-dependent <Hamiltonian function> allowed earlier, the correct <Hamiltonian energy balance> is instead
$$
\boxed{\frac d{dt}H(t,X(t),V(t))=\partial_tH(t,X(t),V(t)).}
$$
For example $H(t,x,v)=t+|v|^2/2$ has a unique global <Hamiltonian flow>, but its value along a curve increases at unit rate. Thus conservation cannot be claimed for arbitrary time-dependent $H$.