09.04.01 · classical-mech / hamiltonian

Legendre transform — from Lagrangian to Hamiltonian

draft3 tiersLean: nonepending prereqs

Anchor (Master): Arnold, *Mathematical Methods of Classical Mechanics*, 2nd ed. (1989), §13, §14; Marsden-Ratiu, *Mechanics and Symmetry*, Ch. 3.3

Intuition [Beginner]

The Lagrangian describes a mechanical system using two kinds of variables: positions (where things are) and velocities (how fast things move). The Hamiltonian describes the same system using positions and momenta (how hard things would push back if you tried to stop them). The Legendre transform is the mathematical machine that swaps velocity for momentum while preserving all the physics.

Why swap? Velocities are tied to the Lagrangian framework; momenta are the natural variables for the Hamiltonian framework, which leads to quantum mechanics, statistical mechanics, and the geometry of phase space. The Legendre transform is the bridge between these two descriptions of the same physics.

Think of it like a change of currency. A price can be quoted in dollars or in euros — same value, different unit. The Legendre transform is the exchange rate. It takes a function of one variable and produces a function of a different variable, encoding the same information in a new form.

Here is a graphical analogy. Take a smooth, upward-curving (convex) function . For each slope , draw the tangent line to the curve. That tangent line has a -intercept — the height where the tangent line crosses the -axis. The Legendre transform is the negative of that intercept. Equivalently, , evaluated at the whose slope equals .

This is not just algebra. It says: instead of describing the curve by its height at each position , describe it by the tangent-line intercept at each slope . For a convex curve, the mapping from to slope is one-to-one, so no information is lost.

Now apply this to mechanics. The Lagrangian is a function of velocity (at fixed position ). Define the momentum as the "slope" of with respect to :

The Legendre transform gives a new function of instead of :

where on the right is understood as the velocity that corresponds to the given (found by inverting ). This is the Hamiltonian.

A concrete example: a free particle of mass . The Lagrangian is . The slope is , so . The Hamiltonian is . The Legendre transform converts a parabola in into a parabola in — same shape, different variable. Both encode "kinetic energy," but one uses velocity and the other uses momentum.

For a particle in a potential , the Lagrangian is . The slope is still (the potential does not depend on velocity). The Hamiltonian becomes — kinetic plus potential energy, now written in terms of and .

The Legendre transform is invertible. Starting from , you can recover by the same formula run backwards: , with expressed in terms of . No information is lost in the exchange.

Visual [Beginner]

Figure: The graph of is a parabola opening upward. At a particular velocity , the tangent line has slope and -intercept . The Hamiltonian is the negative of this intercept, or equivalently the height of the point on the curve above the intercept. A second tangent line at a different velocity shows a different slope and a different intercept; the family of all tangent lines, indexed by slope, encodes the same parabola as the original graph.

Legendre transform of the free-particle Lagrangian: a convex parabola L(v) = (1/2)mv^2, with tangent lines at two velocities. Each tangent line is labelled by its slope p = mv and its intercept. The Hamiltonian H(p) = p^2/(2m) is the set of intercepts negated, plotted against p.

Worked example [Beginner]

The harmonic oscillator: a mass on a spring with constant . The Lagrangian is

Step 1. Compute the momentum. The slope of with respect to is

This is the familiar definition of momentum for a particle of mass .

Step 2. Invert to find velocity. Solve for in terms of :

Step 3. Compute the Hamiltonian. Apply the Legendre transform formula , substituting :

Simplifying:

This is kinetic energy plus potential energy — the total energy, now expressed as a function of position and momentum . The Legendre transform has converted the Lagrangian (kinetic minus potential, in velocity language) into the Hamiltonian (kinetic plus potential, in momentum language).

Check your understanding [Beginner]

Formal definition [Intermediate+]

Let be an -dimensional configuration manifold with local coordinates . The Lagrangian is a smooth function with coordinates on the tangent bundle.

The conjugate momentum of the -th coordinate is

This defines a map , the fibre Legendre transform, sending where . The map is fibre-preserving: it acts independently on each tangent space , mapping it to the corresponding cotangent space .

The Legendre transform is locally invertible when the Hessian matrix

is non-degenerate (i.e., ). By the inverse function theorem, is then a local diffeomorphism on each fibre. A Lagrangian for which is non-degenerate at every point is called regular; if is a global diffeomorphism, the Lagrangian is hyper-regular.

When is hyper-regular, the inverse map exists globally, and the Hamiltonian is defined by

This is the Legendre transform of along the fibres of . The summation convention applies: .

The physical interpretation is that encodes the same dynamics as but in the "dual" variables on the cotangent bundle — phase space — rather than the tangent-bundle variables . The two descriptions are equivalent whenever the Legendre transform is invertible.

Counterexamples to common slips

  • The momentum is not always . For a charged particle in a magnetic field with , the canonical momentum is , not . The vector potential contributes an extra term. This distinction between canonical momentum and kinetic momentum is central to gauge theories.

  • The Hamiltonian is not always . For a Lagrangian of the standard form with a homogeneous quadratic in , the Legendre transform yields . But if includes terms linear in (as in the electromagnetic example above), or if the kinetic energy is not quadratic (as in relativistic mechanics), then . The Legendre-transform formula is the reliable definition; is a special case.

  • Singular Lagrangians break the construction. If at some , the map is not locally invertible there, and the Hamiltonian cannot be defined by the standard recipe. Gauge theories and the reparametrised relativistic particle have this property. Handling singular Lagrangians requires the Dirac-Bergmann constraint algorithm, which extends the Legendre-transform idea to constrained phase spaces.

Key theorem with proof [Intermediate+]

Theorem (The Legendre transform preserves the time derivative and converts EL equations to Hamilton's equations). Let be a regular Lagrangian with Hamiltonian defined by the Legendre transform. Then:

(i) along any physical trajectory (so is conserved if and only if is time-independent).

(ii) The Euler-Lagrange equations for are equivalent to Hamilton's equations , for .

Proof of (i). The Hamiltonian is where . Differentiate with respect to along a trajectory:

The and terms cancel because . If the trajectory satisfies the Euler-Lagrange equations, , so the and terms also cancel, leaving . In particular, if has no explicit time dependence, and is conserved. If is time-independent, is the conserved energy.

Proof of (ii). Take the partial derivatives of with respect to and , treating as a function of .

First, differentiate with respect to :

The last two terms cancel because , giving

Next, differentiate with respect to :

Again cancels two terms, leaving

Now assume the Euler-Lagrange equations hold: . Along the Legendre-transformed trajectory, , so . By equation (2), , hence . Equation (1) gives . These are Hamilton's equations. The converse follows by running the same algebra in reverse.

Worked example: the relativistic free particle

A free relativistic particle has Lagrangian (one spatial dimension for simplicity, ). The conjugate momentum is

the relativistic momentum, where . Solve for : squaring and using , one finds .

Now compute :

Simplifying the square root and combining:

This is the relativistic energy-momentum relation . The Legendre transform has produced the relativistic energy as a function of momentum — the Hamiltonian for a free relativistic particle.

Exercises [Intermediate+]

Lean formalization [Intermediate+]

lean_status: none. Mathlib has convex analysis (Analysis.Convex.Basic, Analysis.Convex.ConcaveOn) that formalises the Legendre transform of a convex function as , along with cotangent-bundle constructions (Geometry.Manifold.Algebra.SmoothFunctions). What is missing is the fibre Legendre transform on a smooth manifold, the Hessian regularity condition as a hypothesis in a theorem, and the proof that the Euler-Lagrange equations transform into Hamilton's equations under this map. These are the load-bearing prerequisites for a formal account of the Lagrangian-to-Hamiltonian passage.

Advanced results [Master]

The fibre derivative and hyper-regularity

The Legendre transform in mechanics is not the Legendre transform of a single function. It is a fibre derivative: for each base point , the map is the derivative of the restricted function . The fibre Legendre transform is

where is the fibre derivative at . Regularity of means is a local diffeomorphism on each fibre; hyper-regularity means it is a global diffeomorphism.

Hyper-regularity holds for the standard mechanical Lagrangian where is a Riemannian metric on . The fibre derivative is , and the non-degeneracy of makes this invertible: , where is the inverse metric. The Hamiltonian becomes

the metric dual of the kinetic energy plus the potential. The Legendre transform is the musical isomorphism determined by the metric, and its inverse is .

Singular Lagrangians and the Dirac-Bergmann algorithm

When , the fibre Legendre transform maps onto a proper submanifold of — the primary constraint surface for some functions . The Hamiltonian is not uniquely determined on because the map is many-to-one; instead one defines a total Hamiltonian with undetermined multipliers .

Consistency conditions — requiring that the constraints be preserved under the time evolution generated by — produce secondary constraints and may fix the multipliers or generate further constraints iteratively. The algorithm terminates when all constraints are consistent and the multipliers are either fixed or correspond to genuine gauge freedom. The result is a Hamiltonian system on the constrained phase space equipped with the Dirac bracket, a modified Poisson bracket that respects the constraints.

This is the standard route for gauge theories. The electromagnetic Lagrangian in four dimensions has a singular Hessian (the time derivative of does not appear). The Dirac-Bergmann analysis produces the primary constraint (where is the conjugate momentum of ), the secondary Gauss-law constraint , and identifies the gauge freedom as the arbitrariness of .

Finsler generalisation

If the kinetic energy is replaced by a Finsler function — positively homogeneous of degree 1 in and satisfying convexity but not necessarily arising from a Riemannian metric — the fibre derivative still defines a map , but the Hamiltonian is now where is the co-Finsler metric on . The Legendre transform maps the Finsler manifold to the co-Finsler manifold . Hyper-regularity holds for strongly convex Finsler functions. This framework covers Lagrangians with non-quadratic kinetic terms (relativistic particles, certain -adic models) without leaving the Legendre-transform paradigm.

Symplectic geometry of the Legendre transform

The cotangent bundle carries the canonical symplectic form . The Legendre transform pulls back to a 2-form on . For a hyper-regular Lagrangian, is symplectic (closed and non-degenerate), and the Euler-Lagrange flow on is mapped by to the Hamiltonian flow on — the Legendre transform is a symplectomorphism between and . This is the geometric content of the equivalence between Lagrangian and Hamiltonian mechanics: they are the same dynamics on two different but symplectomorphic spaces.

The Legendre transform in thermodynamics

The same mathematical operation appears in thermodynamics 11.01.02 pending. The internal energy is a function of entropy and volume . The Helmholtz free energy is the Legendre transform of with respect to (swapping for temperature ). The enthalpy is the Legendre transform with respect to (swapping for pressure ). The Gibbs free energy is the double Legendre transform. Each thermodynamic potential is adapted to a different set of natural variables, just as the Hamiltonian is adapted to rather than .

Legendre-Fenchel transform and convex analysis

The Legendre transform used in mechanics assumes strict convexity and smoothness. The Legendre-Fenchel transform extends it to arbitrary extended-real-valued functions :

No smoothness or strict convexity is required; the supremum always exists (possibly ). When is and strictly convex, the Legendre-Fenchel transform reduces to the classical Legendre transform because the supremum is attained at the unique stationary point .

Rockafellar 1970 proved that the Legendre-Fenchel transform is an involution on the class of closed (lower semicontinuous) proper convex functions: . The correspondence between a convex function and its conjugate — the subgradient relation — is the foundation of convex duality in optimisation. The mechanical content is that the classical Legendre transform, invertible for regular Lagrangians, sits inside this broader framework as the smooth, strictly convex special case. The Legendre-Fenchel perspective also illuminates why the mechanical Legendre transform works: a regular Lagrangian is strictly convex in (the Hessian is positive-definite), which is exactly the condition guaranteeing that the Legendre-Fenchel transform is single-valued and smooth, reducing to the classical formula.

Synthesis. The Legendre transform is the foundational reason that Lagrangian and Hamiltonian mechanics describe the same physical world in dual variables. The central insight is that the fibre derivative identifies the tangent bundle's Lagrangian symplectic structure with the cotangent bundle's canonical symplectic structure , so the Euler-Lagrange flow and the Hamiltonian flow are conjugate by a symplectomorphism. Putting these together with the Dirac-Bergmann extension to singular Lagrangians, the pattern generalises from regular mechanics to gauge field theories and constrained systems, and appears again in 11.01.02 pending where thermodynamic potentials are Legendre transforms of the internal energy.

This is exactly the duality that the bridge is between mechanics on and on : the Legendre transform identifies with through their shared fibre geometry, and the pattern recurs across classical mechanics 09.04.02 pending, thermodynamics 11.01.02 pending, symplectic geometry 05.00.03, and convex analysis.

The Poincaré-Cartan form and the symplectic structure [Master]

The cotangent bundle carries a distinguished 1-form , the Liouville 1-form (also called the Poincaré-Cartan 1-form), defined in local coordinates by

This form is coordinate-independent: for any diffeomorphism , the induced cotangent map satisfies . The defining property is that evaluates on a tangent vector by contracting the momentum component with the projection to : where is the bundle projection. This intrinsic characterisation makes the unique 1-form on whose fibrewise evaluation reproduces the covector 05.00.03.

The canonical symplectic form on is

The pair is the prototype of a symplectic manifold. In local coordinates has the standard block-matrix representation (up to sign convention), which is manifestly non-degenerate. Closedness is automatic from .

For a hyper-regular Lagrangian , the fibre Legendre transform pulls the Liouville form back to a 1-form on the tangent bundle:

This is the Lagrangian Poincaré-Cartan 1-form — a semi-basic 1-form on (it has no components). Its exterior derivative yields the Lagrangian symplectic form

The non-degeneracy of is equivalent to the regularity of : the lower-right block of in the decomposition is the Hessian , which is non-degenerate if and only if is regular. This matches the condition derived in the Formal definition section: regularity of the Hessian is the requirement for the Legendre transform to be a local diffeomorphism on each fibre.

Theorem (The Legendre transform is a symplectomorphism). If is hyper-regular, then $(\mathbb{F}L)^\omega = \omega_L\omega_L\mathbb{F}L : (TQ, \omega_L) \to (T^Q, \omega)$ is a symplectomorphism.

Proof. Since and , naturality of the exterior derivative gives . Because is a diffeomorphism (hyper-regularity) and is symplectic, inherits both properties: closedness follows from , and non-degeneracy follows because the pullback by a diffeomorphism is injective on each tangent space.

The physical content is that the Euler-Lagrange flow on and the Hamiltonian flow on are conjugate by . For every integral curve of the Euler-Lagrange equations, the curve satisfies Hamilton's equations. Phase-space volume is preserved in both pictures — Liouville's theorem — because symplectic flows preserve the Liouville volume form on a -dimensional phase space. This is the geometric content of the conservation of phase-space density first observed by Liouville (1838) and given its symplectic interpretation by Poincaré (1899).

Proposition (Poincaré-Cartan integral invariant). *Let be a closed curve in and the Hamiltonian flow of . Then*

for all . The circulation of the Liouville form around any closed curve is invariant under Hamiltonian evolution.

Proof. The Hamiltonian flow is symplectic: . Cartan's homotopy formula gives the Lie derivative . By definition of the Hamiltonian vector field, , so . Along a physical trajectory , hence . An exact 1-form integrates to zero over any closed curve, establishing for all .

The Poincaré-Cartan integral invariant is the geometric content of the action principle 09.02.01 pending: the stationary-action condition is the statement that the Poincaré-Cartan integral is stationary under variations of the path. This connection between the variational and the symplectic viewpoints is one of the deepest results in geometric mechanics.

Generating functions and the fibre Legendre transform [Master]

Canonical transformations 09.05.01 pending — symplectomorphisms of — are generated by functions whose type is determined by which variables are treated as independent. The four standard types are related by Legendre transforms of a single underlying generating function.

A canonical transformation preserves the symplectic form: . This is equivalent to the closedness condition . By the Poincaré lemma on a contractible neighbourhood, there exists a function satisfying

Type 1. . Then and . The independent variables are the old and new positions.

Type 2. Legendre-transform in the -slot. Define where is obtained by inverting . Then , so and .

Type 3. Legendre-transform in the -slot: . Then , giving and .

Type 4. Double Legendre transform: . Then .

Each type is a Legendre transform of any other in the appropriate variable pair, provided the corresponding Hessian is non-degenerate. This is the same mathematical operation that converts the Lagrangian to the Hamiltonian — the unifying principle is that a Legendre transform swaps one set of conjugate variables for another while preserving the symplectic content.

A concrete example. The identity transformation , has generating function . The derivatives give and , recovering the identity. The Legendre transform of in the -slot produces , whose derivatives give and , confirming consistency.

The connection to this unit is direct. The fibre Legendre transform is itself a canonical transformation (a symplectomorphism), so it admits a generating function. That generating function is related to the Hamilton principal function of the Hamilton-Jacobi theory 09.04.02 pending: the Hamilton-Jacobi equation is the condition that generates a canonical transformation to constant coordinates.

In field theory the same pattern appears at higher multiplicity. The fibre Legendre transform of a Lagrangian density produces the Hamiltonian density with conjugate momentum , and the generating functional for canonical field transformations is the Legendre transform of the action functional. The DeWitt effective action of quantum field theory is defined as the Legendre transform of the generating functional for connected Green's functions — a pattern that propagates from classical mechanics through every level of theoretical physics.

Full proof set [Master]

Proposition 1 (Involution: the Legendre transform is its own inverse). Let be strictly convex with positive-definite Hessian. Then .

Proof. The Legendre transform is where defines via the inverse function theorem (guaranteed by positive-definiteness of the Hessian). Differentiate with respect to :

since cancels the second and third terms. So — the slope of at is .

Now compute . The Legendre transform of at slope is

where is defined by , that is, is the momentum conjugate to for . But , so and the inversion gives . Substituting:

Hence .

Starting from , the reverse Legendre transform with recovers the original Lagrangian. Exercise 5 in the Intermediate tier verifies this for the free particle; Proposition 1 establishes it for all strictly convex Lagrangians.

Proposition 2 (Hessian duality). Let be regular with Hessian . Then the -Hessian of satisfies

The momentum Hessian of is the matrix inverse of the velocity Hessian of .

Proof. From the key theorem proved above, . Differentiating again with respect to :

The defining relation gives, upon differentiating with respect to (holding fixed):

In matrix form , so and .

For the standard Lagrangian , the Hessian is and the -Hessian of is — the inverse metric. The fibre Legendre transform is the musical isomorphism determined by , and its inverse is the reverse transform. The Hessian duality encodes the fact that the Legendre transform exchanges a Riemannian metric for its dual metric on the cotangent bundle.

Proposition 3 (The energy function is the pullback of the Hamiltonian). Define the energy function by

If is hyper-regular, then .

Proof. By definition with . So

But was evaluated at , and the inverse map recovers the original from . Hence

The energy function is the conserved quantity of the Beltrami identity 09.01.03: when has no explicit time dependence, is constant along the Euler-Lagrange flow. Proposition 3 identifies this constant with the Hamiltonian evaluated on the Legendre-transformed trajectory. The Beltrami identity and Hamiltonian energy conservation are the same statement expressed in different variables.

Connections [Master]

  • Action principle 09.02.01 pending — the Lagrangian that enters the Legendre transform is the same function whose stationary action produces the Euler-Lagrange equations. The Legendre transform does not change the physics; it repackages it.

  • Euler-Lagrange equations 09.02.02 pending — the key theorem proves that the EL equations and Hamilton's equations are equivalent under the Legendre transform. The EL equations are the Lagrangian shadow; Hamilton's equations are the Hamiltonian shadow of the same dynamics.

  • Conservation laws 09.01.03 — the energy function that appears as an intermediate in the Beltrami identity is the Hamiltonian evaluated on shell. Energy conservation is when (hence ) is time-independent.

  • Hamilton's equations 09.04.02 pending — this unit constructs the Hamiltonian and proves the equivalence with the EL equations; the next unit develops the full dynamical theory (Poisson brackets, symplectic structure, integrable systems) built on .

  • Canonical transformations 09.05.01 pending — canonical transformations are symplectomorphisms of . The four standard types of generating function are related to each other by Legendre transforms of the same kind developed here.

  • Thermodynamic potentials 11.01.02 pending — the Helmholtz free energy, enthalpy, and Gibbs free energy are Legendre transforms of the internal energy with respect to and/or . The mathematical operation is identical; only the physical interpretation of the variables changes.

  • Geometric mechanics 09.09.01 pending — the fibre Legendre transform is the bridge between Lagrangian mechanics on the tangent bundle and Hamiltonian mechanics on the cotangent bundle. Its symplectic geometry is the foundation of the geometric mechanics programme.

Historical & philosophical context [Master]

The Legendre transform originates in number theory and geometry, not in physics. Adrien-Marie Legendre introduced it in 1787 in the context of his work on elliptic integrals and the calculus of variations, as a technique for transforming between a function and its dual description via tangent-line intercepts. The core observation — that a smooth convex curve can be described equally well by its points or by its tangent lines — is purely geometric.

William Rowan Hamilton applied this mathematical device to mechanics in his 1834 paper "On a general method in dynamics." Hamilton's insight was that the passage from Lagrangian to Hamiltonian mechanics is exactly the Legendre transform of the Lagrangian with respect to the velocity variables. The result — a first-order system in twice as many variables — was not merely a computational convenience. It revealed phase space as the natural arena for mechanics and made the symplectic structure of dynamics visible for the first time.

Carl Gustav Jacob Jacobi recognised that Hamilton's formulation opened the door to a theory of canonical transformations and a PDE (the Hamilton-Jacobi equation) whose complete solution solves the mechanical problem by quadrature. Jacobi's "Vorlesungen uber Dynamik" (1842, published posthumously in 1866) systematised the Hamiltonian framework and established the Legendre transform as a permanent fixture of analytical mechanics.

The Legendre transform acquired a second, independent life in thermodynamics through the work of Massieu (1869), Gibbs (1876), and Planck (1897), who introduced the thermodynamic potentials (free energies, enthalpy) as Legendre transforms of the internal energy. The recognition that the same mathematical operation underlies both the passage from Lagrangian to Hamiltonian mechanics and the passage from one thermodynamic potential to another is a 20th-century synthesis, articulated in the axiomatic thermodynamics of Callen (1960) and the geometric thermodynamics of Hermann (1973) and Mrugala (1978).

Bibliography [Master]

  • Legendre, A.-M., "Memoire sur l'integration de quelques equations aux differences partielles" (1787).
  • Hamilton, W. R., "On a general method in dynamics," Phil. Trans. Roy. Soc. 124 (1834), 247–308.
  • Jacobi, C. G. J., Vorlesungen uber Dynamik (1866, posthumous).
  • Arnold, V. I., Mathematical Methods of Classical Mechanics, 2nd ed. (Springer GTM 60, 1989), §13–14.
  • Marsden, J. E. & Ratiu, T. S., Introduction to Mechanics and Symmetry, 2nd ed. (Springer TAM 17, 1999), Ch. 3.3.
  • Taylor, J. R., Classical Mechanics (University Science Books, 2005), Ch. 13.1.
  • Landau, L. D. & Lifshitz, E. M., Mechematics, 3rd ed. (Course of Theoretical Physics Vol. 1, Pergamon, 1976), §40.
  • Susskind, L. & Hrabovsky, G., The Theoretical Minimum: Classical Mechanics (Basic Books, 2014), Lecture 8.
  • Goldstein, H., Poole, C. P. & Safko, J., Classical Mechanics, 3rd ed. (Pearson, 2002), Ch. 8.
  • Tong, D., Classical Dynamics (DAMTP Cambridge lecture notes), §4.
  • Callen, H. B., Thermodynamics and an Introduction to Thermostatistics, 2nd ed. (Wiley, 1985), Ch. 5.
  • Abraham, R. & Marsden, J. E., Foundations of Mechanics, 2nd ed. (Addison-Wesley, 1978), §3.5–3.6.
  • Dirac, P. A. M., Lectures on Quantum Mechanics (Yeshiva University, 1964), Ch. 1 (constrained Hamiltonian systems).
  • Hermann, R., Geometry, Physics, and Systems (Marcel Dekker, 1973).
  • Rockafellar, R. T., Convex Analysis (Princeton University Press, 1970), Ch. 12 (Legendre transforms of convex functions).