Solution (source code)

= Solution

Minimal electromagnetic coupling changes the <canonical momentum> to $p=\gamma m\dot r+qA$. The <mechanical momentum> is $\pi=p-qA$. The <Legendre transform> yields
$$
\boxed{H(r,p,t)=\sqrt{m^2c^4+c^2[p-qA(r,t)]^2}+q\phi(r,t).}
$$
The cancellation of $q\dot r\cdot A$ in the Legendre transform does not remove magnetic effects: $A$ remains in the relation between canonical and mechanical momenta. The expression is the relativistic kinetic-plus-rest energy with an electrostatic potential-energy term, expressed in canonical variables.