Hamiltonian mechanics
Relativistic charged particle in an electromagnetic field

The relativistic Lagrangian for a particle (rest mass m {\displaystyle m} and charge q {\displaystyle q}) is given by:

L (t) = − m c 2 1 − x ˙ (t) 2 c 2 + q x ˙ (t) ⋅ A (x (t), t) − q φ (x (t), t) {\displaystyle {\mathcal {L}}(t)=-mc^{2}{\sqrt {1-{\frac {{{\dot {\mathbf {x} }}(t)}^{2}}{c^{2}}}}}+q{\dot {\mathbf {x} }}(t)\cdot \mathbf {A} \left(\mathbf {x} (t),t\right)-q\varphi \left(\mathbf {x} (t),t\right)}

Thus the particle's canonical momentum is p (t) = ∂ L ∂ x ˙ = m x ˙ 1 − x ˙ 2 c 2 + q A {\displaystyle \mathbf {p} (t)={\frac {\partial {\mathcal {L}}}{\partial {\dot {\mathbf {x} }}}}={\frac {m{\dot {\mathbf {x} }}}{\sqrt {1-{\frac {{\dot {\mathbf {x} }}^{2}}{c^{2}}}}}}+q\mathbf {A} } that is, the sum of the kinetic momentum and the potential momentum.

Solving for the velocity, we get x ˙ (t) = p − q A m 2 + 1 c 2 (p − q A) 2 {\displaystyle {\dot {\mathbf {x} }}(t)={\frac {\mathbf {p} -q\mathbf {A} }{\sqrt {m^{2}+{\frac {1}{c^{2}}}{\left(\mathbf {p} -q\mathbf {A} \right)}^{2}}}}}

So the Hamiltonian is H (t) = x ˙ ⋅ p − L = c m 2 c 2 + (p − q A) 2 + q φ {\displaystyle {\mathcal {H}}(t)={\dot {\mathbf {x} }}\cdot \mathbf {p} -{\mathcal {L}}=c{\sqrt {m^{2}c^{2}+{\left(\mathbf {p} -q\mathbf {A} \right)}^{2}}}+q\varphi }

This results in the force equation (equivalent to the Euler–Lagrange equation) p ˙ = − ∂ H ∂ x = q x ˙ ⋅ (∇ A) − q ∇ φ = q ∇ (x ˙ ⋅ A) − q ∇ φ {\displaystyle {\dot {\mathbf {p} }}=-{\frac {\partial {\mathcal {H}}}{\partial \mathbf {x} }}=q{\dot {\mathbf {x} }}\cdot ({\boldsymbol {\nabla }}\mathbf {A})-q{\boldsymbol {\nabla }}\varphi =q{\boldsymbol {\nabla }}({\dot {\mathbf {x} }}\cdot \mathbf {A})-q{\boldsymbol {\nabla }}\varphi } from which one can derive d d t (m x ˙ 1 − x ˙ 2 c 2) = d d t (p − q A) = p ˙ − q ∂ A ∂ t − q (x ˙ ⋅ ∇) A = q ∇ (x ˙ ⋅ A) − q ∇ φ − q ∂ A ∂ t − q (x ˙ ⋅ ∇) A = q E + q x ˙ × B {\displaystyle {\begin{aligned}{\frac {\mathrm {d} }{\mathrm {d} t}}\left({\frac {m{\dot {\mathbf {x} }}}{\sqrt {1-{\frac {{\dot {\mathbf {x} }}^{2}}{c^{2}}}}}}\right)&={\frac {\mathrm {d} }{\mathrm {d} t}}(\mathbf {p} -q\mathbf {A})={\dot {\mathbf {p} }}-q{\frac {\partial \mathbf {A} }{\partial t}}-q({\dot {\mathbf {x} }}\cdot \nabla)\mathbf {A} \\&=q{\boldsymbol {\nabla }}({\dot {\mathbf {x} }}\cdot \mathbf {A})-q{\boldsymbol {\nabla }}\varphi -q{\frac {\partial \mathbf {A} }{\partial t}}-q({\dot {\mathbf {x} }}\cdot \nabla)\mathbf {A} \\&=q\mathbf {E} +q{\dot {\mathbf {x} }}\times \mathbf {B} \end{aligned}}}

The above derivation makes use of the vector calculus identity: 1 2 ∇ (A ⋅ A) = A ⋅ J A = A ⋅ (∇ A) = (A ⋅ ∇) A + A × (∇ × A). {\displaystyle {\tfrac {1}{2}}\nabla \left(\mathbf {A} \cdot \mathbf {A} \right)=\mathbf {A} \cdot \mathbf {J} _{\mathbf {A} }=\mathbf {A} \cdot (\nabla \mathbf {A})=(\mathbf {A} \cdot \nabla)\mathbf {A} +\mathbf {A} \times (\nabla \times \mathbf {A}).}

An equivalent expression for the Hamiltonian as function of the relativistic (kinetic) momentum, P = γ m x ˙ (t) = p − q A {\displaystyle \mathbf {P} =\gamma m{\dot {\mathbf {x} }}(t)=\mathbf {p} -q\mathbf {A} }, is H (t) = x ˙ (t) ⋅ P (t) + m c 2 γ + q φ (x (t), t) = γ m c 2 + q φ (x (t), t) = E + V {\displaystyle {\mathcal {H}}(t)={\dot {\mathbf {x} }}(t)\cdot \mathbf {P} (t)+{\frac {mc^{2}}{\gamma }}+q\varphi (\mathbf {x} (t),t)=\gamma mc^{2}+q\varphi (\mathbf {x} (t),t)=E+V}

This has the advantage that kinetic momentum P {\displaystyle \mathbf {P} } can be measured experimentally whereas canonical momentum p {\displaystyle \mathbf {p} } cannot. Notice that the Hamiltonian (total energy) can be viewed as the sum of the relativistic energy (kinetic+rest), E = γ m c 2 {\displaystyle E=\gamma mc^{2}}, plus the potential energy, V = q φ {\displaystyle V=q\varphi }.
oulipo:avoid_letter[t]