HomeArticlesThermodynamics

Maxwell's Demon: How Information Rescues the Second Law

A tiny demon sorting fast molecules from slow ones seems to build order from nothing — until you pay for its memory, and the books balance again.

mysimulator teamUpdated June 2026≈ 8 min read▶ Open the simulation

A thought experiment designed to break a law

James Clerk Maxwell proposed his demon in 1867 as a deliberate attack on the second law of thermodynamics, which says that the entropy of an isolated system never decreases. Picture a box of gas at uniform temperature, split into two halves by a wall with a tiny trapdoor, and a demon watching the molecules approach the door from both sides. The demon opens the door only to let fast-moving molecules pass from the left into the right, and only to let slow-moving molecules pass from the right into the left. After enough time, the right side is noticeably hotter and the left side noticeably colder — heat has apparently flowed from cold to hot, and a temperature difference has appeared spontaneously, which is exactly what the second law forbids in an isolated system.

The trapdoor itself can be built to require essentially zero energy to operate — a frictionless, massless flap. So where does the puzzle actually break down? Maxwell's own answer was that the demon's "very delicate" ability to observe and decide is doing all the work, but for over a century nobody could pin down exactly what physical cost that observation and decision entailed, or why it should be enough to save the second law.

live demo · a population of molecules sorted fast from slow through a gate● LIVE

Szilard's engine and the search for the cost

Leo Szilard simplified the puzzle in 1929 to its essence: a single molecule in a box, a demon that measures which half the molecule is in, and a piston that then extracts k_BT ln(2) of work from that one bit of information by letting the molecule push the piston as the partition is withdrawn on the correct side. Szilard argued that the act of measurement itself must cost at least that much entropy to perform, which would exactly cancel the work extracted. For decades this was the accepted resolution, and it turns out to be subtly wrong: it is possible, in principle, to measure a system's state without paying any thermodynamic cost at all, as long as the measuring device can end the process in a state that still reflects a record of the outcome.

Landauer's principle: forgetting is what costs you

The real resolution, worked out by Rolf Landauer in 1961 and clarified by Charles Bennett in the 1980s, is that the expensive step is not measuring or remembering — it is forgetting. The demon's memory is a physical system with a finite number of possible states, and to run its sorting cycle indefinitely, the demon must periodically reset that memory back to a known, blank state so it can record the next observation. Erasing a bit of memory is a logically irreversible operation: many possible prior memory states (0 or 1) are mapped onto the same final state (say, always 0), and that many-to-one compression of possibilities must, by the second law applied to the demon-plus-environment system, be accompanied by a corresponding release of heat into the environment:

Landauer's principle:

  erasing 1 bit of memory  ->  releases at least  k_B * T * ln(2)  of heat
                                (k_B = Boltzmann constant, T = temperature)

per sorting cycle:
  entropy the demon removes from the gas       <=  k_B * ln(2)  per bit measured
  entropy released by erasing the memory bit    >=  k_B * ln(2)  per bit erased

  total entropy (gas + demon's memory)  never decreases

Because the entropy released by erasure is always at least as large as the entropy the demon manages to remove from the gas, the second law survives once you include the demon's memory as part of the system. A demon with infinite, never-erased memory could in principle keep sorting forever without paying any entropy cost — but then it is not really an isolated cyclic engine any more, it is simply accumulating an ever-growing record, and that record itself is a physical entropy sink that has to be accounted for somewhere.

From thought experiment to laboratory result

What began as a purely conceptual puzzle is now directly testable. Experiments using single electrons on a chip, trapped colloidal particles under a microscope, and photons in an optical cavity have all built small feedback-controlled "demons" that measure a system's fluctuating state and apply a targeted intervention to extract more work than a passive process could — and every one of these experiments has measured the corresponding Landauer erasure cost in the controller's memory, confirming the bound to good precision. The result is now a cornerstone of the field of information thermodynamics, which treats information itself as a thermodynamic quantity on the same footing as heat and work, with real consequences for the fundamental energy cost of computation.

Frequently asked questions

Does Maxwell's demon actually violate the second law of thermodynamics?

No, once the demon's own physical memory is included in the accounting. The demon lowers the gas's entropy by sorting molecules, but it must record which molecule went where, and erasing that memory to reset for the next measurement costs at least k_B T ln(2) of entropy per bit, by Landauer's principle. That erasure cost equals or exceeds the entropy the demon removed from the gas, so total entropy never decreases.

What is Landauer's principle in simple terms?

Landauer's principle states that erasing one bit of information in any physical memory — not copying it, not moving it, but irreversibly resetting it to a known state — must release at least k_B T ln(2) of heat into the environment. It connects information theory directly to thermodynamics: forgetting has an unavoidable minimum energy cost, even though remembering does not.

Has Maxwell's demon been built in a real experiment?

Yes — several groups have built small-scale physical analogues, using single electrons, trapped colloidal particles, or photons, where a feedback controller measures the system's state and applies a targeted intervention to extract work, exactly as the demon does conceptually. These experiments have directly measured the Landauer erasure cost and confirmed that total entropy production, demon plus system plus memory, obeys the second law.

Try it live

Everything above runs in your browser — open Maxwell's Demon and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Maxwell's Demon simulation

What did you find?

Add reproduction steps (optional)