Solution (source code)

= Solution

For a particle of mass $m$ and charge $q$, the <Hamiltonian of a charged particle in an electromagnetic field> is
$$
H(\mathbf x,\mathbf p,t)=\frac1{2m}[\mathbf p-q\mathbf A(\mathbf x,t)]^2+q\phi(\mathbf x,t).
$$
The <canonical momentum> is $\mathbf p=m\dot{\mathbf x}+q\mathbf A$. Hamilton's equations are equivalent to the <Lorentz force law>
$$
\boxed{m\ddot{\mathbf x}=q(\mathbf E+\dot{\mathbf x}\times\mathbf B),
\qquad
\mathbf E=-\nabla\phi-\partial_t\mathbf A,
\qquad
\mathbf B=\nabla\times\mathbf A.}
$$