Charged-particle electromagnetic Lagrangian (source code)

= Charged-particle electromagnetic Lagrangian

For electromagnetic scalar and vector potentials $\phi$ and $A$,
$$
L=\frac12m\dot r^2-q\phi+q\dot r\cdot A.
$$
With
$$
E=-\nabla\phi-\partial_tA,
\qquad
B=\nabla\times A,
$$
the Euler--Lagrange equations give the Lorentz force $m\ddot r=q(E+\dot r\times B)$, while the canonical momentum is $p=m\dot r+qA$.