the Legendre transformation
/ luh-ZHAHNDR /
Suppose you know a smooth convex function of some variable, say the Lagrangian as a function of a velocity q_dot. The Legendre transformation is a change of description that trades that variable for its slope: instead of tracking 'where you are', you track 'how steep the curve is there'. It is the mathematical operation that lets you swap a velocity for a momentum, or an energy that depends on volume for one that depends on pressure, without losing any information.
Precisely, given a function L(q_dot) that is convex in q_dot, define the new variable p = partial L / partial q_dot (the slope) and the transformed function H(p) = p q_dot - L, where q_dot is re-expressed as a function of p by inverting the slope relation. This H is the Legendre transform of L. The construction is symmetric: transforming H back gives L again, and q_dot = partial H / partial p. Convexity is what guarantees the slope relation is invertible, so the transform is single-valued. In mechanics the Legendre transform in the velocities carries the Lagrangian L(q, q_dot, t) to the Hamiltonian H(q, p, t) = sum_i p_i q_dot_i - L.
The same operation appears throughout physics whenever you want to change which quantity is your independent (control) variable. In thermodynamics it turns internal energy U(S, V) into enthalpy H(S, P), Helmholtz free energy F(T, V), and Gibbs free energy G(T, P) -- each Legendre transform swaps a natural variable for its conjugate (S for T, V for P). Recognizing that the Hamiltonian and the thermodynamic potentials are the same kind of object is one of the unifying insights of graduate physics.
For the free particle L = (1/2) m q_dot^2, the momentum is p = partial L / partial q_dot = m q_dot, so q_dot = p/m, and the Legendre transform is H = p q_dot - L = p(p/m) - (1/2) m (p/m)^2 = p^2/(2m) -- the kinetic energy written in terms of momentum instead of velocity.
The Legendre transform of the free-particle Lagrangian is its Hamiltonian, the familiar p^2/(2m).
The transform is only well-behaved when L is convex in the velocities; if L is not convex (or is linear, as for a relativistic massless particle) the slope-to-variable map is not invertible and the naive Legendre transform fails, which is the origin of constrained Hamiltonian systems.