THE GROUND / STRATUM · PATTERN SEAM

A Pile of Sand That Counts the Trees

OBJECT  the abelian sandpile on a grid RULE  a cell with ≥ 4 grains topples one to each neighbour STATUS  theorem (1990); scaling limit (2013)

Pour grains onto a grid. Whenever a square is holding four or more, it topples: it hands one grain to each of its four neighbours, and grains pushed off the edge are gone. Keep going until nothing is over the limit. That childish rule hides an entire arithmetic — a group, a fractal, and a circle packing — and every piece of it is provable, and recomputed here in front of you.

The rule is the whole model. A cell never "holds" four grains; the instant it reaches four it sheds them, one in each direction. A single grain dropped on a tall stack can set off a chain reaction — an avalanche — that races across the grid and dies out. This is the abelian sandpile, introduced as a toy for self-organized criticality by Bak, Tang and Wiesenfeld in 1987 and turned into deep mathematics by Deepak Dhar in 1990. It is one of the most studied objects in statistical physics and combinatorics, and almost none of what it does is obvious.

Start here. Below, a tall pile of grains has already been poured onto the centre square and left to topple flat — the concentric diamond is the stable residue, and it is the first sign that this rule builds structure on its own. The grid's four edges are open, so grains that topple outward fall away into a sink. Click anywhere to drop more and watch a cell let go the instant it hits four; a single added grain can set off a cascade across thousands of cells. Press clear for an empty grid, or let it self-organize to watch the pile drive itself to criticality.

INSTRUMENT I · topple itempty
0 1 2 3 grains (full) click / tap the grid to add grains
grains on grid 0  ·  last avalanche topplings  ·  mean height 0.000

The first miracle: order doesn't matter

When several cells are over the limit at once, which do you topple first? It feels like it should matter — different choices, different cascades. It doesn't. No matter the order you resolve the topplings, you always reach the same stable pile, and every cell topples the same number of times getting there. This is the abelian property, the theorem that gives the model its name (Dhar, 1990). It is why "stabilise the pile" is even a well-defined operation.

Don't take it on faith. The button below takes the current grid, pours an identical fistful of grains onto it, and then stabilises it two completely different ways — once by an avalanche-front queue, once by repeatedly scanning a shuffled list of cells — and checks that the two final piles agree cell for cell.

adds 6000 grains, then compares two toppling orders
abelian check — press the button.

The second miracle: the pile counts trees

Once a pile is stable, every cell holds 0, 1, 2 or 3 grains. Most such patterns are transient — junk states the dynamics drift away from and can never return to. The ones the system keeps revisiting forever are called recurrent. They are the real "memory" of the pile, and here is the astonishing fact: the recurrent configurations form an abelian group under "add the piles and let it topple," and the size of that group is

exactly the number of spanning trees of the grid.

A spanning tree is a way to wire every cell of the grid (plus the sink) into one connected network with no loops. Counting them sounds unrelated to stacking sand — yet they are the same number, by Kirchhoff's matrix-tree theorem: it equals the determinant of the grid's reduced Laplacian. Three utterly different computations, one integer. The instrument checks all three: it builds the Laplacian matrix and takes its exact determinant, and — for grids small enough — it also brute-force enumerates every stable pattern and counts which are recurrent. Watch the count climb to meet the determinant.

INSTRUMENT II · |group| = #spanning trees = det Δ3 × 3
grid =
det Δ  (reduced Laplacian)
spanning trees of the graph
recurrent configs (brute force)

The third miracle: the do-nothing is a fractal

Every group has an identity — the element that changes nothing when you add it. In ordinary arithmetic it's zero, and it's boring. Here it is anything but. The identity of the sandpile group is a specific recurrent pile, and you find it by a standard piece of computational sleight-of-hand: stabilise a grid of all-6s, subtract that from all-6s, and stabilise again. The result acts as zero for the whole group — add it to any recurrent pile and you get that pile back, untouched.

You would expect zero to look like nothing. Instead it looks like this — an intricate, self-similar fractal that no one designed, falling straight out of the toppling rule (its image popularised by Michael Creutz in 1991). It is recomputed live below; the larger sizes take a moment. Then switch the instrument to a single point source: drop a great many grains on one cell of an empty plane and let the avalanche run. The stable pattern is a different fractal — and its structure, proven by recent mathematics, is governed by an Apollonian circle packing, the very object dissected one stratum over.

INSTRUMENT III · the shape it settles intoidentity · 128×128
computing…
size =
0 1 2 3 grains

The point-source picture is not just pretty; it is a frontier of current mathematics. In 2013 Wesley Pegden and Charles Smart proved that as the number of grains grows, this pattern, suitably rescaled, converges to a single limiting shape — the sandpile has a well-defined fractal "continuum limit," characterised as the solution of an elliptic obstacle problem. Then Lionel Levine, Pegden and Smart (2016–2017) identified what organises it: each flat, periodic patch you can see is indexed by an "integer superharmonic matrix," and the space of those matrices is — provably — an Apollonian circle packing. The patch boundaries in the picture are arranged according to that packing. So it is precise to say the sandpile fractal is governed by an Apollonian packing, rather than that the image is literally a packing of circles. Either way, the circles you met in the gasket of integer curvatures are hiding inside a pile of sand.

And the criticality, honestly

The model was born to explain self-organized criticality: drop grains at random and the pile drives itself to a delicate balance where avalanches come in all sizes, with no characteristic scale — a small perturbation can trigger a system-spanning cascade. Press "let it self-organize" in the first instrument and you can watch the mean height climb and settle near its critical value while the avalanche-size histogram fills out a long, heavy tail across orders of magnitude. That much is real and visible. The careful caveat: whether the two-dimensional pile is truly scale-invariant in the strict sense — clean power laws with well-defined exponents — is genuinely subtle. The avalanche statistics carry logarithmic corrections and "multifractal" structure, and the precise exponents have been debated for decades. So the histogram here is shown as what it honestly is: a heavy-tailed distribution spanning many scales, not a fitted power law. The toy that launched a thousand papers is still, in this exact respect, not fully understood.

What is not in doubt is the arithmetic. Topple it any way you like — same pile. Count the stable memories — that's the spanning trees. Find the do-nothing — it's a fractal. This whole world is sitting inside one rule a child could follow, waiting for someone to add the grains.