\subsection{Hamilton-Jacobi with Electromagnetic Fields}

This subsection extends the Hamilton--Jacobi framework to a charged particle moving in electromagnetic fields by replacing the canonical momentum with the minimal-coupling substitution $p \to p - qA$.

\dfn{Lagrangian for a charged particle in electromagnetic fields}{
Let a particle of mass $m$ and charge $q$ move with velocity $\vec{v}$ in an electromagnetic field described by the scalar potential $\varphi(\vec{r},t)$ and the vector potential $\vec{A}(\vec{r},t)$. The Lagrangian is
\[
\mcL = \tfrac12 m v^2 - q\varphi + q\,\vec{v}\cdot\vec{A}.
\]
The term $-q\varphi$ represents the electrostatic potential energy, while the velocity-dependent term $q\,\vec{v}\cdot\vec{A}$ is the magnetic interaction. Together they reproduce both the electric and magnetic parts of the Lorentz force when the Euler--Lagrange equations are applied. The canonical momentum conjugate to each spatial coordinate $r_i$ is
\[
p_i = \pdv{\mcL}{\dot{r}_i} = m v_i + q A_i,
\]
so that in vector notation,
\[
\vec{p} = m\vec{v} + q\vec{A}.
\]
The kinetic (mechanical) momentum is $m\vec{v} = \vec{p} - q\vec{A}$, and it is this combination that enters the kinetic-energy part of the Hamiltonian.}

\nt{The canonical momentum differs from the kinetic momentum. The extra term $q\vec{A}$ in the canonical momentum is what distinguishes a charged particle's Hamiltonian dynamics from those of a free particle, even in the absence of a scalar potential. Because $\vec{A}$ generally depends on position, the canonical momentum is not simply $m\vec{v}$, and its time derivative is not equal to the mechanical force. Instead, Hamilton's equations for the canonical variables reproduce the full Lorentz-force law.}

\thm{Hamiltonian for a charged particle in electromagnetic fields}{
Let $m$ denote the mass, let $q$ denote the charge, let $\varphi(\vec{r},t)$ denote the scalar potential, and let $\vec{A}(\vec{r},t)$ denote the vector potential. The canonical momentum has components $p_i$. Then the Hamiltonian of the charged particle is
\[
\mcH(\vec{r},\vec{p},t) = \frac{1}{2m}\bigl|\vec{p} - q\vec{A}(\vec{r},t)\bigr|^2 + q\,\varphi(\vec{r},t).
\]
The corresponding Hamilton--Jacobi equation for the principal function $\mcS(\vec{r},t)$ follows by replacing $p_i$ with $\pdv{\mcS}{r_i}$:
\[
\frac{1}{2m}\left|\nabla\mcS - q\vec{A}\right|^2 + q\,\varphi + \pdv{\mcS}{t} = 0.
\]}

\pf{Derivation from the Lagrangian to the HJ equation}{
Start from the Lagrangian
\[
\mcL = \tfrac12 m\,\dot{\vec{r}}\cdot\dot{\vec{r}} - q\varphi(\vec{r},t) + q\,\dot{\vec{r}}\cdot\vec{A}(\vec{r},t).
\]
Compute the canonical momentum by differentiating with respect to each velocity component:
\[
\vec{p} = \pdv{\mcL}{\dot{\vec{r}}} = m\dot{\vec{r}} + q\vec{A}.
\]
Invert this relation to express the velocity in terms of the canonical momentum:
\[
\dot{\vec{r}} = \frac{1}{m}\bigl(\vec{p} - q\vec{A}\bigr).
\]
Form the Legendre transform to obtain the Hamiltonian:
\[
\mcH = \vec{p}\cdot\dot{\vec{r}} - \mcL.
\]
Substitute the expressions for $\dot{\vec{r}}$ and $\mcL$. The kinetic-term piece gives
\[
\vec{p}\cdot\dot{\vec{r}} = \frac{1}{m}\,\vec{p}\cdot\bigl(\vec{p} - q\vec{A}\bigr) = \frac{1}{m}\bigl(p^2 - q\,\vec{p}\cdot\vec{A}\bigr),
\]
and the Lagrangian itself reads
\[
\mcL = \tfrac{1}{2m}\bigl|\vec{p} - q\vec{A}\bigr|^2 - q\varphi + \frac{q}{m}\bigl(\vec{p} - q\vec{A}\bigr)\cdot\vec{A}.
\]
The dot product in the last term of $\mcL$ expands as
\[
\frac{q}{m}\bigl(\vec{p} - q\vec{A}\bigr)\cdot\vec{A} = \frac{q}{m}\bigl(\vec{p}\cdot\vec{A} - qA^2\bigr).
\]
Subtracting $\mcL$ from $\vec{p}\cdot\dot{\vec{r}}$ gives
\[
\mcH = \frac{1}{m}\bigl(p^2 - q\,\vec{p}\cdot\vec{A}\bigr) - \Biggl[\frac{1}{2m}\bigl(p^2 - 2q\,\vec{p}\cdot\vec{A} + q^2A^2\bigr) - q\varphi + \frac{q}{m}\bigl(\vec{p}\cdot\vec{A} - qA^2\bigr)\Biggr].
\]
Combine the terms proportional to $\vec{p}\cdot\vec{A}$:
\[
-\frac{q}{m}\,\vec{p}\cdot\vec{A} - \frac{q}{m}\,\vec{p}\cdot\vec{A} + \frac{2q}{2m}\,\vec{p}\cdot\vec{A} = -\frac{q}{m}\,\vec{p}\cdot\vec{A}.
\]
Combine the terms proportional to $A^2$:
\[
-\frac{q^2}{2m}A^2 + \frac{q^2}{m}A^2 = \frac{q^2}{2m}A^2.
\]
Together with the $p^2$ terms, $\frac{p^2}{m} - \frac{p^2}{2m} = \frac{p^2}{2m}$. All terms assemble into the compact form
\[
\mcH = \frac{1}{2m}\bigl|\vec{p} - q\vec{A}\bigr|^2 + q\varphi.
\]
Now replace each component of the canonical momentum by the gradient of the action function, $p_i = \pdv{\mcS}{r_i}$, so that $\vec{p} \to \nabla\mcS$. The Hamilton--Jacobi equation $\mcH + \pdv{\mcS}{t} = 0$ then becomes
\[
\frac{1}{2m}\left|\nabla\mcS - q\vec{A}\right|^2 + q\,\varphi + \pdv{\mcS}{t} = 0.
\]}

\cor{Minimal coupling rule and gauge invariance}{
The passage from a free particle to a charged particle in electromagnetic fields is effected by the minimal coupling substitutions
\[
\vec{p} \longrightarrow \vec{p} - q\vec{A},
\qquad
E \longrightarrow E - q\varphi.
\]
Under a gauge transformation of the potentials,
\[
\vec{A}' = \vec{A} + \nabla\Lambda,
\qquad
\varphi' = \varphi - \pdv{\Lambda}{t},
\]
the HJ equation retains its form provided the principal function transforms as
\[
\mcS'(\vec{r},t) = \mcS(\vec{r},t) - q\,\Lambda(\vec{r},t).
\]
To see this, substitute $\nabla\mcS' = \nabla\mcS - q\nabla\Lambda$ into the HJ equation written in the transformed potentials:
\[
\frac{1}{2m}\bigl|\nabla\mcS' - q\vec{A}'\bigr|^2 + q\varphi' + \pdv{\mcS'}{t} = \frac{1}{2m}\bigl|\nabla\mcS - q\vec{A}\bigr|^2 + q\varphi + \pdv{\mcS}{t},
\]
so the unprimed and primed equations are identical. Thus the Hamilton--Jacobi formulation respects electromagnetic gauge invariance.}

\nt{A deep connection to quantum mechanics emerges from the WKB ansatz. Write the wavefunction as $\psi(\vec{r},t) = \exp\bigl(i\mcS(\vec{r},t)/\hbar\bigr)$. Substituting this form into the Schrodinger equation,
\[
i\hbar\,\pdv{\psi}{t} = \frac{1}{2m}\bigl(-i\hbar\nabla - q\vec{A}\bigr)^2\psi + q\varphi\psi,
\]
and collecting terms order by order in $\hbar$, the leading-order equation (proportional to $\hbar^0$) is exactly the classical Hamilton--Jacobi equation for a charged particle:
\[
\frac{1}{2m}\bigl|\nabla\mcS - q\vec{A}\bigr|^2 + q\varphi + \pdv{\mcS}{t} = 0.
\]
Higher-order terms in $\hbar$ account for quantum corrections. In this sense, the classical Hamilton--Jacobi PDE is the $\hbar\to 0$ limit of the Schrodinger equation.}

\ex{Separation for time-independent fields}{
Suppose the electromagnetic potentials are time-independent. Then the Hamiltonian has no explicit time dependence and the total energy $E$ is conserved. The time variable separates from the action as $\mcS = W(\vec{r}) - Et$, and the Hamilton--Jacobi equation reduces to the time-independent form
\[
\frac{1}{2m}\bigl|\nabla W - q\vec{A}(\vec{r})\bigr|^2 + q\,\varphi(\vec{r}) = E.
\]
If any spatial coordinate is absent from both $\vec{A}$ and $\varphi$, the corresponding component of $\nabla W$ is a constant separation equal to the conserved canonical momentum for that coordinate.}

\qs{Hamilton--Jacobi for a uniform magnetic field in Landau gauge}{
A charged particle moves in a uniform magnetic field $\vec{B} = B_0\,\hat{\bm{z}}$ with the vector potential chosen in the Landau gauge $\vec{A} = (0, B_0 x, 0)$ and scalar potential $\varphi = 0$.

\begin{enumerate}[label=(\alph*)]
\item Write the Hamiltonian in terms of the canonical momenta $p_x$, $p_y$, $p_z$.
\item Write the full Hamilton--Jacobi equation explicitly in Cartesian coordinates. Identify which generalized coordinates are cyclic.
\item For an electron ($q = -e = -1.60\times 10^{-19}\,\mathrm{C}$, $m = 9.11\times 10^{-31}\,\mathrm{kg}$) in a field $B_0 = 1.00\,\mathrm{T}$, the cyclotron frequency is $\omega_c = |q|B_0/m$. If the total transverse energy is $E_\perp = 100\,\mathrm{eV} = 1.60\times 10^{-17}\,\mathrm{J}$, compute $\omega_c$ numerically and verify the value of $\omega_c$ from the HJ separation constants matches this expression.
\end{enumerate}}

\sol \textbf{Part (a).} The Hamiltonian for a charged particle in electromagnetic fields is
\[
\mcH = \frac{1}{2m}\bigl|\vec{p} - q\vec{A}\bigr|^2 + q\varphi.
\]
With $\vec{A} = (0, B_0 x, 0)$ and $\varphi = 0$, the three components of $\vec{p} - q\vec{A}$ are
\[
\bigl(p_x - q(0),\; p_y - q B_0 x,\; p_z - q(0)\bigr) = \bigl(p_x,\; p_y - q B_0 x,\; p_z\bigr).
\]
The square of the magnitude is the sum of the squares of these components. Therefore,
\[
\mcH = \frac{1}{2m}\Bigl[p_x^2 + \bigl(p_y - q B_0 x\bigr)^2 + p_z^2\Bigr].
\]

\textbf{Part (b).} The Hamilton--Jacobi equation reads $\mcH\bigl(\vec{r},\nabla\mcS\bigr) + \pdv{\mcS}{t} = 0$. Substitute the Hamiltonian from part (a) with the replacements $p_x \to \pdv{\mcS}{x}$, $p_y \to \pdv{\mcS}{y}$, $p_z \to \pdv{\mcS}{z}$:
\[
\frac{1}{2m}\left[\left(\pdv{\mcS}{x}\right)^2 + \left(\pdv{\mcS}{y} - q B_0 x\right)^2 + \left(\pdv{\mcS}{z}\right)^2\right] + \pdv{\mcS}{t} = 0.
\]
This is the full HJ PDE in Cartesian coordinates. A generalized coordinate is cyclic if it is absent from the Hamiltonian. The coordinate $y$ does not appear explicitly in $\mcH$, so $y$ is cyclic and the conjugate momentum $\pdv{\mcS}{y} = p_y$ is conserved. Similarly, $z$ is absent from $\mcH$, so $z$ is cyclic and $p_z$ is conserved. The coordinate $x$ does appear in the term $(p_y - q B_0 x)^2$, so $x$ is not cyclic. Thus $y$ and $z$ are the two cyclic coordinates.

\textbf{Part (c).} For the electron, the cyclotron frequency follows from the minimal-coupling Hamiltonian. The numerical value is
\[
\omega_c = \frac{|q| B_0}{m}.
\]
Substitute the given values:
\[
|q| = 1.60\times 10^{-19}\,\mathrm{C},
\qquad
B_0 = 1.00\,\mathrm{T},
\qquad
m = 9.11\times 10^{-31}\,\mathrm{kg}.
\]
Form the ratio:
\[
\omega_c = \frac{(1.60\times 10^{-19})(1.00)}{9.11\times 10^{-31}}\,\mathrm{rad/s}.
\]
This gives
\[
\omega_c = 1.756\times 10^{11}\,\mathrm{rad/s}.
\]
Now verify that the HJ formalism produces the same frequency. Because the potentials are time-independent, the action separates as $\mcS = W_x(x) - E_\perp t + \alpha_y\,y + \alpha_z\,z$. The time-independent HJ equation for the transverse motion is
\[
\frac{1}{2m}\left[\left(\der{W_x}{x}\right)^2 + \bigl(\alpha_y - q B_0 x\bigr)^2\right] = E_\perp,
\]
where $E_\perp$ is the total transverse energy. Solve for $\der{W_x}{x}$:
\[
\der{W_x}{x} = \pm\sqrt{2mE_\perp - \bigl(\alpha_y - q B_0 x\bigr)^2}.
\]
Change variable to the shifted $x$-coordinate centered on the guiding center, $X = x - \alpha_y/(q B_0)$, giving
\[
\der{W_x}{X} = \pm\sqrt{2mE_\perp - (q B_0)^2 X^2}.
\]
This is the square-root form of the harmonic-oscillator action. Completing the square and comparing with the standard form $\pm\sqrt{2m\mcE - m^2\omega^2 X^2}$, we identify
\[
m^2\omega^2 = (q B_0)^2,
\qquad\text{so}\qquad
\omega = \frac{|q| B_0}{m} = \omega_c.
\]
The HJ separation constant analysis thus recovers the cyclotron frequency exactly, independent of the guiding-center location and the transverse energy. The transverse energy $E_\perp = 1.60\times 10^{-17}\,\mathrm{J}$ sets the gyroradius but does not affect the frequency.

Therefore, the Hamiltonian is
\[
\mcH = \frac{1}{2m}\Bigl[p_x^2 + \bigl(p_y - q B_0 x\bigr)^2 + p_z^2\Bigr],
\]
the Hamilton--Jacobi equation is
\[
\frac{1}{2m}\left[\left(\pdv{\mcS}{x}\right)^2 + \left(\pdv{\mcS}{y} - q B_0 x\right)^2 + \left(\pdv{\mcS}{z}\right)^2\right] + \pdv{\mcS}{t} = 0,
\]
the cyclic coordinates are $y$ and $z$, and the cyclotron frequency is
\[
\omega_c = 1.76\times 10^{11}\,\mathrm{rad/s}.
\]
