# research/sandpiles

The verified mathematics behind the instrument **Sandpiles, as Percussion**
(`/instruments/sandpiles/`, ledger P10 #5).

The abelian sandpile (Bak–Tang–Wiesenfeld 1987) on an N×N square grid: a site with
≥ 4 grains topples, one grain to each orthogonal neighbour; boundary grains leave
(the sink). The instrument plays each toppling as a strike and each avalanche as a
wave-by-wave drum fill. That can be an *honest* instrument only because the avalanche
— and so its rhythm — is a property of the pile and not of the order you topple in.

## Files

- **`engine.mjs`** — the from-scratch engine the page mirrors: `stabilize` (three
  toppling-order policies: parallel `wave`, row-major `seq`, uniformly `random`),
  the group add `⊕`, the `identity` element, and `drive` (record avalanche sizes
  while adding grains).
- **`verify.mjs`** — proves the facts the instrument makes audible. `node research/sandpiles/verify.mjs`.
- **`verify-page.mjs`** — loads the built page in a real browser and asserts the
  same engine drives the UI. `npm run build && node research/sandpiles/verify-page.mjs`.

## What is proved (all 11 ✓)

1. **The abelian property (Dhar 1990)** — final grid + full odometer + total topples
   are identical across `wave`, `seq`, and 4 random orders, on 200 random configs
   (N = 3..8). *The load-bearing truth.*
2. Avalanche size = Σ odometer; `⊕` is commutative.
3. **The identity element** e = stabilize(6·all − stabilize(6·all)) (Creutz 1991):
   stable, idempotent, fixes the maximal recurrent config, for N = 4, 6, 8, 12; the
   non-trivial fractal on 16×16.
4. **Self-organised criticality** — a 40×40 grid driven to stationarity gives
   avalanche sizes with no characteristic scale (std/mean ≈ 2.1) and a near-straight
   log–log survival line.
5. A **landmark avalanche** (centre grain on flat-3 7×7 → 84 topplings) reproduces
   exactly under two orders.

## The honest caveat

The size distribution is a power law, but the precise exponent is subtle and
debated for the 2-D ASM (multifractal; strong finite-size effects). The instrument
reports the slope of *your* run descriptively, never as a universal constant. What
is exact is the order-independence — which is what the honesty of the rhythm rests on.

## Sources

- P. Bak, C. Tang, K. Wiesenfeld, *Phys. Rev. Lett.* 59 (1987) 381.
- D. Dhar, *Phys. Rev. Lett.* 64 (1990) 1613 — abelian property, odometer, group.
- M. Creutz, *Comput. Phys.* 5 (1991) 198 — the identity as a fractal.
- L. Levine, J. Propp, "What is… a sandpile?," *Notices AMS* 57 (2010) 976.
