There’s a fascinating analogy between classical mechanics and thermodynamics, which I last talked about in 2012:

• Classical mechanics versus thermodynamics (part 1).

• Classical mechanics versus thermodynamics (part 2).

I’ve figured out more about it, and today I’m giving a talk about it in the physics colloquium at the University of British Columbia. It’s a colloquium talk that’s supposed to be accessible for upper-level undergraduates, so I’ll spend a lot of time reviewing the basics… which is good, I think.

I don’t know if the talk will be recorded, but you can see my slides here, and I’ll base this blog article on them.

### Hamilton’s equations versus the Maxwell relations

Why do Hamilton’s equations in classical mechanics:

look so much like the Maxwell relations in thermodynamics?

William Rowan Hamilton discovered his equations describing classical mechanics in terms of energy around 1827. By 1834 he had also introduced *Hamilton’s principal function*, which I’ll explain later.

James Clerk Maxwell is most famous for his equations describing electromagnetism, perfected in 1865. But he also worked on thermodynamics, and discovered the ‘Maxwell relations’ in 1871.

**Hamilton’s equations** describe how the position and momentum of a particle on a line change with time if we know the energy or **Hamiltonian** :

Two of the **Maxwell relations** connect the volume , entropy , pressure and temperature of a system in thermodynamic equilibrium:

Using this change of variables:

Hamilton’s equations:

become these relations:

These are *almost* like two of the Maxwell relations! But in thermodynamics we always use partial derivatives:

and we say which variables are held constant:

If we write Hamilton’s equations in the same style as the Maxwell relations, they look funny:

Can this possibly be right?

*Yes!* When we work out the analogy between classical mechanics and thermodynamics we’ll see why.

We can get Maxwell’s relations starting from this: the internal energy of a system in equilibrium depends on its entropy and volume

Temperature and pressure are derivatives of

Maxwell’s relations follow from the fact that mixed partial derivatives commute! For example:

To get Hamilton’s equations the same way, we need a function of the particle’s position and time such that

Then we’ll get Hamilton’s equations from the fact that mixed partial derivatives commute!

The trick is to let be ‘Hamilton’s principal function’. So let’s define that. First, the **action** of a particle’s path is

where is the **Lagrangian**:

The particle always takes a path from to that’s a critical point of the action. We can derive Hamilton’s equations from this fact.

Let’s assume this critical point is a *minimum*. Then the least action for any path from to is called **Hamilton’s principal function**

A beautiful fact: if we differentiate Hamilton’s principal function, we get back the energy and momentum :

You can prove these equations using

which implies that

where we integrate along the minimizing path. (It’s not as trivial as it may look, but you can do it.)

Now let’s fix a starting-point for our particle, and say its path ends at any old point . Think of Hamilton’s principal function as a function of just :

Then the particle’s momentum and energy when it reaches are:

This is just what we wanted. Hamilton’s equations now follow from the fact that mixed partial derivatives commute!

So, we have this analogy between classical mechanics and thermodynamics:

Classical mechanics |
Thermodynamics |

action: | internal energy: |

position: | entropy: |

momentum: | temperature: |

time: | volume: |

energy: | pressure: |

What’s really going on in this analogy? It’s not really the matchup of variables that matters most—it’s something a bit more abstract. Let’s dig deeper.

I said we could get Maxwell’s relations from the fact that mixed partials commute, and gave one example:

But to get the other Maxwell relations we need to differentiate other functions—and there are *four* of them!

• : internal energy

• : Helmholtz free energy

• : enthalpy

• : Gibbs free energy

They’re important, but memorizing all the facts about them has annoyed students of thermodynamics for over a century. Is there some other way to get the Maxwell relations? Yes!

In 1958 David Ritchie explained how we can get all four Maxwell relations from one equation! Jaynes also explained how in some unpublished notes for a book. Here’s how it works.

Start here:

Integrate around a loop :

so

This says the **heat** added to a system equals the **work** it does in this cycle

Green’s theorem implies that if a loop encloses a region

Similarly

But we know these are equal!

So, we get

for any region enclosed by a loop. And this in turn implies

In fact, all of Maxwell’s relations are hidden in this one equation!

Mathematicians call something like a **2-form** and write it as . It’s an ‘oriented area element’, so

Now, starting from

We can choose any coordinates and get

(Yes, this is mathematically allowed!)

If we take we get

and thus

We can actually cancel some factors and get one of the Maxwell relations:

(Yes, this is mathematically justified!)

Let’s try another one. If we take we get

Cancelling some factors here we get another of the Maxwell relations:

Other choices of give the other two Maxwell relations.

In short, Maxwell’s relations all follow from one simple equation:

Similarly, Hamilton’s equations follow from this equation:

All calculations work in *exactly* the same way!

By the way, we can get these equations efficiently using the identity and the product rule for :

Now let’s change viewpoint slightly and temporarily treat and as independent from and So, let’s start with with coordinates . Then this 2-form on :

is called a **symplectic structure**.

Choosing the internal energy function , we get this 2-dimensional **surface of equilibrium states**:

Since

we know

for any region in the surface , since on this surface and our old argument applies.

This fact encodes the Maxwell relations! Physically it says: for any cycle on the surface of equilibrium states, the heat flow in equals the work done.

Similarly, in classical mechanics we can start with with coordinates , treating and as independent from and This 2-form on :

is a symplectic structure. Hamilton’s principal function defines a 2d surface

We have for any region in this surface And this fact encodes Hamilton’s equations!

### Summary

**In thermodynamics**, any 2d region in the surface of equilibrium states has

This is equivalent to the Maxwell relations.

**In classical mechanics**, any 2d region in the surface of allowed 4-tuples for particle trajectories through a single point has

This is equivalent to Hamilton’s equations.

These facts generalize when we add extra degrees of freedom, e.g. the particle number in thermodynamics:

or more dimensions of space in classical mechanics:

We get a vector space with a 2-form on it, and a **Lagrangian submanifold** : that is, a *n*-dimensional submanifold such that

for any 2d region

This is more evidence for Alan Weinstein’s “symplectic creed”:

**EVERYTHING IS A LAGRANGIAN SUBMANIFOLD**

As a spinoff, we get two extra Hamilton’s equations for a point particle on a line! They look weird, but I’m sure they’re correct for trajectories that go through a specific arbitrary spacetime point