Back to the on-screen lesson ·
The Legendre transform $\mathcal{H} = \sum p\dot{q} - \mathcal{L}$, Hamilton's equations $\dot{q} = \partial\mathcal{H}/\partial p$ and $\dot{p} = -\partial\mathcal{H}/\partial q$, cyclic coordinates, and Poisson brackets.
Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.
By the end of this lesson you will be able to construct a Hamiltonian from a Lagrangian, write and use Hamilton's equations, and decide when the Hamiltonian is conserved and when it is the energy.
You can write a Lagrangian, find generalized momenta $p_i = \partial\mathcal{L}/\partial\dot{q}_i$, and build the conserved energy function $\sum p_i\dot{q}_i - \mathcal{L}$. You have met the Legendre transform in thermodynamics or in that energy function, even if not by name. This lesson makes the energy function the central object, written in coordinates and momenta, and derives the first-order equations of motion that come with it.
| Term | What it means |
|---|---|
| Hamiltonian | $\mathcal{H}(q, p, t) = \sum p_i\dot{q}_i - \mathcal{L}$, written in coordinates and momenta. |
| Canonical momentum | $p_i = \partial\mathcal{L}/\partial\dot{q}_i$, an independent variable in Hamilton's formulation. |
| Legendre transform | The change of variables from $(q, \dot{q})$ to $(q, p)$ that turns $\mathcal{L}$ into $\mathcal{H}$. |
| Hamilton's equations | $\dot{q}_i = \partial\mathcal{H}/\partial p_i$ and $\dot{p}_i = -\partial\mathcal{H}/\partial q_i$. |
| Phase space | The $2n$-dimensional space of all $(q, p)$, in which each state is one point. |
| Cyclic coordinate | A coordinate absent from $\mathcal{H}$, whose momentum is therefore conserved. |
| Poisson bracket | $\{f, g\} = \sum(\partial f/\partial q\,\partial g/\partial p - \partial f/\partial p\,\partial g/\partial q)$, with $\dot{f} = \{f, \mathcal{H}\}$. |
Lagrange's equations are $n$ second-order equations in the coordinates. Hamilton rewrote them as $2n$ first-order equations by treating the momenta $p_i = \partial\mathcal{L}/\partial\dot{q}_i$ as independent variables. The Hamiltonian is the Legendre transform
$$\mathcal{H}(q, p, t) = \sum_ip_i\dot{q}_i - \mathcal{L}(q, \dot{q}, t),$$
with every $\dot{q}_i$ rewritten in terms of the $p$'s and $q$'s. Differentiating it and using Lagrange's equations gives Hamilton's equations:
$$\dot{q}_i = \frac{\partial\mathcal{H}}{\partial p_i}, \qquad \dot{p}_i = -\frac{\partial\mathcal{H}}{\partial q_i}.$$
The first says how coordinates change given the momenta; the second is the generalized force. When the constraints are fixed and the potential does not depend on velocities, $\mathcal{H} = T + U$, the total energy. And along any motion, $d\mathcal{H}/dt = \partial\mathcal{H}/\partial t$, so a Hamiltonian with no explicit time is conserved.
Another way: picture
Picture the state of a pendulum not as an angle alone but as a point in a plane: angle across, momentum up. Hamilton's equations are a rule that says, at every point, which way the state moves and how fast. The whole motion is a flow, like water moving through the plane, and each possible history is one streamline.
Another way: steps
Take the differential of $\mathcal{H} = \sum p\dot{q} - \mathcal{L}$: $d\mathcal{H} = \sum(\dot{q}\,dp + p\,d\dot{q}) - \sum(\partial\mathcal{L}/\partial q\,dq + \partial\mathcal{L}/\partial\dot{q}\,d\dot{q}) - \partial\mathcal{L}/\partial t\,dt$. The $d\dot{q}$ terms cancel because $p = \partial\mathcal{L}/\partial\dot{q}$; that cancellation is exactly why the Legendre transform is the right one. Lagrange's equation replaces $\partial\mathcal{L}/\partial q$ by $\dot{p}$.
What remains is $d\mathcal{H} = \sum(\dot{q}\,dp - \dot{p}\,dq) - \partial\mathcal{L}/\partial t\,dt$. Comparing with $d\mathcal{H} = \sum(\partial\mathcal{H}/\partial p\,dp + \partial\mathcal{H}/\partial q\,dq) + \partial\mathcal{H}/\partial t\,dt$ gives Hamilton's equations, and $\partial\mathcal{H}/\partial t = -\partial\mathcal{L}/\partial t$. No new physics has been added; the same content is written in new variables, which turns out to reveal structure the Lagrangian hides.
For a mass on a spring, $\mathcal{L} = \tfrac{1}{2}m\dot{x}^2 - \tfrac{1}{2}kx^2$ gives $p = m\dot{x}$ and $\mathcal{H} = p^2/2m + \tfrac{1}{2}kx^2$. Hamilton's equations are $\dot{x} = p/m$ and $\dot{p} = -kx$: the definition of momentum and Newton's law, split into two first-order pieces. In the phase plane, $\mathcal{H} = E$ is an ellipse, and the state circles it once per period.
For a pendulum with angle $\phi$, $p_\phi = mL^2\dot{\phi}$ and $\mathcal{H} = p_\phi^2/2mL^2 + mgL(1 - \cos\phi)$. Near $\phi = 0$ the phase curves are ellipses; at higher energy they stretch; above the energy needed to go over the top they become wavy lines running across the plane, the pendulum whirling round. The boundary between the two kinds of motion, the separatrix, is the curve through the inverted position, and it is where chaos first appears when the pendulum is driven.
For a particle in a central potential, $p_r = m\dot{r}$ and $p_\phi = mr^2\dot{\phi}$, and $\mathcal{H} = p_r^2/2m + p_\phi^2/2mr^2 + U(r)$. The angle $\phi$ is cyclic, so $\dot{p}_\phi = 0$: angular momentum is conserved, read straight off $\mathcal{H}$. The radial equations are $\dot{r} = p_r/m$ and $\dot{p}_r = p_\phi^2/mr^3 - U'(r)$.
The term $p_\phi^2/2mr^2$ is the centrifugal barrier of the two-body lesson, appearing here without any substitution: once $p_\phi$ is a constant, $\mathcal{H}$ is already the one-dimensional energy in the effective potential. In Hamilton's form, a cyclic coordinate removes itself and its momentum from the problem at once, which is one of the method's main advantages over Lagrange's.
The Hamiltonian equals $T + U$ when the kinetic energy is a quadratic form in the velocities and the potential does not depend on them. Two common cases break this. With a moving constraint, like the bead on a spinning rod, $\mathcal{H} = p^2/2m - \tfrac{1}{2}m\omega^2r^2$, conserved but not the energy, as the Jacobi integral lesson found.
For a charge in a magnetic field, $\mathcal{L} = \tfrac{1}{2}mv^2 - q\Phi + q\vec{v} \cdot \vec{A}$, the canonical momentum is $\vec{p} = m\vec{v} + q\vec{A}$, and $\mathcal{H} = (\vec{p} - q\vec{A})^2/2m + q\Phi$. Here $\mathcal{H}$ is the energy, but written in the canonical momentum, not $m\vec{v}$. Quantum mechanics is built on exactly this Hamiltonian, with $\vec{p}$ replaced by $-i\hbar\nabla$, and getting the canonical momentum right is what makes the Zeeman effect and superconductivity come out correctly.
For any quantity $f(q, p, t)$, the chain rule and Hamilton's equations give $\dot{f} = \{f, \mathcal{H}\} + \partial f/\partial t$, where the Poisson bracket is $\{f, g\} = \sum(\partial f/\partial q_i\,\partial g/\partial p_i - \partial f/\partial p_i\,\partial g/\partial q_i)$. A quantity with no explicit time dependence is conserved exactly when its bracket with $\mathcal{H}$ vanishes.
The basic brackets are $\{q_i, p_j\} = \delta_{ij}$. In 1925 Paul Dirac noticed that the rules of the new quantum mechanics matched these brackets, with $\{f, g\}$ replaced by the commutator divided by $i\hbar$. That correspondence is why the Hamiltonian formulation, and not the Lagrangian, is the natural bridge from classical mechanics to quantum mechanics, and why a quantum course starts by writing down $\hat{H}$.
Checking an answer. Combine the two equations for each coordinate and you must recover Lagrange's equation. $\mathcal{H}$ must contain no velocities, only coordinates and momenta. The first equation must reproduce the definition of momentum. And for a natural system, $\mathcal{H}$ must equal the energy you would compute directly.
Solving $2n$ first-order equations instead of $n$ second-order ones may seem like extra work, but it has large advantages. The state of the system is a single point in phase space, and the equations say where it goes next, which is how numerical integrators work. Integrators designed around Hamilton's equations, called symplectic, conserve phase-space area exactly and energy almost exactly for billions of steps.
That is why NASA's Jet Propulsion Laboratory, in computing the positions of the planets for its ephemerides, and astronomers simulating the solar system for millions of years, integrate Hamilton's equations with symplectic methods. An ordinary integrator would slowly add or remove energy and send simulated planets drifting out of their orbits.
For one degree of freedom with a conserved Hamiltonian, every motion runs along a curve $\mathcal{H}(q, p) = E$ in the phase plane, so the whole family of motions can be drawn at once as the contour map of $\mathcal{H}$. Closed contours around a minimum of the potential are oscillations; contours that run off to large $q$ are motions that escape; and contours that pass through a saddle point, where both $\partial\mathcal{H}/\partial q$ and $\partial\mathcal{H}/\partial p$ vanish, separate the two kinds.
The direction along each contour follows from Hamilton's equations: where $p > 0$, $\dot{q} = p/m > 0$, so the state moves to the right in the upper half of the plane and to the left in the lower half. Equilibria are the points where the flow stops. Reading a phase portrait in this way gives the qualitative behavior of a system, which states oscillate, which escape and which sit on a knife edge, before any equation is solved, and it is the starting point for the lessons on phase space and chaos that follow.
Mission controllers at the Johnson Space Center in Houston track a spacecraft's state as a position and a momentum, exactly the variables of Hamilton's formulation. Its Hamiltonian per unit mass, $v^2/2 - GM/r$, is conserved between burns, so one number, read at any point, says whether the orbit is bound: negative means the craft will come back; positive means it will escape the Earth.
The International Space Station, at $6790$ km and $7.66$ km/s, has about $-29$ MJ/kg. A craft at $6671$ km moving at $11.0$ km/s has $+0.7$ MJ/kg and is leaving; at $10.85$ km/s it has $-0.9$ MJ/kg and will fall back, perhaps to the Moon's distance. The line between the two, $\mathcal{H} = 0$, is the escape condition, and a few tenths of a kilometer per second on either side of it decide whether a lunar mission reaches the Moon or sails past.
Will the planets' orbits stay as they are for billions of years? Astronomers answer by integrating Hamilton's equations for the Sun and planets over enormous spans of time. The Hamiltonian is the total energy of the system, $\sum p_i^2/2m_i$ minus the gravitational potential between each pair, and it must be conserved.
Symplectic integrators, designed to respect the structure of Hamilton's equations, keep the energy error bounded over billions of steps, where ordinary methods let it drift. Simulations of this kind, run by groups in the United States and Europe, show that the inner solar system is chaotic: Mercury has roughly a one percent chance of a close encounter with Venus within the next five billion years. That result could not be trusted without an integrator faithful to Hamilton's form.
Because $\mathcal{H} = T + U$ in most textbook problems, it is easy to think of the Hamiltonian as another name for the energy. It is defined as $\sum p\dot{q} - \mathcal{L}$, and that equals $T + U$ only when the kinetic energy is quadratic in the velocities and the potential does not depend on them. With a moving constraint the Hamiltonian is conserved but is not the energy.
A second error is to leave velocities in $\mathcal{H}$. Hamilton's equations are derivatives with respect to $p$ and $q$ with the other held fixed, which only makes sense once every $\dot{q}$ has been written in terms of momenta.
Write the Lagrangian of a mass $m$ on a spring of stiffness $k$.
$\mathcal{L} = \tfrac{1}{2}m\dot{x}^2 - \tfrac{1}{2}kx^2$
Kinetic minus potential.
Find the momentum.
$p = \dfrac{\partial\mathcal{L}}{\partial\dot{x}} = m\dot{x}$
The ordinary momentum.
Form the Legendre transform.
$\mathcal{H} = p\dfrac{p}{m} - \tfrac{1}{2}m\left(\dfrac{p}{m}\right)^2 + \tfrac{1}{2}kx^2$
Replace $\dot{x}$ by $p/m$ everywhere.
Simplify the Hamiltonian.
$\mathcal{H} = \dfrac{p^2}{2m} + \tfrac{1}{2}kx^2$
The total energy.
Write Hamilton's equations.
$\dot{x} = \dfrac{p}{m}, \quad \dot{p} = -kx$
Combined, $m\ddot{x} = -kx$.
Write the Lagrangian of a particle in a central potential.
$\mathcal{L} = \tfrac{1}{2}m(\dot{r}^2 + r^2\dot{\phi}^2) - U(r)$
Polar coordinates.
Find both momenta.
$p_r = m\dot{r}, \quad p_\phi = mr^2\dot{\phi}$
Differentiate with respect to each velocity.
Write the Hamiltonian.
$\mathcal{H} = \dfrac{p_r^2}{2m} + \dfrac{p_\phi^2}{2mr^2} + U(r)$
$T + U$ with velocities replaced by momenta.
Apply Hamilton's equation for the angle's momentum.
$\dot{p}_\phi = -\dfrac{\partial\mathcal{H}}{\partial\phi} = 0$
$\phi$ is cyclic.
Apply it for the radial momentum.
$\dot{p}_r = \dfrac{p_\phi^2}{mr^3} - U'(r)$
The centrifugal term appears automatically.
A bead of mass $m$ slides on a rod spinning at a steady $\omega$. Write its Lagrangian.
$\mathcal{L} = \tfrac{1}{2}m(\dot{r}^2 + \omega^2r^2)$
The rotation is imposed.
Find the momentum.
$p = m\dot{r}$
Only $\dot{r}$ is a velocity of the system.
Form the Hamiltonian.
$\mathcal{H} = p\dfrac{p}{m} - \dfrac{p^2}{2m} - \tfrac{1}{2}m\omega^2r^2 = \dfrac{p^2}{2m} - \tfrac{1}{2}m\omega^2r^2$
The Legendre transform.
Compare it with the kinetic energy.
$T = \dfrac{p^2}{2m} + \tfrac{1}{2}m\omega^2r^2 \ne \mathcal{H}$
The sign of the rotational term differs.
Write Hamilton's equations.
$\dot{r} = \dfrac{p}{m}, \quad \dot{p} = m\omega^2r$
The bead is flung outward.
Decide what is conserved.
$\dfrac{\partial\mathcal{H}}{\partial t} = 0 \Rightarrow \mathcal{H} \text{ conserved, } T \text{ not}$
The motor turning the rod does work on the bead.
Differentiate the Hamiltonian with respect to momentum.
$\dot{x} = \dfrac{p}{2}$
$\partial(p^2/4)/\partial p$.
Differentiate with respect to position.
$\dfrac{\partial\mathcal{H}}{\partial x} = 6x$
$\partial(3x^2)/\partial x$.
Change the sign for the momentum equation.
A particle of mass $8$ kg has Hamiltonian $\mathcal{H} = \dfrac{p^2}{16} + U(x)$. What does Hamilton's first equation give for $\dot{x}$?
Complete the worked solution: a ball of mass $6$ kg at height $y = 6$ m has vertical momentum $p = 30$ kg m/s, with $\mathcal{H} = \dfrac{p^2}{2m} + mgy$ and $g = 10$ m/s². Find $\dot{y}$ in m/s, $\dot{p}$ in N, and $\mathcal{H}$ in J.
Differentiate the Hamiltonian with respect to momentum.
$\dot{y} = \dfrac{p}{m} =$ s
Hamilton's first equation.
Differentiate with respect to height and change the sign.
$\dot{p} = -mg =$ f
Hamilton's second equation: the weight.
Add the kinetic and potential terms.
$\mathcal{H} = \dfrac{p^2}{2m} + mgy =$ h
The energy, conserved because $t$ does not appear.
Check the sign of the momentum's rate.
$\text{negative, whatever the height}$
Gravity always reduces the upward momentum.
Match each statement to its equation.
| $\partial\mathcal{H}/\partial p_i$ | $-\partial\mathcal{H}/\partial q_i$ | $\sum p_i\dot{q}_i - \mathcal{L}$ | $\partial\mathcal{H}/\partial t$ | |
|---|---|---|---|---|
| rate of a coordinate | ||||
| rate of a momentum | ||||
| Legendre transform | ||||
| rate of the Hamiltonian |
A mass-spring system has $\mathcal{H} = \dfrac{p^2}{2m} + \tfrac{1}{2}kx^2$ with $m = 1$ kg and $k = 7$ N/m. At one instant $x = 3$ m and $p = 3$ kg m/s. Fill in $\dot{x}$ in m/s, $\dot{p}$ in N, and $\mathcal{H}$ in J.
| value | |
|---|---|
| $\dot{x}$ (m/s) | |
| $\dot{p}$ (N) | |
| $\mathcal{H}$ (J) |
A system has $\mathcal{L} = 5\dot{x}^2 - 3x^2$. Find its Hamiltonian as a formula in $p$ and $x$.
Answer:
A unit mass moves in the potential $U = -1/r$ with Hamiltonian $\mathcal{H} = \dfrac{p_r^2}{2} + \dfrac{p_\phi^2}{2r^2} - \dfrac{1}{r}$. At $r = 1$ with $p_\phi = 1$, what is $\dot{p}_r$ (in consistent units)?
Answer: rate of radial momentum
Flight controllers in Houston track a spacecraft at perigee, $6571$ km from the Earth's center, moving at $10.25$ km/s. What is its Hamiltonian per unit mass, in MJ/kg? Use $GM = 3.986 \times 10^5$ km³/s².
Answer: MJ/kg of orbital energy
Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.
A system has $\mathcal{L} = 4\dot{x}^2 - x^2$. Find its Hamiltonian as a formula in $p$ and $x$.
Answer:
You can use Hamilton's equations. Explain to someone why a spacecraft's Hamiltonian tells you whether it will ever come back.
19. Your turn: a particle of mass $2$ kg has $\mathcal{H} = p^2/4 + 3x^2$. Find $\dot{x}$ and $\dot{p}$., step 3
$\dot{p} = -6x$
Hamilton's second equation.