The Hamiltonian Function
Classical mechanics owns exactly two master functions. The Lagrangian you have already met: feed it a path, integrate, demand stationarity, and the equations of motion fall out. The second — the Hamiltonian — carries identical physical information, yet reorganizes it so radically that whole subjects become visible that the Lagrangian keeps hidden: phase-space geometry, Liouville's incompressible flow, canonical transformations, and eventually the operator that runs the Schrödinger equation. When physicists say "write down the Hamiltonian of the system," they are asking for the one function from which everything else — dynamics, conservation laws, statistical weights , quantum spectra — can be cranked out by differentiation. The construction itself you already own: is precisely the Legendre transform of the previous article, applied in the velocities, with the generalized momenta as the new variables. What this article adds is the meaning of the object that construction produces. lives on phase space, not configuration space; its level sets are the rails that conserved motion rides; its partial derivatives — one per phase-space direction — encode the complete dynamics; and its total time derivative collapses to its explicit time dependence, the cleanest conservation statement in mechanics. We build carefully, assemble the zoo of Hamiltonians you will actually use — oscillator, central force, charged particle — and stop exactly where the dynamics begins: the canonical equations themselves, and the flow they generate, are the story of the companion article Hamilton's Canonical Equations.
- The Hamiltonian is the Legendre transform of the Lagrangian with respect to the generalized velocities: , with re-expressed using .
- It is a function on phase space — the space of coordinates and conjugate momenta — rather than on configuration-velocity space, the natural arena of the Lagrangian.
- Its total time derivative along the motion equals its explicit time dependence, , so is conserved whenever has no explicit time dependence.
- Differentiating generates the dynamics through Hamilton's canonical equations , — first-order ODEs replacing second-order ones.
- Under common conditions (scleronomic constraints, velocity-independent potential) equals the total mechanical energy , but conservation and energy-equality are logically distinct properties.
- Key idea: The Hamiltonian is the Legendre transform of the Lagrangian in the velocities: , evaluated after eliminating in favour of . Its first derivatives reproduce all the dynamics.
The Hamiltonian is the Legendre transform of the Lagrangian in the velocities: , evaluated after eliminating in favour of . Its first derivatives reproduce all the dynamics, and .
Where this lives today
Every quantum mechanics problem begins "the Hamiltonian of the system is…" — canonical quantization takes the classical , promotes the conjugate pair to operators, and the Schrödinger equation does the rest. The electromagnetic Hamiltonian derived above becomes, verbatim, the minimal-coupling operator that underlies atomic spectra in fields, Landau levels, and superconductivity. Statistical mechanics is even more direct: the canonical ensemble weights microstates by , so the partition function — hence all equilibrium thermodynamics — is an integral over the same phase-space landscape whose contours the classical flow rides. Computation completes the circle. Molecular-dynamics codes and solar-system integrators use symplectic algorithms that respect the Hamiltonian structure step by step, keeping energy errors bounded over billions of steps where naive integrators drift. And Hamiltonian Monte Carlo — the workhorse sampler of modern Bayesian statistics — invents a fictitious momentum and flows along level sets of an artificial precisely because contour-riding explores probability landscapes faster than any random walk.
The physical picture
Think of the Lagrangian as living on the space of positions and velocities — mathematicians call it the tangent bundle — and the Hamiltonian as living on the space of positions and momenta, the cotangent bundle: phase space. The Legendre transform is the dictionary between the two. Velocities answer "where is the system heading?"; momenta answer "how hard is it heading there?" — the conjugate quantity that conservation laws actually speak about, as the previous article's momentum zoo made concrete. What does the function look like on its space? For one degree of freedom you can draw it: a landscape over the plane. And here is the picture that organizes everything downstream — when has no explicit time dependence, the motion runs along the contour lines of that landscape. The phase-space velocity vector is the gradient of rotated by ninety degrees: steepest-ascent information, redeployed as flow along level sets, never across them. Energy conservation is not an extra fact to prove; it is the geometry of the flow:
The second thing to hold on to is why the combination rather than anything else. The Legendre transform article proved it: that specific combination is the unique one whose differential contains no — the velocity genuinely drops out, so is a bona fide function of , and its two families of partial derivatives are exactly enough to steer the full flow. One function, slopes, complete dynamics. That economy is what "the Hamiltonian generates time evolution" means — a phrase that survives verbatim into quantum mechanics, where generates the evolution of states through the Schrödinger equation.
Building the function
Assemble the construction in three deliberate moves — each inherited from a previous article, now snapped together. Starting from a Lagrangian with an invertible velocity Hessian, define the conjugate momenta, then trade:
where: — the Hamiltonian, a function on the -dimensional phase space plus time; the bar insists every velocity has been eliminated via the inverted momentum map. The three moves: differentiate to get the momenta (Generalized Momenta), check the Hessian so the map inverts (Legendre Transformation), then substitute until no survives. Skip the third and you have nothing: a mixed-variable expression with no phase-space meaning. What makes definition (1) worth the ceremony is its differential. As established in the Legendre article, the contributions cancel identically, leaving
where: the entered through the Euler–Lagrange equation — this is the differential on solutions. Read the coefficients and the entire dynamics appears:
where: the first pair are Hamilton's canonical equations — first-order equations replacing the second-order Euler–Lagrange equations. Note the antisymmetry: coordinate rates come from momentum-slopes with a plus, momentum rates from coordinate-slopes with a minus. That single sign is the ninety-degree rotation of the hero figure, and the germ of the entire symplectic structure. We use equations (3) here only to certify that contains the dynamics; their consequences — flow, phase portraits, Poisson brackets, Liouville — are the dedicated business of Hamilton's Canonical Equations.
The goal is to certify, in one self-contained pass, that the function defined in (1) steers the complete motion: both halves of (3), with their asymmetric signs, from nothing but the definition and the Euler–Lagrange equations. The strategy is the Legendre differential with the dynamics fed in at the single point where physics is needed. Keep the two inputs distinct as you read — one identity is structural (true off-shell, from the transform), one is dynamical (true on solutions only); conflating them is the standard source of sign errors in this derivation.
Step 1. Differentiate the definition treating all of as independent for now:
Step 2. Apply the structural input: the momentum definition kills both packets exactly. What survives shows depends on alone — the transform has done its job before any equation of motion was mentioned. Why this half is called structural: it holds for any curve in phase space, physical or not. It already yields : the momentum-slope of H recovers the velocity that momentum replaced.
Step 3. Apply the dynamical input: on actual solutions the Euler–Lagrange equation gives (the momentum form derived in Generalized Momenta). Substituting,
Why the minus sign lands on the coordinate side: the Lagrangian's coordinate-slope is a force, and force drains or feeds momentum; the transform hands that role to H with its sign flipped, because L enters the definition of H negatively.
Step 4. Read off the coefficients of the independent differentials , , — equations (3) in full. Two remarks close the loop. First, the count: one scalar function on phase space determines all rates; no further input exists or is needed. Second, the boundary of this article: what these equations do — conserve volume, generate flows, organize into brackets — begins in Hamilton's Canonical Equations. Verified: matches Goldstein §8.1 and Landau–Lifshitz §40; for the pair (3) reads , , which recombine to Newton's .
The evolution of H itself
Chain-rule along a trajectory and feed in (3): the phase-space terms cancel in pairs, leaving the identity that governs conservation:
where: — the rate of change along the motion; — the explicit time dependence at a frozen phase-space point. The theorem: they coincide. So a Hamiltonian with no explicit clock is a constant of the motion, whatever it is made of — and whether that conserved number is the mechanical energy is a logically separate question, answered condition by condition in Hamiltonian as Total Energy. Keep the two properties (conserved; equal to energy) in separate mental boxes: systems exist with either one and not the other.
The zoo: Hamiltonians you will actually use
Fluency in Hamiltonian mechanics is mostly fluency in reading these five off without hesitation. Each follows from definition (1) applied to the corresponding Lagrangian; the middle column is the momentum map to invert.
| system | momenta | Hamiltonian |
|---|---|---|
| particle in a potential | ||
| simple harmonic oscillator | ||
| planar central force | , | |
| charge in an EM field | ||
| relativistic free particle |
Two of these deserve their construction in full — the oscillator because it is the template for every quadratic problem in physics, and the electromagnetic charge because it is the template for every gauge structure in physics.
Go deeper · Derivation B · 1 minThe Hamiltonian of the simple harmonic oscillator, and its phase ellipse
We are constructing for the mass-spring system from scratch and extracting the geometry of its level sets — the ellipses that make the oscillator the standard portrait of phase space. The strategy is definition (1) executed literally, then a reading of as a conic. Nothing here is hard; the value is seeing the machine run once end to end on the system every other field of physics borrows.
Step 1. Lagrangian and momentum: , so and the Hessian is — invertible, .
Step 2. Transform: , giving
Why this is also T plus V: the Lagrangian is quadratic-kinetic with a velocity-independent potential — exactly the conditions under which the transform returns the energy, per the companion energy article.
Step 3. Read the level sets. is : an ellipse with semi-axes and . No explicit appears, so by (4) each trajectory is confined to its ellipse forever — the contour-riding of the hero figure, now exact.
Step 4. Extract one more number for later chapters: the area enclosed is — energy over frequency, the action variable of the action-angle formalism, and (times ) the semiclassical count of quantum states. The oscillator's phase ellipse is the seed of all of it. Verified: equations (3) give , , hence — the correct oscillator dynamics; semi-axes and area recomputed in Worked Example 1; matches Goldstein §8.2.
Go deeper · Derivation C · 1 minThe Hamiltonian of a charged particle in an electromagnetic field
The goal is the Hamiltonian behind minimal coupling — the structure that classical mechanics bequeaths to the Schrödinger equation and to all of quantum field theory. The strategy: start from the velocity-dependent Lagrangian (built in Velocity-Dependent Potentials), use the canonical momentum computed in Generalized Momenta, and transform. Watch what the potentials do: never adds energy — it shifts the momentum inside the square — while adds energy directly. Confusing those two roles produces Hamiltonians that are dimensionally fine and physically wrong.
Step 1. Inputs: , with canonical momentum . Invert the (trivially invertible) map: .
Step 2. Assemble and substitute:
Step 3. Collect: the first and third terms combine to , and subtracting the half leaves
Why the vector potential sits inside the square: is just — the kinetic momentum. The Hamiltonian is the plain kinetic energy plus electric potential energy; the magnetic field, which does no work, contributes no energy term and instead deforms the geometry of phase space through the momentum shift.
Step 4. Sanity-read the value: on solutions — numerically the energy, even though the function of looks nothing like a textbook . With static potentials nothing depends explicitly on , so this energy is conserved: the magnetic force, forever perpendicular to the velocity, never changes the speed. Verified: expanding equations (3) for this H reproduces the Lorentz force (Goldstein §8.1); setting recovers the free Hamiltonian; the operator version is the magnetic Schrödinger Hamiltonian.
Limiting cases
| Case | Result | Meaning |
|---|---|---|
| quadratic , velocity-independent , scleronomic | the familiar energy reading — special case, not definition | |
| conserved , whatever its relation to energy | ||
| electromagnetic structure switches off smoothly | ||
| limit of | relativistic H contains the Newtonian one plus rest energy | |
| one degree of freedom, conserved | orbits = level curves of | the phase portrait is a contour map |
| degenerate Hessian | transform fails | no by this route; constrained (Dirac) formalism |
Worked examples
1 · Oscillator: from initial data to the phase ellipse (confidence builder)
A block of mass on a spring with is released at with velocity . Find , and the semi-axes and area of its phase-space orbit.
Step 1. Parameters: . Initial momentum: .
Step 2. Evaluate the Hamiltonian at the initial point: . No explicit time dependence, so this number is locked in for the whole motion.
Step 3. Semi-axes of the level ellipse : and . Check the consistency: the block reaches exactly when — all potential — and crosses with — all kinetic.
Step 4. Enclosed area: . Cross-check against the formula from the derivation: ✓. That area — an action — is the quantity adiabatic invariance preserves and quantum mechanics ultimately chops into units of .
2 · Satellite: a two-momentum Hamiltonian evaluated on orbit (exam level)
A satellite circles Earth () at . Using the central-force Hamiltonian , evaluate both momenta and , and interpret the sign.
Step 1. Circular-orbit speed from gravity as centripetal force: .
Step 2. The momenta. Radial: circular orbit means , so . Angular: — conserved, since is cyclic in .
Step 3. Kinetic piece from the momenta: — which is indeed ✓.
Step 4. Potential piece: . Total: . The value is negative — the signature of a bound orbit — and equals exactly , the virial theorem's fingerprint for inverse-square forces. One function, evaluated once, has told us the orbit is bound, how tightly, and which momentum is banked as a constant: that is the Hamiltonian working as an instrument rather than a formality.
Origins · 1 minWilliam Rowan Hamilton and how this was discovered
Hamilton was appointed Andrews Professor of Astronomy and Royal Astronomer of Ireland at twenty-two, while still an undergraduate. His optics — a single "characteristic function" from which every ray property follows by differentiation — was reengineered in 1834–35 into dynamics: one function on phase space steering all motion through paired first-order equations. Jacobi sharpened the machinery within a decade, but the audacious idea — replace forces with the geometry of a generating function — is Hamilton's. He spent his later years on quaternions, carving into Broom Bridge in 1843; posterity kept both gifts, using his quaternions to spin spacecraft and his Hamiltonian, promoted to an operator, to run the entire quantum theory. He reportedly considered the optical–mechanical analogy his finest work — a judgment quantum mechanics vindicated a century on.
Going further
References. Goldstein, Poole & Safko, Classical Mechanics, 3rd ed., Ch. 8 · Landau & Lifshitz, Mechanics, 3rd ed., §40 · Morin, Introduction to Classical Mechanics, Ch. 15 · Taylor, Classical Mechanics, Ch. 13 · Arnold, Mathematical Methods of Classical Mechanics, Ch. 3
Provenance. Definitions and derivations follow Goldstein §8.1–8.2, Landau & Lifshitz §40, Morin Ch. 15, and Taylor Ch. 13. A verifier should: (1) reconfirm the Legendre cancellation in the differential of ; (2) recompute via Euler's theorem on homogeneous functions; (3) check the SHO Hamiltonian yields and elliptical orbits; (4) verify the EM Hamiltonian equals the kinetic energy . Numerical statements (period , ) are standard textbook results. Worked-example numbers on this page (oscillator , ellipse , area ; satellite , , ) are illustrative arithmetic recomputed from the boxed formulas.
Builds on: Legendre Transformation · Generalized Momenta Leads to: Hamilton's Canonical Equations · Hamiltonian as Total Energy · Phase Space · Equivalence of Lagrangian and Hamiltonian Formulations
If H and L contain the same information, why maintain both?
Because each exposes structure the other buries. The Lagrangian is built for covariance and symmetry arguments: it is a scalar under coordinate changes, makes Noether's theorem one line, and generalizes frictionlessly to field theory. The Hamiltonian is built for state-space structure: first-order flow, conserved phase volume, canonical transformations, action-angle variables, perturbation theory, and the direct bridges to statistical mechanics (through ) and quantum mechanics (through ). Working physicists translate constantly — derive from symmetry, transform to to compute or quantize. The dictionary being an involution (see Legendre Transformation) is what makes the double bookkeeping safe.
Why must H never be written as a function of velocities?
Because every downstream operation differentiates with respect to its declared variables. The canonical equations read slopes of at fixed or fixed ; if a velocity hides inside, those partial derivatives silently pick up wrong contributions and the generated dynamics is wrong — not approximately, but structurally. The differential identity (2) that guarantees has no component is earned by completing the elimination; an uneliminated has not paid for it. A practical audit: scan your final ; if any symbol carries an overdot, the Legendre transform is unfinished.
Is the Hamiltonian unique for a given system?
No — and the freedom is useful. Upstream, the Lagrangian itself is defined only up to a total time derivative ; different gauge choices for (or for in electromagnetism) yield different canonical momenta and different-looking Hamiltonians for identical physics. Downstream, canonical transformations reshuffle wholesale, often to make trivial — that is the entire strategy of action-angle variables and Hamilton–Jacobi theory. What is invariant is not the formula for but the flow it generates and the values of gauge-invariant observables along it.
What does it mean, precisely, that H generates time translation?
Compare with an easier statement: momentum generates space translation, in the sense that 's conjugate role produces shifts of . The canonical equations say the same about and time: the instantaneous change of any phase-space function along the motion is assembled entirely from 's slopes — in bracket notation (developed in the canonical-equations article), . Evolving by is applying an infinitesimal transformation whose generator is , exactly as rotating by applies one generated by angular momentum. Quantum mechanics preserves the statement word for word, swapping brackets for commutators: .
Can a dissipative system have a Hamiltonian?
Not a standard one on the physical variables. Friction breaks the two pillars simultaneously: energy drains ( along trajectories would decrease) and phase-space volume contracts (trajectories spiral onto attractors), while any Hamiltonian flow conserves both its -level structure and volume. Workarounds exist and are instructive — time-dependent Hamiltonians like (Caldirola–Kanai) reproduce damped-oscillator trajectories at the cost of an explicitly time-dependent, non-energy ; embedding the system in a larger Hamiltonian bath (system plus environment) is the honest route and the starting point of open-quantum-systems theory. For genuinely dissipative classical modelling, the Lagrangian side offers the Rayleigh dissipation function instead.
What is the relation between H and the energy function h(q, q̇, t) from the Lagrangian chapter?
They are the same physical quantity wearing different variables. The energy function (Jacobi integral) lives on the Lagrangian side, as a function of ; the Hamiltonian is pushed through the momentum dictionary to . Values agree at corresponding points; conservation statements agree ( mirrors equation (4)). What differs is power: only in the variables do the derivatives of the function generate the motion. The full Lagrangian-side story is The Energy Function and Jacobi Integral; the question of when either equals is Hamiltonian as Total Energy.
Why do the two canonical equations carry opposite signs?
The asymmetry is the geometry of the hero figure. If both equations carried plus signs the flow would be itself — trajectories would climb the landscape, would grow monotonically, and nothing would be conserved. The minus sign rotates the gradient by ninety degrees instead: is perpendicular to , so the flow hugs contours and is constant automatically. That rotation matrix is the symplectic form in embryo; its consequences — area preservation, Liouville's theorem, the bracket algebra — are the substance of the canonical-equations article.
Does every Lagrangian system possess a Hamiltonian?
Every one whose velocity Hessian is invertible — which covers all standard mechanical systems, since positive-definite kinetic energy guarantees it. The exceptions are the degenerate Lagrangians flagged in the Legendre article: gauge theories, where some momenta come out as fixed functions of the coordinates (constraints) and velocities cannot be fully eliminated. There the naive transform stalls and the Dirac–Bergmann constrained-Hamiltonian formalism takes over, producing a Hamiltonian on the constraint surface plus generators of gauge transformations. So the honest statement: every regular Lagrangian has a unique Hamiltonian by (1); singular ones have a richer, still-Hamiltonian structure that costs more machinery.