\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$.

\nt{Where does the $q\,\vec{v}\cdot\vec{A}$ term come from?}{
We can reverse-engineer the electromagnetic Lagrangian by demanding that the Euler--Lagrange equations reproduce the Lorentz force. Start from the ansatz $\mcL = \tfrac12 m v^2 - q\varphi + q\,\vec{v}\cdot\vec{A}$ and check the $x$-component. The Euler--Lagrange equation reads
\[
\frac{\dd}{\dd t}\!\left(\pdv{\mcL}{\dot{x}}\right) = \pdv{\mcL}{x}.
\]
The canonical momentum is $\pdv{\mcL}{\dot{x}} = m\dot{x} + qA_x$. Its total time derivative expands as
\[
\frac{\dd}{\dd t}(m\dot{x}+qA_x) = m\ddot{x} + q\pdv{A_x}{t} + q\dot{x}\pdv{A_x}{x} + q\dot{y}\pdv{A_x}{y} + q\dot{z}\pdv{A_x}{z}.
\]
The spatial derivative of the Lagrangian is
\[
\pdv{\mcL}{x} = -q\pdv{\varphi}{x} + q\dot{x}\pdv{A_x}{x} + q\dot{y}\pdv{A_y}{x} + q\dot{z}\pdv{A_z}{x}.
\]
Equating left and right sides and rearranging, the terms $q\dot{x}\pdv{A_x}{x}$ cancel, leaving
\[
m\ddot{x} = q\Biggl(-\pdv{\varphi}{x} - \pdv{A_x}{t}\Biggr) + q\dot{y}\Biggl(\pdv{A_y}{x} - \pdv{A_x}{y}\Biggr) + q\dot{z}\Biggl(\pdv{A_z}{x} - \pdv{A_x}{z}\Biggr).
\]
The first grouped term is $qE_x$ using $E_x = -\pdv{\varphi}{x} - \pdv{A_x}{t}$. The next two are the $x$-component of $q(\vec{v}\times\vec{B})_x = q(\dot{y}B_z - \dot{z}B_y)$ using $B_z = \pdv{A_y}{x} - \pdv{A_x}{y}$ and $B_y = \pdv{A_x}{z} - \pdv{A_z}{x}$. Thus $m\ddot{x} = q(E_x + (\vec{v}\times\vec{B})_x)$, matching the Lorentz force. The Lagrangian $\mcL = \tfrac12 mv^2 - q\varphi + q\,\vec{v}\cdot\vec{A}$ is not a guess --- it is uniquely fixed by the requirement that the variational principle yield $\vec{F} = q(\vec{E}+\vec{v}\times\vec{B})$.}

\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. The passage from a free-particle Hamiltonian to the electromagnetic one simply requires the substitutions $\vec{p} \to \vec{p} - q\vec{A}$ and $E \to E - q\varphi$. This procedure is called \emph{minimal coupling} because it represents the lowest-order way to couple electromagnetic potentials to particle motion: the potentials enter only through the simple shift of the canonical momentum, with no higher-order derivative couplings, no spin-dependent terms, and no direct coupling of the field-strength tensor to the particle coordinates.}

\nt{Canonical versus kinetic momentum}{
It is crucial to distinguish two notions of momentum for a charged particle. The canonical momentum $\vec{p} = m\vec{v} + q\vec{A}$ is the formal variable that appears in Hamilton's equations and the Hamilton--Jacobi equation. It is the quantity conserved when its corresponding coordinate is cyclic (absent from the Hamiltonian). The kinetic momentum $m\vec{v} = \vec{p} - q\vec{A}$, by contrast, is the physically measured momentum: it is the mass times the actual velocity of the particle, and its time derivative equals the mechanical Lorentz force $q(\vec{E}+\vec{v}\times\vec{B})$. These two momenta differ by $q\vec{A}$. 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. The canonical momentum is what Hamilton's equations govern; the kinetic momentum is what a detector would measure.}

\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.
\]
To understand why these substitutions are consistent, consider gauge transformations of the potentials. An arbitrary smooth scalar function $\chi(\vec{r},t)$ defines the gauge transformation
\[
\vec{A}' = \vec{A} + \nabla\chi,
\qquad
\varphi' = \varphi - \pdv{\chi}{t}.
\]
The physical electric and magnetic fields expressed in terms of potentials are $\vec{E} = -\nabla\varphi - \pdv{\vec{A}}{t}$ and $\vec{B} = \nabla\times\vec{A}$. Substituting the primed potentials,
\[
\vec{E}' = -\nabla\varphi' - \pdv{\vec{A}'}{t} = -\nabla\varphi + \nabla\pdv{\chi}{t} - \pdv{\vec{A}}{t} - \nabla\pdv{\chi}{t} = \vec{E},
\]
\[
\vec{B}' = \nabla\times\vec{A}' = \nabla\times(\vec{A}+\nabla\chi) = \nabla\times\vec{A} + 0 = \vec{B}.
\]
Both $\vec{E}$ and $\vec{B}$ are unchanged, as required since potentials are a redundant mathematical description and only the fields are physically measurable. How does the Lagrangian behave? Under the gauge transformation, the new Lagrangian is
\[
\mcL' = \tfrac12 m v^2 - q\varphi' + q\,\vec{v}\cdot\vec{A}' = \mcL + q\,\vec{v}\cdot\nabla\chi + q\,\pdv{\chi}{t}.
\]
The extra terms combine into a total time derivative: $q\,\vec{v}\cdot\nabla\chi + q\,\pdv{\chi}{t} = \frac{\dd(q\chi)}{\dd t}$. The action changes by $\int_{t_1}^{t_2} \frac{\dd(q\chi)}{\dd t}\,\dd t = q\chi(t_2) - q\chi(t_1)$, a pure boundary term. Since the principle of least action fixes the endpoints, the variation of this boundary term vanishes: $\delta[q\chi(t_2)-q\chi(t_1)] = 0$. The Euler--Lagrange equations, which depend only on the variation of the action, remain unchanged. This is why adding a total time derivative to any Lagrangian never alters the equations of motion. Under the gauge transformation the HJ equation retains its form provided the principal function transforms as
\[
\mcS'(\vec{r},t) = \mcS(\vec{r},t) - q\,\chi(\vec{r},t).
\]
To see this, substitute $\nabla\mcS' = \nabla\mcS - q\nabla\chi$ 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{Connection to quantum mechanics through the WKB approximation}{
The Hamilton--Jacobi equation is the classical $\hbar\to 0$ limit of the Schrödinger equation, and the bridge between them is the WKB (Wentzel--Kramers--Brillouin) approximation, a semiclassical method valid when the action is large compared to $\hbar$. The WKB ansatz writes the wavefunction as $\psi(\vec{r},t) = A(\vec{r},t)\,\exp(\mathrm{i}\mcS(\vec{r},t)/\hbar)$, where $\mcS$ plays the role of a phase function and $A$ is a slowly varying amplitude. For simplicity set $A=1$ so that $\psi = \exp(\mathrm{i}\mcS/\hbar)$ and substitute this directly into the Schrödinger equation for a charged particle,
\[
\mathrm{i}\hbar\,\pdv{\psi}{t} = \frac{1}{2m}\bigl(-\mathrm{i}\hbar\nabla - q\vec{A}\bigr)^2\psi + q\varphi\psi.
\]
Compute the derivatives: $\pdv{\psi}{t} = (\mathrm{i}/\hbar)(\pdv{\mcS}{t})\psi$, and
\[
(-\mathrm{i}\hbar\nabla - q\vec{A})\psi = -\mathrm{i}\hbar\Bigl(\frac{\mathrm{i}}{\hbar}\nabla\mcS\,\psi\Bigr) - q\vec{A}\psi = (\nabla\mcS - q\vec{A})\psi.
\]
Applying the operator a second time,
\[
\bigl(-\mathrm{i}\hbar\nabla - q\vec{A}\bigr)^2\psi = (-\mathrm{i}\hbar\nabla)\bigl[(\nabla\mcS - q\vec{A})\psi\bigr] - q\vec{A}\cdot(\nabla\mcS - q\vec{A})\psi.
\]
The gradient of the product gives $(\nabla\mcS - q\vec{A})(\mathrm{i}/\hbar)(\nabla\mcS)\psi + (\mathrm{i}/\hbar)(\nabla\mcS)(\nabla\mcS - q\vec{A})\psi$ plus the term involving $\nabla\cdot(\nabla\mcS-q\vec{A})$. Multiplying by $-\mathrm{i}\hbar$, the leading-order piece (proportional to $\hbar^0$) is $|\nabla\mcS - q\vec{A}|^2\psi$, while a correction proportional to $\hbar$ involves $\nabla\cdot(\nabla\mcS - q\vec{A})$. The right-hand side of the Schrödinger equation becomes
\[
\frac{1}{2m}\Bigl[|\nabla\mcS - q\vec{A}|^2 - \mathrm{i}\hbar\,\nabla\cdot(\nabla\mcS - q\vec{A})\Bigr]\psi + q\varphi\psi.
\]
The left-hand side is $-\pdv{\mcS}{t}\,\psi$. Equating and dividing by $\psi$, the $\hbar^0$ (leading-order) terms give exactly
\[
\frac{1}{2m}|\nabla\mcS - q\vec{A}|^2 + q\varphi + \pdv{\mcS}{t} = 0,
\]
which is the classical Hamilton--Jacobi equation for a charged particle. The $\hbar^1$ term $-\mathrm{i}\hbar/(2m)\,\nabla\cdot(\nabla\mcS - q\vec{A}) = 0$ yields a continuity equation for the amplitude $A$. Higher-order terms in $\hbar$ provide successive quantum corrections. In this way, the Hamilton--Jacobi equation is the zeroth-order term in a systematic semiclassical expansion of quantum mechanics.}

\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,
\[
\mcH = \frac{1}{2m}\Bigl[p_x^2 + \bigl(p_y - q B_0 x\bigr)^2 + p_z^2\Bigr],
\]
\[
\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,
\]
\[
\text{cyclic coordinates: } y, z,\qquad \omega_c = 1.76\times 10^{11}\,\mathrm{rad/s}.
\]
