\subsection{Derivation of the Hamilton--Jacobi Equation}

This subsection derives the Hamilton--Jacobi partial differential equation from Hamiltonian mechanics through a special canonical transformation. Jacobi's theorem then reduces the solution of the mechanics problem to finding a complete integral of the resulting PDE.

\nt{What is a canonical transformation?}{
A canonical transformation is a change of coordinates from $(q,p)$ to new variables $(Q,P)$ that preserves the form of Hamilton's equations. In the new variables the motion still satisfies $\dot{Q}_i = \pdv{\mcK}{P_i}$ and $\dot{P}_i = -\pdv{\mcK}{Q_i}$ for some new Hamiltonian $\mcK$. Why do such transformations exist? From Hamilton's principle, the action integral is $S = \int \mcL\,\dd t$. If we change coordinates so that the new Lagrangian differs from the old one by a total time derivative, $\mcL' = \mcL + \dd F/\dd t$, the action changes only by the boundary term $F(t_\mathrm{f}) - F(t_\mathrm{i})$. Since the variational principle fixes the endpoints, these boundary terms do not affect the Euler--Lagrange equations. The equations of motion are therefore unchanged. Any coordinate change generated in this way -- where the Lagrangian shifts by a total time derivative -- is canonical.}

\dfn{Generating function $F_2$}{
A type-2 generating function $F_2(q,P,t)$ defines a canonical transformation through two sets of partial-derivative relations:
\[
p_i = \pdv{F_2}{q_i},
\qquad
Q_i = \pdv{F_2}{P_i}.
\]
The first relation expresses the old momenta in terms of the old coordinates and new momenta; the second gives the new coordinates. Together these two equations completely determine the transformation. The total-time-derivative shift in the Lagrangian means the new Hamiltonian is related to the old by
\[
\mcK(Q,P,t) = \mcH(q,p,t) + \pdv{F_2}{t},
\]
since adding $\dd F_2/\dd t$ to the Lagrangian shifts the Legendre transform (which defines the Hamiltonian) by $-\pdv{F_2}{t}$. This is the crucial formula: it tells us exactly how the Hamiltonian changes under the transformation, and it is what lets us control the new dynamics by choosing $F_2$ wisely.}

\dfn{Hamilton's principal function and the Hamilton--Jacobi action}{
Let $q_1,\dots,q_n$ be generalized coordinates and let $p_1,\dots,p_n$ be the corresponding canonical momenta. Hamilton's principal function $\mcS(q_1,\dots,q_n,t)$ is a generating function whose spatial partial derivatives equal the canonical momenta:
\[
p_i = \pdv{\mcS}{q_i}
\]
for each $i=1,\dots,n$. When $\mcS$ satisfies the Hamilton--Jacobi equation it encodes the complete solution to the equations of motion.}

\nt{Why turn ODEs into a PDE?}{
At first glance, replacing $2n$ coupled first-order ODEs with one nonlinear PDE seems like a step backward. Three reasons make the trade worth it.

(a) Separability reveals symmetries: if the Hamiltonian admits cyclic coordinates, the PDE separates and each separated equation displays a conserved quantity, making symmetries algebraically manifest. A cyclic coordinate in the Hamiltonian becomes a trivially integrable separated equation in the PDE.

(b) Complete integrals bypass ODE solving entirely: finding a solution with $n$ independent constants, then applying Jacobi's theorem, yields the trajectory $q(t)$ algebraically without integrating equations of motion at all. The mechanics problem reduces to algebra.

(c) Quantum-mechanical connection: the Hamilton--Jacobi equation is the classical limit of the Schrödinger equation, appearing as the leading-order term in the WKB approximation where the wavefunction takes the form $\psi \propto \exp(\mathrm{i}\mcS/\hbar)$. Solving the HJ equation is the prerequisite step for connecting classical trajectories to quantum amplitudes -- a theme that recurs throughout the advanced material.}

\nt{Geometric optics analogy}{
Geometric optics provides an intuitive picture. In optics there are two complementary descriptions of light: the ray picture, where light follows trajectories through space, and the wavefront picture, where surfaces of constant phase propagate through the medium. The eikonal equation, $|\nabla\phi| = n(\mathbf{r})$, is a first-order PDE for the optical phase $\phi(\mathbf{r})$. Surfaces of constant $\phi$ are the wavefronts; the gradient $\mathbf{k} = \nabla\phi$ is the local wave-vector, pointing normal to each wavefront, and its magnitude $|\mathbf{k}| = n$ encodes the local refractive index. The light rays are the characteristics of the eikonal equation -- integral curves of $\mathbf{k}$ -- and they obey Snell's law at interfaces.

The Hamilton--Jacobi theory is the exact mechanical analogue of this picture. The principal function $\mcS$ plays the role of optical phase, the canonical momentum $\mathbf{p} = \nabla\mcS$ plays the role of the wave-vector (it is the gradient of $\mcS$, pointing normal to surfaces of constant action), and particle trajectories are the characteristics -- integral curves of $\mathbf{p}$ -- just as light rays are integral curves of $\mathbf{k}$. The Hamilton--Jacobi equation itself is the mechanical eikonal equation.

Just as Fermat's principle determines the path of light through minimizing optical path length, Hamilton's principle determines the path of the particle through extremizing the action. Both are encoded in the same first-order PDE structure: one governing propagating wavefronts of light, the other governing propagating surfaces of constant action.}

\thm{The Hamilton--Jacobi partial differential equation}{
Let $\mcH(q_1,\dots,q_n,p_1,\dots,p_n,t)$ be the Hamiltonian of a system with $n$ degrees of freedom. We seek a type-2 canonical transformation, generated by $\mcS(q,P,t)$, that simplifies the dynamics by choosing the new Hamiltonian to vanish identically: $\mcK = 0$. With $\mcK = 0$, every new coordinate and momentum is constant in time, because $\dot{Q}_i = \pdv{\mcK}{P_i} = 0$ and $\dot{P}_i = -\pdv{\mcK}{Q_i} = 0$. This choice eliminates all time dependence in the transformed variables, reducing the entire dynamics problem to finding $\mcS$. The generating function $\mcS(q_1,\dots,q_n,t)$ satisfies
\[
\mcH\!\left(q_1,\dots,q_n,\pdv{\mcS}{q_1},\dots,\pdv{\mcS}{q_n},t\right) + \pdv{\mcS}{t} = 0.
\]
This is the Hamilton--Jacobi equation.}

\pf{Derivation from the canonical transformation to $\mcK=0$}{
Begin with the Lagrangian $\mcL(q,\dot{q},t)$ for a system with generalized coordinates $q_1,\dots,q_n$. Define the canonical momenta through the Legendre transform:
\[
p_i = \pdv{\mcL}{\dot{q}_i}
\]
for each $i$. The Hamiltonian is the Legendre transform of the Lagrangian:
\[
\mcH = \sum_{i=1}^{n} p_i \dot{q}_i - \mcL,
\]
expressed as a function of $(q,p,t)$ after eliminating $\dot{q}$ in favor of $p$ using the inverse of the Legendre map. Hamilton's canonical equations follow from the definition:
\[
\dot{q}_i = \pdv{\mcH}{p_i},
\qquad
\dot{p}_i = -\pdv{\mcH}{q_i}.
\]
These $2n$ first-order coupled equations determine the dynamics once initial conditions are given. For systems with many degrees of freedom these equations are tightly coupled and difficult to integrate directly.

Now seek a type-2 canonical transformation from $(q,p)$ to new variables $(Q,P)$ that simplifies the dynamics. The generating function $F_2(q,P,t)$ defines the transformation through the relations
\[
p_i = \pdv{F_2}{q_i},
\qquad
Q_i = \pdv{F_2}{P_i}.
\]
The new Hamiltonian $\mcK(Q,P,t)$ is related to the original Hamiltonian $\mcH$ by the standard transformation rule
\[
\mcK = \mcH + \pdv{F_2}{t}.
\]

The central idea of the Hamilton--Jacobi method is to choose the generating function $F_2$ so that the new Hamiltonian vanishes identically: $\mcK = 0$. The motivation for this choice is simple -- with $\mcK = 0$, Hamilton's equations in the new variables give
\[
\dot{Q}_i = \pdv{\mcK}{P_i} = 0,
\qquad
\dot{P}_i = -\pdv{\mcK}{Q_i} = 0.
\]
Every new coordinate and every new momentum is strictly constant in time. The dynamics in the transformed variables is completely trivial: all $2n$ constants of motion are known immediately.

Setting $\mcK = 0$ in the transformation rule gives the key relation
\[
\mcH = -\pdv{F_2}{t}.
\]
Rename the generating function $F_2$ as $\mcS(q_1,\dots,q_n,P_1,\dots,P_n,t)$ and use $p_i = \pdv{\mcS}{q_i}$ to substitute the momenta inside the Hamiltonian. The previous equation reads
\[
\mcH\!\left(q_1,\dots,q_n,\pdv{\mcS}{q_1},\dots,\pdv{\mcS}{q_n},t\right) = -\pdv{\mcS}{t}.
\]
Rearranging gives the Hamilton--Jacobi partial differential equation:
\[
\mcH\!\left(q_1,\dots,q_n,\pdv{\mcS}{q_1},\dots,\pdv{\mcS}{q_n},t\right) + \pdv{\mcS}{t} = 0.
\]
Every solution $\mcS$ of this PDE generates a canonical transformation to variables in which the motion is completely trivial. The constants $P_i$ can be identified with separation constants $\alpha_i$ and the constants $Q_i$ with integration constants $\beta_i$. Finding the complete integral of this one PDE is therefore equivalent to solving all $2n$ Hamilton's equations at once.}

\cor{Time-independent HJ equation (Hamilton--Charpit--Jacobi)}{
When the Hamiltonian does not depend explicitly on time, $\pdv{\mcH}{t} = 0$ and the Hamiltonian is a conserved quantity, $\mcH = E$. In this case the time dependence of $\mcS$ separates as $\mcS = W(q_1,\dots,q_n) - Et$, and the Hamilton--Jacobi equation reduces to
\[
\mcH\!\left(q_1,\dots,q_n,\pdv{W}{q_1},\dots,\pdv{W}{q_n}\right) = E.
\]
This is the time-independent Hamilton--Jacobi equation, sometimes called the Hamilton--Charpit--Jacobi equation. Solving for $W$ and appending $-Et$ gives the complete principal function.}

\dfn{Jacobi's theorem on complete integrals}{
A complete integral of the Hamilton--Jacobi equation is a solution $\mcS(q_1,\dots,q_n,\alpha_1,\dots,\alpha_n,t)$ containing $n$ independent non-additive separation constants $\alpha_1,\dots,\alpha_n$ (plus one overall additive constant that drops out of all derivatives and does not affect the physics). The term non-additive means each $\alpha_i$ appears in $\mcS$ in a way that cannot be removed by simply shifting $\mcS$ by a constant -- for example, as a coefficient of $x$ or inside a square root.

The constants $\alpha_i$ play the role of the new canonical momenta $P_i$, all conserved because $\mcK = 0$. Physically, the $\alpha_i$ are constants of motion that specify the state of the system; common choices include the total energy, the magnitude of angular momentum, and its $z$-component. The constants $\beta_i$ play the role of the new coordinates $Q_i$ and are fixed by initial conditions.

Jacobi's theorem provides the equations of motion:
\[
\pdv{\mcS}{\alpha_i} = \beta_i
\]
for each $i=1,\dots,n$. Each equation $\pdv{\mcS}{\alpha_i} = \beta_i$ is algebraic in the coordinates and time, so the $n$ equations together determine $q_1(t),\dots,q_n(t)$.

The algorithm is: find the complete integral, differentiate $\mcS$ with respect to each separation constant $\alpha_i$, set each result equal to a constant $\beta_i$, and solve the resulting $n$ algebraic equations for $q_1(t),\dots,q_n(t)$. The canonical momenta then follow from $p_i = \pdv{\mcS}{q_i}$. This procedure replaces the integration of $2n$ coupled first-order differential equations with the solution of $n$ algebraic equations -- a dramatic simplification.}

\nt{Connection to Hamilton's principle of least action}{
Hamilton's principal function $\mcS(q,t)$ evaluated along the actual physical path coincides with the action integral $\int_{t_0}^{t} \mcL\,\dd t'$ computed along that trajectory. The Hamilton--Jacobi equation itself can be viewed as the condition that the action integral be stationary under endpoint variations, generalized to a differential equation for the action. This unifies the variational and canonical formulations of classical mechanics into a single framework based on the propagating wavefront of constant action. The principal function $\mcS$ is itself the action evaluated from a fixed initial point to the variable endpoint $(q,t)$ along the true trajectory.}

\nt{Connection to Maupertuis' principle}{
The time-independent Hamilton--Jacobi equation also connects to Maupertuis' principle, which characterizes true trajectories as geodesics in configuration space with a metric scaled by kinetic energy. The reduced action $W(q)$ satisfies $\dd W = p_i\,\dd q_i$, so that integrating $\dd W$ along a trajectory is equivalent to integrating the momentum one-form. When $H=E$ is held fixed, the paths that extremize $\int p_i\,\dd q_i$ are the same paths found by solving the time-independent equation for $W$. This makes the Hamilton--Jacobi formalism the bridge between the velocity-space perspective of Lagrangian mechanics and the phase-space perspective of Hamiltonian mechanics.}

\mprop{Summary of the HJ method}{
The Hamilton--Jacobi method solves a mechanics problem in five steps:
\begin{enumerate}[label=\bfseries\tiny\protect\circled{\small\arabic*}]
\item Write the Hamiltonian $\mcH(q,p,t)$ in terms of the appropriate generalized coordinates and momenta. Choose coordinates that exploit the symmetry of the problem.

\item Substitute $p_i = \pdv{\mcS}{q_i}$ into $\mcH$ to obtain the Hamilton--Jacobi PDE: $\mcH + \pdv{\mcS}{t} = 0$. This converts the problem from solving $2n$ ODEs into solving one PDE.

\item Separate variables if possible. If $\mcH$ does not depend explicitly on time, set $\mcS = W(q) - Et$ and solve the time-independent equation $\mcH(q,\pdv{W}{q}) = E$. Cyclic coordinates produce additive terms in $W$ that separate immediately.

\item Find a complete integral $\mcS(q,\alpha,t)$ containing $n$ independent non-additive separation constants $\alpha_1,\dots,\alpha_n$. For a one-degree-of-freedom system this means one constant; for higher dimensional systems more separation constants appear.

\item Apply Jacobi's theorem: set $\pdv{\mcS}{\alpha_i} = \beta_i$ for each $i$, then solve the resulting $n$ algebraic equations for $q_1(t),\dots,q_n(t)$. The momenta follow from $p_i = \pdv{\mcS}{q_i}$. The mechanics problem is solved.
\end{enumerate}
}

\ex{Complete integral for a free particle}{
For a free particle in one dimension, $\mcH = p^2/2m$. The Hamilton--Jacobi equation is
\[
\tfrac{1}{2m}\left(\pdv{\mcS}{x}\right)^2 + \pdv{\mcS}{t} = 0.
\]
We try the additive separation ansatz $\mcS(x,t) = W(x) + T(t)$. Substituting into the PDE gives
\[
\frac{1}{2m}\left(\der{W}{x}\right)^2 + \der{T}{t} = 0.
\]
Since the first term depends only on $x$ and the second only on $t$, each must equal a constant. We choose the separation constant as $\alpha^2/(2m)$, where $\alpha$ will turn out to be the constant momentum:
\[
\frac{1}{2m}\left(\der{W}{x}\right)^2 = \frac{\alpha^2}{2m},
\qquad
\der{T}{t} = -\frac{\alpha^2}{2m}.
\]
The spatial equation gives $\der{W}{x} = \pm\alpha$. Choosing the positive sign (the negative case is covered by allowing $\alpha$ to be either positive or negative) and integrating with respect to $x$ gives $W(x) = \alpha x + c_W$. Similarly, integrating the temporal equation gives $T(t) = -\alpha^2 t/(2m) + c_T$. Absorbing the two additive constants into a single overall additive constant (which does not affect the physics) yields the complete integral
\[
\mcS(x,t;\alpha) = \alpha x - \frac{\alpha^2}{2m}\,t.
\]
We can verify this solution directly by substitution. Computing $\pdv{\mcS}{x} = \alpha$ and $\pdv{\mcS}{t} = -\alpha^2/(2m)$, the left-hand side of the PDE becomes $\tfrac{1}{2m}\alpha^2 - \alpha^2/(2m) = 0$, confirming the result. Here $\alpha$ is the constant momentum and serves as the single separation constant for this one-degree-of-freedom system. Because the Hamiltonian does not depend explicitly on time, energy conservation $\mcH = E = \alpha^2/(2m)$ determines the relationship between the separation constant and the total mechanical energy of the particle. The level sets $\mcS = \mathrm{const}$ are planes in $(x,t)$ space, representing uniformly propagating wavefronts of constant action.}

\qs{Hamilton--Jacobi for a one-dimensional Hamiltonian}{
A one-dimensional system has Hamiltonian
\[
\mcH(x,p) = \frac{p^2}{2m} + V(x).
\]

\begin{enumerate}[label=(\alph*)]
\item Write the Hamilton--Jacobi PDE explicitly for this system.
\item For the free-particle case $V(x) = 0$, find the complete integral $\mcS(x,t;\alpha)$ by separation of variables, identifying $\alpha$ as the constant momentum.
\item Show from Jacobi's theorem that $\pdv{\mcS}{\alpha} = \beta$ yields the trajectory $x(t) = (\alpha/m)t + \beta$. For $m = 2.0\,\mathrm{kg}$, $\alpha = 4.0\,\mathrm{kg\!\cdot\!m/s}$, and $\beta = 1.0\,\mathrm{m}$, compute $x(3.0\,\mathrm{s})$ and verify that the result satisfies $m\ddot{x} = 0$.
\end{enumerate}}

\sol \textbf{Part (a).} The Hamilton--Jacobi equation is obtained by the standard HJ substitution: everywhere the canonical momentum $p$ appears in the Hamiltonian, replace it with $\pdv{\mcS}{x}$. Starting from the given Hamiltonian,
\[
\mcH(x,p) = \frac{p^2}{2m} + V(x),
\]
the substitution $p \to \pdv{\mcS}{x}$ gives
\[
\frac{1}{2m}\left(\pdv{\mcS}{x}\right)^2 + V(x).
\]
The full HJ equation adds the time derivative $\pdv{\mcS}{t}$ and sets the sum to zero:
\[
\frac{1}{2m}\left(\pdv{\mcS}{x}\right)^2 + V(x) + \pdv{\mcS}{t} = 0.
\]
This is the explicit Hamilton--Jacobi PDE for a one-dimensional particle in potential $V(x)$. For general potentials $V(x)$ this is a nonlinear first-order PDE that must be solved to find $\mcS(x,t)$.

\textbf{Part (b).} For $V(x) = 0$, the Hamiltonian reduces to pure kinetic energy, $\mcH = p^2/(2m)$, and the Hamilton--Jacobi equation becomes
\[
\frac{1}{2m}\left(\pdv{\mcS}{x}\right)^2 + \pdv{\mcS}{t} = 0.
\]
Use the separation ansatz $\mcS(x,t) = W(x) + T(t)$. Because $W$ depends only on $x$ and $T$ only on $t$, the partial derivatives become ordinary derivatives:
\[
\frac{1}{2m}\left(\der{W}{x}\right)^2 + \der{T}{t} = 0.
\]
The first term depends only on $x$ and the second only on $t$, so each must equal a constant. We choose the separation constant so that the spatial derivative equals the momentum $\alpha$:
\[
\frac{1}{2m}\left(\der{W}{x}\right)^2 = \frac{\alpha^2}{2m},
\qquad
\der{T}{t} = -\frac{\alpha^2}{2m}.
\]
Solving the spatial part, take the square root of both sides:
\[
\der{W}{x} = \pm\alpha.
\]
Choosing the positive sign (the negative case is covered by allowing $\alpha$ to be negative) and integrating with respect to $x$ gives $W(x) = \alpha x$. Integrating the temporal equation gives $T(t) = -\alpha^2 t/(2m)$. The complete integral is therefore
\[
\mcS(x,t;\alpha) = \alpha x - \frac{\alpha^2}{2m}\,t.
\]
This solves the HJ PDE and contains one independent non-additive constant $\alpha$, which is the constant momentum. The energy is $E = \alpha^2/(2m)$.

\textbf{Part (c).} Jacobi's theorem states that $\pdv{\mcS}{\alpha} = \beta$, where $\beta$ is a constant determined by initial conditions. Differentiate the complete integral with respect to $\alpha$:
\[
\pdv{\mcS}{\alpha} = x - \frac{\alpha}{m}\,t.
\]
Set this equal to $\beta$ and solve for $x$:
\[
x - \frac{\alpha}{m}\,t = \beta,
\qquad\text{so}\qquad
x(t) = \frac{\alpha}{m}\,t + \beta.
\]
The velocity is
\[
\dot{x} = \frac{\alpha}{m},
\]
which is constant. The acceleration is
\[
\ddot{x} = 0,
\]
confirming the free-particle equation of motion $m\ddot{x} = 0$.

Now substitute the numerical values. The particle has mass $m = 2.0\,\mathrm{kg}$, the separation constant is $\alpha = 4.0\,\mathrm{kg\!\cdot\!m/s}$, and the integration constant is $\beta = 1.0\,\mathrm{m}$. The constant velocity is
\[
\frac{\alpha}{m} = \frac{4.0\,\mathrm{kg\!\cdot\!m/s}}{2.0\,\mathrm{kg}} = 2.0\,\mathrm{m/s}.
\]
The trajectory becomes
\[
x(t) = (2.0\,\mathrm{m/s})\,t + 1.0\,\mathrm{m}.
\]
At $t = 3.0\,\mathrm{s}$, the position is
\[
x(3.0\,\mathrm{s}) = (2.0)(3.0)\,\mathrm{m} + 1.0\,\mathrm{m} = 7.0\,\mathrm{m}.
\]
The total energy of the particle is $E = \alpha^2/(2m) = (4.0)^2/(2 \cdot 2.0) = 4.0\,\mathrm{J}$, which equals the kinetic energy $\tfrac{1}{2}(2.0)(2.0)^2 = 4.0\,\mathrm{J}$ -- a consistent check. The velocity is constant at $2.0\,\mathrm{m/s}$, the acceleration vanishes, and the initial position $x(0) = \beta = 1.0\,\mathrm{m}$. The constant $\alpha$ is the conserved linear momentum $p = m\dot{x} = 4.0\,\mathrm{kg\!\cdot\!m/s}$, and the constant $\beta$ is the initial position. Together, $\alpha$ and $\beta$ form a complete set of two independent constants for this one-degree-of-freedom system, matching the two parameters needed to describe the general solution of the second-order equation of motion.

Therefore,
\[
\text{HJ PDE:}\quad \frac{1}{2m}\left(\pdv{\mcS}{x}\right)^2 + V(x) + \pdv{\mcS}{t} = 0,
\]
\[
\mcS(x,t;\alpha) = \alpha x - \frac{\alpha^2}{2m}\,t,
\qquad
x(t) = \frac{\alpha}{m}\,t + \beta,
\qquad
x(3.0\,\mathrm{s}) = 7.0\,\mathrm{m}.
\]
