# 6. Hamilton’s Equations

*Michael Fowler*

## A Dynamical System’s Path in Configuration Space and in State Space

*The story so far*: For a mechanical system with $n$ degrees of freedom, the spatial configuration at
some instant of time is completely specified by a set of $n$ variables we'll call the ${q}_{i}$ ’s.
The $n$ -dimensional ${q}_{i}$ space is (naturally) called *configuration space.*** **It’s like a freeze frame, a
snapshot of the system at a given instant.** **Subsequent time evolution from that state
is uniquely determined if we're also given the initial velocities ${\dot{q}}_{i}$.

The set of ${q}_{i}\text{'s}$ and ${\dot{q}}_{i}\text{'s}$ together define the *state*** **of the system, meaning
both its configuration and how fast it’s changing, therefore fully determining
its future (and past) as well as its present. The $2n$ -dimensional space spanned by $\left({q}_{i},{\dot{q}}_{i}\right)$ is the *state
space*.

The system’s time evolution is along a path in *configuration* space parameterized by the
time $t.$ That, of course, fixes the corresponding path
in *state* space, since differentiating
the functions ${q}_{i}\left(t\right)$ along that path determines the ${\dot{q}}_{i}\left(t\right).$

Trivial one-dimensional examples of these spaces are provided by the one-dimensional simple harmonic oscillator, where configuration space is just the $x$ axis, say, the state space is the $\left(x,\dot{x}\right)$ plane, the system’s time path in the state space is an ellipse.

For a stone falling vertically down, the configuration space is again a line, the path in the $\left(x,\dot{x}\right)$ state space is parabolic, $\dot{x}\propto \sqrt{x}.$

*Exercise*: sketch
the paths in state space for motions of a pendulum, meaning a mass at the end
of a light rod, the other end fixed, but free to rotate in one vertical
plane. Sketch the paths in $\left(\theta ,\dot{\theta}\right)$ coordinates.

In principle, the system’s path through configuration space can always be computed using Newton’s laws of motion, but in practice the math may be intractable. As we’ve shown above, the elegant alternative created by Lagrange and Hamilton is to integrate the Lagrangian

$L\left({q}_{i},{\dot{q}}_{i},t\right)=T\left({q}_{i},{\dot{q}}_{i}\right)-V\left({q}_{i},t\right)$

along different paths in configuration space from a given initial state to a given final state in a given time: as Hamilton proved, the actual path followed by the physical system between the two states in the given time is the one for which this integral, called the action, is minimized. This minimization, using the standard calculus of variations method, generates the Lagrange equations of motion in ${q}_{i},{\dot{q}}_{i}$, and so determines the path.

Notice that specifying both the initial ${q}_{i}$ ’s *and*
the final ${q}_{i}$ ’s fixes $2n$ variables.
That’s all the degrees of freedom there are, so the motion is completely
determined, just as it would be if we’d specified instead the initial ${q}_{i}$ ’s and ${\dot{q}}_{i}$ ’s.

## Phase Space

Newton wrote his equation of motion not as force equals mass
times acceleration, but as force equals *rate
of change of momentum*. Momentum,
mass times velocity, is the natural "quantity of motion" associated
with a time-varying dynamical parameter. It is some measure of how important
that coordinate's motion is to the future dynamical development of the system.

Hamilton recast Lagrange's equations of motion in these more
natural variables $\left({q}_{i},{p}_{i}\right)$,
positions and momenta, instead of $\left({q}_{i},{\dot{q}}_{i}\right)$. The $q$ 's and $p$ 's are
called *phase space*** **coordinates.

So phase space is the same identical underlying space as state space, just with a different set of coordinates. Any particular state of the system can be completely specified either by giving all the variables $\left({q}_{i},{\dot{q}}_{i}\right)$ or by giving the values of all the $\left({q}_{i},{p}_{i}\right)$.

## Going From State Space to Phase Space

Now, the momenta are the *derivatives
of the Lagrangian* with respect to the velocities, ${p}_{i}=\partial L\left({q}_{i},{\dot{q}}_{i}\right)/\partial {\dot{q}}_{i}$.
So, how do we get from a function $L\left({q}_{i},{\dot{q}}_{i}\right)$ of positions and velocities to a function of
positions and the derivatives of that function $L$ with respect to the velocities?

## How It's Done in Thermodynamics

To see how, we'll briefly review a very similar situation in thermodynamics: recall the expression that naturally arises for incremental energy, say for the gas in a heat engine, is

$dE\left(S,V\right)=TdS-PdV,$

where $S$ is the entropy and $T=\partial E/\partial S$ is the temperature. But $S$ is not a handy variable in real life --
temperature $T$ is a lot easier to measure! We need an energy-like function whose
incremental change is some function of $dT,dV$ rather than $dS,dV.$ The early thermodynamicists solved this
problem by introducing the concept of the *free
energy*,

$F=E-TS$

so that $dF=-SdT-PdV.$ This change of function (and variable) was important: the free energy turns out to be more practically relevant than the total energy, it's what's available to do work.

So we've transformed from a function $E\left(S\right)$ to a function $F\left(T\right)=F\left(\partial E/\partial S\right)$ (ignoring $P,V$, which are passive observers here).

## Math Note: the Legendre Transform

The change of variables described above is a standard mathematical routine known as the Legendre transform. Here’s the essence of it, for a function of one variable.

Suppose we have a function $f\left(x\right)$ that is convex, which is math talk for it always curves upwards, meaning ${d}^{2}f\left(x\right)/d{x}^{2}$ is positive. Therefore its slope, we’ll call it

$y=df\left(x\right)/dx$,

is a monotonically increasing function of $x$. For some physics (and math) problems, this slope $y$, rather than the variable $x,$ is the interesting parameter. To shift the focus to $y$, Legendre introduced a new function, $g\left(y\right)$, defined by

$g\left(y\right)=xy-f\left(x\right).$

The function $g\left(y\right)$ is called the *Legendre transform* of the function $f\left(x\right)$.

To see how they relate, we take increments:

$dg\left(y\right)=ydx+xdy-df\left(x\right)=ydx+xdy-ydx=xdy,$

(Looking at the diagram, an increment $dx$ gives a related increment $dy,$ as the slope increases on moving up the curve.)

From this equation,

$x=dg\left(y\right)/dy.$

Comparing this with $y=df\left(x\right)/dx,$ it’s clear that a *second* application of the Legendre transformation would get you
back to the original $f\left(x\right)$. So no information is lost in the Legendre
transformation -- $g\left(y\right)$ in a sense contains $f\left(x\right),$ and vice versa.

## Hamilton's Use of the Legendre Transform

We have the Lagrangian $L\left({q}_{i},{\dot{q}}_{i}\right),$ and Hamilton's insight that these are not the best variables, we need to replace the Lagrangian with a closely related function (like going from the energy to the free energy), that is a function of the ${q}_{i}$ (that's not going to change) and, instead of the ${\dot{q}}_{i}$ 's, the ${p}_{i}$ 's, with ${p}_{i}=\partial L\left({q}_{i},{\dot{q}}_{i}\right)/\partial {\dot{q}}_{i}$. This is exactly a Legendre transform like the one from $f\to g$ discussed above.

The new function is

$H\left({q}_{i},{p}_{i}\right)={\displaystyle \sum _{i=1}^{n}{p}_{i}{\dot{q}}_{i}}-L\left({q}_{i},{\dot{q}}_{i}\right),$

from which

$dH\left({p}_{i},{q}_{i}\right)=-{\displaystyle \sum _{i}{\dot{p}}_{i}d{q}_{i}+{\displaystyle \sum _{i}{\dot{q}}_{i}d{p}_{i}},}$

analogous to $dF=-SdT-PdV$ This new function is of course the *Hamiltonian*.

## Checking that We *Can* Eliminate
the ${\dot{q}}_{i}\text{'s}$

We should check that we *can*
in fact write

$H\left({p}_{i},{q}_{i}\right)={\displaystyle \sum _{i=1}^{n}{p}_{i}{\dot{q}}_{i}}-L\left({q}_{i},{\dot{q}}_{i}\right)$

as a function of just the variables $\left({q}_{i},{p}_{i}\right)$, with all trace of the ${\dot{q}}_{i}$ ’s eliminated. Is this always possible? The answer is yes.

Recall the ${\dot{q}}_{i}$ ’s only appear in the Lagrangian in the kinetic energy term, which has the general form

$T={\displaystyle \sum _{i,j}{a}_{ij}\left({q}_{k}\right){\dot{q}}_{i}{\dot{q}}_{j}}$

where the coefficients ${a}_{ij}$ depend in general on some of the ${q}_{k}$ ’s, but are independent of the velocities, the ${\dot{q}}_{k}$ ’s. Therefore, from the definition of the generalized momenta,

$${p}_{i}=\frac{\partial L}{\partial {\dot{q}}_{i}}={\displaystyle \sum _{j=1}^{n}{a}_{i\text{}j}\left({q}_{k}\right){\dot{q}}_{j}},$$

and we can write this as a vector-matrix equation,

$p=A\dot{q}$.

That is, ${p}_{i}$ is a linear function of the ${\dot{q}}_{j}$ ’s. Hence, the inverse matrix ${A}^{-1}$ will give us ${\dot{q}}_{i}$ as a linear function of the ${p}_{j}\text{'s}$, and then putting this expression for the ${\dot{q}}_{i}$ into the Lagrangian gives the Hamiltonian as a function only of the ${q}_{i}\text{'s}$ and the ${p}_{i}\text{'s}$, that is, the phase space variables.

The matrix $A$ is always invertible because the kinetic energy is positive definite (as is obvious from its Cartesian representation) and a symmetric positive definite matrix has only positive eigenvalues, and therefore is invertible.

## Hamilton’s Equations

Having finally established that we can write, for an incremental change along the dynamical path of the system in phase space,

$dH\left({q}_{i},{p}_{i}\right)=-{\displaystyle \sum _{i}{\dot{p}}_{i}d{q}_{i}+{\displaystyle \sum _{i}{\dot{q}}_{i}d{p}_{i}}}$

we have immediately the so-called *canonical form* of Hamilton’s equations of motion:

$$\begin{array}{l}\frac{\partial H}{\partial {p}_{i}}={\dot{q}}_{i},\\ \frac{\partial H}{\partial {q}_{i}}=-{\dot{p}}_{i}.\end{array}$$

Evidently going from state space to phase space has replaced the second order Euler-Lagrange equations with this equivalent set of pairs of first order equations.

## A Simple Example

For a particle moving in a potential in one dimension, $L\left(q,\dot{q}\right)={\scriptscriptstyle \frac{1}{2}}m{\dot{q}}^{2}-V\left(q\right).$

Hence

$$p=\frac{\partial L}{\partial \dot{q}}=m\dot{q},\text{\hspace{1em}}\dot{q}=\frac{p}{m}.$$

Therefore

$$\begin{array}{c}H=p\dot{q}-L=p\dot{q}-{\scriptscriptstyle \frac{1}{2}}m{\dot{q}}^{2}+V\left(q\right)\\ =\frac{{p}^{2}}{2m}+V\left(q\right).\end{array}$$

(Of course, this is just the total energy, as we expect.)

The Hamiltonian equations of motion are

$$\begin{array}{l}\dot{q}=\frac{\partial H}{\partial p}=\frac{p}{m}\\ \dot{p}=-\frac{\partial H}{\partial q}=-{V}^{\prime}\left(q\right).\end{array}$$

So, as we’ve said, the second order Lagrangian equation of motion is replaced by two first order Hamiltonian equations. Of course, they amount to the same thing (as they must!): differentiating the first equation and substituting in the second gives immediately $-\text{\hspace{0.17em}}{V}^{\prime}\left(q\right)=m\ddot{q},$ that is, $F=ma,$ the original Newtonian equation (which we derived earlier from the Lagrange equations).