Maxwell's Demon

In 1867, James Clerk Maxwell — the man who had just united electricity, magnetism and light — wrote a letter to his friend Peter Tait containing a small, polite act of sabotage against all of thermodynamics. Imagine, he said, "a being whose faculties are so sharpened" that it can watch individual molecules. Give this being a box of gas divided into two chambers by a wall, with one tiny trapdoor. The being — later nicknamed the demon — does nothing but open and shut the door. Yet with that alone, Maxwell argued, it could do something the laws of physics say is impossible: make heat flow the wrong way, without doing any work. The puzzle he set that day took physics more than a century to answer — and the answer, when it finally came, was found not by physicists studying steam engines but by computer scientists studying memory.

The sorting trick

Recall what temperature really is: the molecules of a warm gas are not all alike. At any one temperature they move with a whole spread of speeds — some sluggish, some frantic — and "hotter" just means the whole distribution shifts fastward. Both chambers start at the same temperature: each holds the same mixture of fast and slow molecules.

The demon's scheme is childishly simple. It sits at the trapdoor and watches molecules approach:

That's the whole algorithm. Molecule by molecule, the fast ones accumulate on the right and the slow ones on the left. The right chamber heats up; the left chamber cools down. A temperature difference has been conjured out of nothing: the door can be made frictionless and essentially massless, so the demon does no work worth mentioning. It never pushes a molecule — it only chooses.

Why this is a scandal

The second law of thermodynamics says heat never flows, on its own, from cold to hot; equivalently, the entropy of an isolated system never decreases. In the language of microstates and macrostates, the demon has taken the gas from the enormous "mixed" macrostate to the far smaller "sorted" macrostate — it has lowered the entropy of the gas — while apparently paying nothing anywhere else. That is precisely what the second law forbids.

Take the last point seriously and the consequences are spectacular. A working demon is a licence for perpetual motion of the second kind: not energy from nowhere (energy is conserved throughout — the demon never breaks the first law), but limitless useful work squeezed from the random jiggling of ordinary matter. Bolt a demon to a ship's hull and it could sail forever, powered by nothing but the warmth of the ocean, leaving a trail of ice cubes behind it. Every power station on Earth would be obsolete. Physicists were confident this had to be impossible — the second law is the most battle-tested law in physics — but saying "that can't be right" is not the same as finding the flaw. Where, exactly, does the demon's scheme break down?

A century of attempted exorcisms

For over a hundred years, physicists tried to exorcise the demon — and every exorcism taught us something, while none quite finished the job.

The cliffhanger: check the demon's notebook

Here is the clue the century of exorcisms kept circling. To play its game, the demon must, for each molecule, know something — fast or slow? left or right? Every decision leaves a record: a changed brain cell, a flipped switch, a mark in a notebook. Sort n molecules and the demon has accumulated n bits of information about the gas that it did not have before. The gas gets more ordered; the demon's memory gets more full. And a memory is a physical thing. What happens when the notebook runs out — when the demon must wipe it clean to keep going? Does resetting a memory have an unavoidable thermodynamic price?

It does — and that price is exactly what rescues the second law. But to state it precisely you need the physics of information itself: what a bit physically is, and what erasing one unavoidably costs. That machinery is built in the reversible-computing course, where the demon is finally exorcised — by Landauer's principle and Bennett's accounting of the demon's memory. For now, savour the twist: the most famous paradox in thermodynamics is not really about heat at all. It is about forgetting.

Yes — and this century, several have been. In 2010, a Tokyo team (Toyabe and colleagues) watched a tiny bead jiggling in a fluid and, each time thermal noise happened to kick it "uphill", quickly adjusted an electric field to stop it sliding back — a feedback demon that converted information from its camera into stored energy, at up to about 28% of the Szilard bound. In 2016, physicists in Finland built a single-electron demon out of nanoscale circuits: it watches one electron and flicks a gate voltage in response, measurably cooling one part of the circuit while its own memory-keeping electronics warm up another. These "information engines" are wonderful precisely because they don't break the second law: every one of them turns measured information into work, and every one of them pays for it in the bookkeeping of its records — exactly as the modern resolution predicts. The demon is real; it just has to pay its bills.

A common shortcut: "the second law is only statistical, so a small enough machine slips beneath it." Half right, dangerously wrong. Fluctuations do momentarily concentrate energy — a pressure difference flickers into being across any small hole all the time. The mistake is thinking a tiny machine can harvest those flukes systematically. Smoluchowski's argument closes the door: any mindless contraption small enough to respond to single molecules — a trapdoor, a ratchet and pawl, a one-way valve — is small enough to be shaken by the same thermal storm, and its own random misfirings give back everything the flukes provide. On average, nothing is gained. Many tiny ratchets don't add up to one working demon; they add up to an expensive way of doing nothing. What a fluctuation-harvester genuinely needs is what Maxwell's demon has and a trapdoor lacks — memory — and memory is precisely where the second law collects its fee.