physics2u
Depth
PU-201 / L18 · lecture

The Legendre Transform and the Hamiltonian

~6 min read · Tier toggle changes depth (T1 plain · T2 standard · T3 rigour)

BEFORE YOU START

You should be comfortable with the Euler-Lagrange equations and the definition of the Lagrangian \( L(q, \dot{q}, t) \). Familiarity with partial differentiation and the concept of a total derivative is assumed.

Why this matters

The Hamiltonian provides a dual description of mechanics that is often more powerful than the Lagrangian.

While the Lagrangian formulation relies on generalized coordinates and their velocities, the Hamiltonian formulation replaces velocities with momenta. This shift is not merely algebraic; it reveals the symplectic structure of phase space and establishes the canonical equations of motion. This formalism is the essential bridge to quantum mechanics, where position and momentum become non-commuting operators, and to statistical mechanics, where the distribution of states in phase space is fundamental.

From Velocity to Momentum

In the Lagrangian framework, the state of a system is defined by its position and velocity. However, in many physical problems, momentum is a more natural variable. For example, in electromagnetic fields, the canonical momentum includes the vector potential, whereas the mechanical momentum does not. To transition from the \( (q, \dot{q}) \) description to the \( (q, p) \) description, we need a mathematical tool that allows us to swap the independent variable from velocity to momentum without losing information. This tool is the Legendre transform. It is a general mathematical operation that converts a function of a variable into a function of its conjugate variable, preserving the essential structure of the system while changing the perspective.

The Legendre Transform

The Legendre transform is defined for a function \( L(\dot{q}) \) that is convex with respect to \( \dot{q} \). We define the generalized momentum \( p \) as the partial derivative of the Lagrangian with respect to the generalized velocity:

\[ p = \frac{\partial L}{\partial \dot{q}} \]

Assuming this relationship can be inverted to express \( \dot{q} \) as a function of \( p \), we define the Hamiltonian \( H \) as:

\[ H(q, p, t) = p \dot{q} - L(q, \dot{q}, t) \]

Here, \( \dot{q} \) on the right-hand side is understood to be the function of \( p \) obtained from the inversion of the momentum definition. The term \( p \dot{q} \) has the dimensions of energy, ensuring that \( H \) is also an energy-like quantity. In many standard mechanical systems where the potential energy does not depend on velocity, the Hamiltonian is equal to the total mechanical energy \( T + V \). However, in general, \( H \) is defined by the transform, not by the sum of kinetic and potential energies.

Deriving the Canonical Equations

To see how the dynamics change, we examine the total differential of the Hamiltonian. Since \( H \) is a function of \( q \), \( p \), and \( t \), its total differential is:

\[ dH = \frac{\partial H}{\partial q} dq + \frac{\partial H}{\partial p} dp + \frac{\partial H}{\partial t} dt \]

Alternatively, we can compute \( dH \) using the definition \( H = p \dot{q} - L \). Taking the differential of this expression:

\[ dH = d(p \dot{q}) - dL = \dot{q} dp + p d\dot{q} - \left( \frac{\partial L}{\partial q} dq + \frac{\partial L}{\partial \dot{q}} d\dot{q} + \frac{\partial L}{\partial t} dt \right) \]

Using the definition \( p = \frac{\partial L}{\partial \dot{q}} \), the terms involving \( d\dot{q} \) cancel out (\( p d\dot{q} - p d\dot{q} = 0 \)). We are left with:

\[ dH = \dot{q} dp - \frac{\partial L}{\partial q} dq - \frac{\partial L}{\partial t} dt \]

By comparing the coefficients of \( dq \), \( dp \), and \( dt \) in the two expressions for \( dH \), we obtain the Hamiltonian equations of motion:

\[ \dot{q} = \frac{\partial H}{\partial p}, \quad \dot{p} = -\frac{\partial H}{\partial q}, \quad \frac{\partial H}{\partial t} = -\frac{\partial L}{\partial t} \]

These equations are first-order differential equations, in contrast to the second-order Euler-Lagrange equations. They treat position and momentum symmetrically, highlighting the phase-space structure of mechanics.

Conservation of Energy

The third equation, \( \frac{\partial H}{\partial t} = -\frac{\partial L}{\partial t} \), provides a direct link to energy conservation. If the Lagrangian does not depend explicitly on time (\( \frac{\partial L}{\partial t} = 0 \)), then the Hamiltonian is constant along the trajectory of the system. In such cases, \( H \) is the conserved energy of the system. This is a powerful result because it allows us to identify conserved quantities simply by inspecting the time-dependence of the Lagrangian or Hamiltonian, without solving the equations of motion.

The derivation

◆ DERIVATION EMBED · D-004 · not re-derived here

The Legendre Transform to the Hamiltonian

Derives the Hamiltonian as the Legendre transform of the Lagrangian in the velocities, trading q-dot for conjugate momentum p.

q̇i = ∂H/∂pi,    ṗi = − ∂H/∂qi,    ∂H/∂t = − ∂L/∂t
Open full derivation →
Tier 3 · watch out

A common misconception is that the Hamiltonian is always equal to the total mechanical energy \( T + V \). This is only true if the transformation from generalized coordinates to Cartesian coordinates is time-independent and the potential energy is velocity-independent. In systems with time-dependent constraints or velocity-dependent potentials (like magnetic fields), \( H \) may differ from \( T + V \). Always derive \( H \) using the Legendre transform definition \( H = p \dot{q} - L \) rather than assuming it equals the sum of kinetic and potential energies. C

Worked example

Problem. Consider a particle of mass \( m \) moving in one dimension under the influence of a potential \( V(x) = \frac{1}{2} k x^2 \). The Lagrangian is given by \( L = \frac{1}{2} m \dot{x}^2 - \frac{1}{2} k x^2 \). Find the Hamiltonian and the equations of motion.

  1. Calculate the generalized momentum \( p \): \[ p = \frac{\partial L}{\partial \dot{x}} = m \dot{x} \]
  2. Invert the relationship to find \( \dot{x} \) in terms of \( p \): \[ \dot{x} = \frac{p}{m} \]
  3. Compute the Hamiltonian using \( H = p \dot{x} - L \): \[ H = p \left( \frac{p}{m} \right) - \left( \frac{1}{2} m \left( \frac{p}{m} \right)^2 - \frac{1}{2} k x^2 \right) \] \[ H = \frac{p^2}{m} - \frac{p^2}{2m} + \frac{1}{2} k x^2 = \frac{p^2}{2m} + \frac{1}{2} k x^2 \]
  4. Derive the equations of motion: \[ \dot{x} = \frac{\partial H}{\partial p} = \frac{p}{m} \] \[ \dot{p} = -\frac{\partial H}{\partial x} = -k x \]
\[ H = \frac{p^2}{2m} + \frac{1}{2} k x^2 \]

Units check. The term \( \frac{p^2}{2m} \) has units \( \frac{(\mathrm{kg \cdot m/s})^2}{\mathrm{kg}} = \mathrm{kg \cdot m^2/s^2} = \mathrm{J} \). The term \( \frac{1}{2} k x^2 \) has units \( \frac{\mathrm{N/m} \cdot \mathrm{m}^2}{1} = \mathrm{N \cdot m} = \mathrm{J} \). Both terms are energies, so the Hamiltonian has consistent units of Joules.

CHECK YOURSELF

Three quick tests

  1. What is the primary advantage of the Hamiltonian formulation over the Lagrangian formulation?
    AnswerThe Hamiltonian formulation uses first-order differential equations and treats position and momentum symmetrically, revealing the phase-space structure.
  2. If the Lagrangian \( L \) does not depend explicitly on time, what can be said about the Hamiltonian \( H \)?
    AnswerThe Hamiltonian is conserved along the trajectory, meaning \( \frac{dH}{dt} = 0 \).
  3. Is the Hamiltonian always equal to the total mechanical energy \( T + V \)?
    AnswerNo, it is only equal to \( T + V \) under specific conditions (time-independent transformations and velocity-independent potentials). In general, \( H \) is defined by the Legendre transform.
PROBLEMS

Problem set for PU-201 →

Each derivation in this unit ends with five graded problems with full solutions.

NOTES

Lecture notes drafted with a local model and checked line by line by the editor; every number in the worked example was recomputed.

Derivations cited: D-004 · Threads: force, energy, symmetry