The Rise and Fall of Complexity: Coffee, Cream, and the Second Law

Abstract

A cup of coffee with a splash of cream is the most-cited everyday illustration of the second law of thermodynamics. Stir it and the cream disperses; the cup never spontaneously unmixes. But the cup tells a second, subtler story that the bare second law does not. Entropy increases monotonically from the moment the cream lands until the cup is uniform, yet the visible structure does not. It is dull at the start (cream sitting on coffee), intricate in the middle (filaments and tendrils), and dull again at the end (a flat milky brown). This playground simulates the cup with an incompressible Navier-Stokes solver running on the GPU, measures coarse-grained Shannon entropy and Lempel-Ziv apparent complexity from the live concentration field, and plots both on one fixed axis. The point is the contrast: entropy rises and stays risen; apparent complexity rises and then falls.

Background

Entropy is observer-relative

The version of entropy that increases in the second law is not a property of the exact microstate. The exact microstate of the cup, the position and velocity of every molecule, carries the same information-theoretic entropy at every instant if you could track it perfectly; microscopic dynamics are reversible and information-preserving. The entropy that increases is a coarse-grained entropy: you partition the system into macroscopically distinguishable cells and count how many microstates are compatible with what you can actually see. Boltzmann's S = k log W and Gibbs's ensemble entropy are both coarse-grained in this sense.

This is why entropy here is computed by binning the cup into boxes and asking, per box, what fraction of the fluid is cream. A box that is pure coffee or pure cream is informative and low-entropy; a box that is a fifty-fifty mix is maximally uncertain and high-entropy. The box size is a modelling choice, and the entropy depends on it. That dependence is not a defect: it is the content of the claim that entropy is relative to a level of description, made operational. In this playground the box size is a slider, so the claim can be tested by hand.

The coffee automaton

Scott Aaronson, Sean Carroll and Lauren Ouellette made this precise in Quantifying the Rise and Fall of Complexity in Closed Systems (2014). They modelled a two-dimensional fluid of two interacting species, a "coffee automaton", and asked how a measure of apparent complexity behaves over time while entropy increases. Their measure was concrete and unromantic: take a frame, coarse-grain it, and compress it. The compressed size of the coarse-grained image is the apparent complexity. The compressed size of the fine-grained image tracks the entropy.

The finding: with realistic interactions, apparent complexity rises from near zero, reaches an interior maximum, and falls back, while entropy increases monotonically throughout. Without interactions the bump is much weaker. Interactions are what let tendrils form, and tendrils are where the apparent complexity lives.

Carroll has popularised the same picture in From Eternity to Here (2010): the universe began in a low-entropy state and is heading toward high-entropy heat death, and the interesting complex structures, galaxies, stars, planets, life, are a transient feature of the middle of that history rather than its endpoint.

The model

The fluid

The cup is a two-dimensional cross-section, gravity downward, solved with Jos Stam's stable-fluids scheme (Stable Fluids, SIGGRAPH 1999) on a 128 by 128 velocity grid with the cream concentration carried at 256 by 256. Each frame runs, in order:

  1. Advection. The velocity field is traced backwards along itself and resampled. Semi-Lagrangian advection is unconditionally stable, which is what makes real-time fluid possible at all.
  2. Vorticity confinement. Semi-Lagrangian advection numerically damps small-scale rotation. Confinement (Fedkiw, Stam and Jensen 2001) pushes energy back into it, which is what keeps filaments thin instead of letting them blur into a smooth gradient.
  3. Buoyancy. Cream is slightly denser than hot black coffee, roughly 1.01 against 0.99 g/mL, so the body force on a cream-rich cell points down. A layer of cream resting on top is therefore Rayleigh-Taylor unstable, and a fresh pour overturns and falls as a plume with no stirring at all.
  4. Drag and a speed ceiling. Both are numerical necessities rather than physics, and both are discussed under limitations.
  5. Viscous diffusion. An implicit Jacobi solve of (I - nu dt laplacian) u = u0, so the viscosity is unconditionally stable at any value.
  6. Projection. The divergence of the velocity field is computed, a pressure Poisson equation is solved by Jacobi iteration, and the pressure gradient is subtracted. This is the step that makes the fluid incompressible, and it is the step that makes the filaments. A flow that is free to compress does not fold.
  7. Transport. Only now is the cream carried through the flow, with a monotonicity limiter that prevents the interpolation from inventing new maxima or minima.

The walls are sealed on all four sides. That is a modelling choice with a numerical motive: semi-Lagrangian transport with clamped sampling manufactures dye wherever flow crosses an open boundary, and the total cream in the cup is exactly what sets the ceiling of the entropy curve.

The measurement

Roughly five times a second the concentration field is box-averaged down to a 64 by 64 grid and read back. From that field:

  • entropy is the mean binary Shannon entropy H(c) = -[c log2 c + (1 - c) log2 (1 - c)] over coarse-graining boxes, in bits, between 0 and 1;
  • mixedness is the mean of 1 - |2c - 1|, which is 1 at a fifty-fifty mix and 0 at a pure box;
  • apparent complexity is the Lempel-Ziv complexity of the coarse-grained field, quantised to four levels and read row by row, divided by n / log_a(n), the value a random sequence of the same length over the same alphabet would give.

The Lempel-Ziv parse stands in for the paper's gzip. It is deterministic, needs no compression library, and has exact known values on degenerate inputs, which is what lets it be checked rather than trusted: the LZ76 parse of any constant sequence has exactly two phrases and of any alternating sequence exactly three, results that come from Lempel and Ziv (1976) and not from this codebase.

Both quantities are dimensionless and bounded in [0, 1], and both are plotted on one fixed axis with no rescaling.

Validation

A CPU reference implementation of the same scheme runs headlessly, which makes the solver checkable against closed-form fluid dynamics. The calibration panel reports:

  • Projection annihilates a gradient flow. A field u = sin(2 pi m x / n) is pure divergence and carries no rotation, so an exact projection removes all of it. About seven percent survives, which is the error of the discrete Poisson solve: Jacobi converges geometrically and is slowest on the longest wavelengths, and the collocated central-difference gradient and divergence operators are not exact inverses.
  • Advection in a uniform stream. A blob in a constant velocity field translates by exactly u t. The solver gets this to within a tenth of a percent.
  • Taylor-Green decay. The vortex u = (sin kx cos ky, -cos kx sin ky) is a Laplacian eigenmode, so Navier-Stokes decays its amplitude as exp(-2 nu k^2 t) (Taylor and Green 1937). The solver reproduces this to about one percent.

Alongside these, the measurement pipeline is checked against H(1/2) = 1, H(0) = 0, the closed-form mean of the binary entropy over an eight-level ramp, and the two Lempel-Ziv identities.

Results

Three regimes recur, and they are the three moments in the analogy.

  1. Layered. Just after the pour, cream sits above coffee. Almost every coarse box is internally pure, so entropy is near zero. The picture is two flat blocks, which compresses well, so apparent complexity is near its floor.
  2. Swirling. The layer overturns, or the spoon folds it, and the interface is stretched into filaments. Coarse boxes now span the whole range of concentrations and sit beside boxes unlike them. This is the part of the picture a compressor cannot summarise, and apparent complexity peaks here. Entropy is climbing through its mid-range.
  3. Uniform. Eventually every box approaches the same concentration. The picture becomes one flat block, which compresses better than two, so apparent complexity falls below where it started, while entropy saturates near its ceiling.

The ceiling deserves a note. Binary entropy is maximal at c = 1/2, so the cup can only reach a full bit if it is half cream. The cream slider sets that directly, and watching the entropy plateau move as you change it is the clearest way to see that the axis is measuring something real rather than being normalised into place.

The presets move the peak around, and not always in the direction intuition suggests. A thin, low-viscosity fluid with strong vorticity confinement keeps small eddies alive and produces the tallest peak. A thick, high-viscosity fluid couples the whole cup so that it overturns as a single roll: the mixing is fast but coarse, and the complexity peak is early, and collapses hard, because there are no small eddies to sustain fine filaments. Diffusion-only settling never forms strong filaments at all, and its peak has not arrived by the end of the run.

Limitations

  • Two dimensions. There is no vortex stretching, and two-dimensional turbulence has an inverse energy cascade (Kraichnan 1967), so this is qualitatively a different fluid from a real cup. A three-dimensional solve would give finer filaments and probably a later, taller peak.
  • One scalar, not two fluids. Cream and coffee are a single concentration field advected by one velocity field, not two phases with their own equations of state. Real cream is a polydisperse emulsion.
  • Transport is not conservative. Semi-Lagrangian advection does not conserve the quantity it carries, and in a chaotic flow the error does not shrink with more pressure iterations or a finer grid: measured here it wanders over roughly plus or minus fifteen percent. A global mass fixer rescales the field after every step to restore the initial total. The uncorrected drift is reported in the calibration panel rather than hidden, because the mean concentration is exactly what sets the entropy ceiling.
  • Drag and a speed cap are not physics. Vorticity confinement injects energy rather than conserving it, and buoyancy with nothing to balance it accelerates the flow without bound: without these two terms the Courant number reached the hundreds while this was being built, at which point advection stops conserving dye at all. Linear drag stands in for form drag and turbulent dissipation, and it is what sets the pace of the pour.
  • One complexity measure. A different compressor would shift the height and timing of the peak. The existence of an interior peak should be robust; its exact shape is not.
  • The sweep runs on a coarser grid. The parameter sweep and the sensitivity tornado run the same solver headlessly at 20 by 20 rather than 128 by 128, so they should be read for the shape of a trend and not for absolute values.
  • Closed cup. There is no thermal reservoir and no cooling. The cup reaches equilibrium; a real cup also goes cold.

Why it matters

The cup is a small lesson about the arrow of time. The second law guarantees that disorder, properly coarse-grained, increases. It does not guarantee that anything interesting happens along the way, and it certainly does not guarantee that the interesting things last. Complex structure is a feature of the journey between a low-entropy past and a high-entropy future, sustained, where it persists, by a flow of low-entropy energy through an open system. The cup closes and goes uniform. The Earth stays interesting only because the Sun keeps pouring.

References

  • S. Aaronson, S. M. Carroll, L. Ouellette. Quantifying the Rise and Fall of Complexity in Closed Systems. arXiv:1405.6903 (2014).
  • S. M. Carroll. From Eternity to Here: The Quest for the Ultimate Theory of Time. Dutton (2010).
  • J. Stam. Stable Fluids. SIGGRAPH (1999).
  • R. Fedkiw, J. Stam, H. W. Jensen. Visual Simulation of Smoke. SIGGRAPH (2001), for vorticity confinement.
  • G. I. Taylor, A. E. Green. Mechanism of the Production of Small Eddies from Large Ones. Proc. R. Soc. Lond. A (1937).
  • A. Lempel, J. Ziv. On the Complexity of Finite Sequences. IEEE Transactions on Information Theory (1976).
  • F. Kaspar, H. G. Schuster. Easily calculable measure for the complexity of spatiotemporal patterns. Physical Review A (1987).
  • R. H. Kraichnan. Inertial Ranges in Two-Dimensional Turbulence. Physics of Fluids (1967).
  • E. T. Jaynes. Information Theory and Statistical Mechanics. Physical Review (1957).
  • L. Boltzmann. Lectures on Gas Theory (1896 to 1898), for the statistical reading of entropy.