Solution (source code)

= Solution

Let
$$
H(x,p)=U(x)+\frac12p^Tp
$$
be the <Hamiltonian>. The <Hamiltonian Monte Carlo> proposal is accepted with the <Metropolis–Hastings acceptance probability>
$$
\boxed{
\alpha=1\wedge
\exp\{H(X_t,P_t)-H(x(L\varepsilon),p(L\varepsilon))\}.}
$$
The leapfrog map is volume preserving and reversible after momentum reversal, so no proposal-density Jacobian appears.