# Pi out of the stack An early write-up of this work had a section titled "Pi" that ended in defeat: pi was hunted inside a single carpet's area and never found. The instinct was right and the object was wrong. Pi is here — not in one carpet, but in the **stack** of carpets, and it comes out as a counted number rather than an assumed one. Every claim below is tagged. **Proved** means proved or classical; **Verified** means recomputed here and reported as measured; **Conjecture** means supported and open. ## A single carpet cannot hold pi Take any self-similar fractal that keeps `k` of the `b^d` subcells at every level. Its filled fraction at level `n` is exactly `(k/b^d)^n` — rational at every level, and its limit is `0` or `1`. The carpet keeps 8 of 9, the sponge 20 of 27, so the level-`n` fractions are `(8/9)^n` and `(20/27)^n`. No irrational constant can be read off a sequence of that shape. (**Proved**, elementary.) The classical fractal that *does* give pi works differently: the Wallis sieve changes its ratio at every level, so its area is a genuine infinite product, ``` Product_{n >= 1} (1 - 1/(2*n + 1)^2) = pi/4 ``` recomputed here to `0.785398261` at two million factors against `pi/4 = 0.785398163`. (**Verified**, numerics; the identity itself is Wallis, **Proved**.) A fixed-ratio carpet has one ratio, not a product of changing ones. That is the whole reason the original hunt failed, and it is worth logging so nobody re-chases it. ## What the stack lights up Stack the grid at scales `k = 1, 2, 3, ...`. Every lattice point `(a, b)` factors uniquely as `g * (a/g, b/g)` with `g = gcd(a, b)`, so it belongs to exactly one layer of the stack, and the points that appear in the first layer are exactly those with `gcd(a, b) = 1` — equivalently, the points visible from the corner, with no nearer lattice point on the same ray. The stack is therefore a partition of the grid into scaled copies of the lit set. (**Proved**, elementary.) Checked numerically as `sum_{k >= 1} lit(floor(N/k)) = N^2`, exact at `N = 10, 100, 1000, 3000`. (**Verified**.) The density of those lit points is the classical coprimality density, ``` lit / N^2 -> 1/zeta(2) = 6/pi^2 = 0.6079271018... ``` (**Proved**, classical — Dirichlet and Mertens.) Inverting it turns the picture into an estimator: ``` pi = sqrt( 6 / density ) = sqrt( 6 * N^2 / lit ) ``` The constant is classical; what the stack adds is a picture, so pi is counted out of the grid rather than imposed on it. The same visibility fact anchors the base-3 story in [what base 3 hides](bases.md). ## The numbers Lit points counted by a totient sieve as `2 * sum_{k=1..N} phi(k) - 1`, cross-checked against a brute `gcd` scan at `N = 10, 50, 100, 200` with exact agreement. | N | lit points | density | pi estimate | abs error | |---|---|---|---|---| | 10 | 63 | 0.6300000000 | 3.08606700 | 5.6e-02 | | 100 | 6087 | 0.6087000000 | 3.13959750 | 2.0e-03 | | 1000 | 608383 | 0.6083830000 | 3.14041534 | 1.2e-03 | | 10000 | 60794971 | 0.6079497100 | 3.14153424 | 5.8e-05 | | 20000 | 243180791 | 0.6079519775 | 3.14152838 | 6.4e-05 | | 100000 | 6079301507 | 0.6079301507 | 3.14158478 | 7.9e-06 | | 200000 | 24317197835 | 0.6079299459 | 3.14158531 | 7.3e-06 | At `N = 100000` the stack gives `3.14158...`, six correct figures against `pi = 3.14159265...`. (**Verified**, recomputed.) It is a slow estimator and an honestly noisy one. The error term in the coprime count is `O(N log N)`, so accuracy improves only like `1/N`, and because that term fluctuates arithmetically the approach is not monotone: `N = 20000` is *worse* than `N = 10000` in the table above, and `N = 200000` barely improves on `N = 100000`. (**Verified**, observed in the run.) That puts it in the same family as the Wallis product and the Leibniz series — correct, convergent, not fast. The point was never speed. ## The dimension picks the zeta The same count in `d` dimensions has density `1/zeta(d)` (**Proved**, classical, by Mobius inversion). So the stack is a geometric generator for the whole zeta family, and the dimension you stack in decides which constant falls out. Counted by `sum_{k=1..N} mu(k) * floor(N/k)^d`, cross-checked against brute `gcd` at `N = 10, 40` for `d = 2, 3`: | d | density at N = 100000 | limit | constant recovered | true value | |---|---|---|---|---| | 2 | 0.6079301507 | `6/pi^2` | `pi = 3.14158478` | `3.14159265` | | 3 | 0.8319084771 | `1/zeta(3)` | `zeta(3) = 1.20205531` | `1.20205690` | | 4 | 0.9239388718 | `1/zeta(4)` | `pi = 3.14159226` via `pi = (90/density)^(1/4)` | `3.14159265` | (**Verified**, recomputed.) Two things follow. The 3D sponge stack does **not** give pi: it gives Apery's constant `zeta(3)`, which is not known to be a rational multiple of any power of pi — the same parity barrier that blocks Catalan's constant (**Conjecture**; no impossibility proof exists, and none is expected to be easy). And every even dimension is a fresh pi route: `zeta(4) = pi^4/90` recovers pi to seven figures at `N = 100000`, an order better than the 2D count at the same `N`. (**Verified**, observed in the run.) ## Pi to the fourth, out of one design Every route above runs through `gcd`. One more pi lives in the stack and never mentions coprimality at all. Take the design with filled corners `(0,0)` and `(1,1)` — code 9, the diagonal — and truncate its parity pattern to an `n x n` grid: cell `(i, j)` is filled when `i` and `j` have the same parity. The filled fraction `rho(n) = fill(n)/n^2` tends to `1/2`, and the fluctuation around that limit is exact at every `n`: zero at every even `n`, and exactly `1/(2*n^2)` at every odd `n` — `fill(2m) = 2*m^2` on the nose, while `fill(2m-1) = m^2 + (m-1)^2` and the numerator of `rho - 1/2` collapses to `1`. (**Proved**, elementary.) Weight the fluctuations into a Dirichlet series and only the odd terms survive, each equal to `1/(2*n^(s+2))` — the fluctuation times the weight, two different things: ``` Z(s) = Sum_{n >= 1} (rho(n) - 1/2) / n^s = (1/2) * lambda(s+2), Re(s) > -1 ``` with `lambda(s) = (1 - 2^(-s)) * zeta(s)` the Dirichlet lambda function. At `s = 2` and `s = 4`: ``` Z(2) = pi^4/192 = 0.50733901580... Z(4) = pi^6/1920 = 0.50072353832... ``` (**Proved**; **Verified** by `lab/visibility/lambda4.py`: the fluctuation exact in rational arithmetic to `n = 80`, the reductions `1/192` and `1/1920` exact, both constants matched at 90 digits with two independent pi routines and two independent lambda routes agreeing to `1.2e-75` or better, and the series summed straight off counted fills with no closed form anywhere — gap `8.3e-11` at `n <= 999`, the size of the neglected tail.) One caution is load-bearing: the constant belongs to the corner set, not the symmetry class. The orbit mate — corners `(0,1)` and `(1,0)`, code 6 — has fluctuation exactly `-1/(2*n^2)` on odd `n`, so its `Z(2)` is `-pi^4/192`: same shape under cube symmetry, opposite sign under truncation to `n` cells, the fixed-`n` caveat [the core](core.md) already records. (**Verified**, `n = 1..40`.) And the machine is genuinely different from the stack above — a Dirichlet series over one design's own fill fluctuation across truncations, with no visibility and no Mobius anywhere in it. A second, disjoint way for the grid to know pi. ## Where the fractal versions stand Restricting the count from the full grid to the cells of a fractal keeps the pi but changes the constant. Those restricted densities are recorded in [the ledger](sequences.md) and every one of them is **Conjecture** there, not theorem — numerical support with shrinking gaps, no proof of the interchange of limits. Each is a rational multiple of `6/pi^2` (**Proved**, exact arithmetic on the three values): | entry | conjectured density | as a multiple of `6/pi^2` | |---|---|---| | A396934, Sierpinski triangle | `16/(3*Pi^2) = 0.5403796` | `8/9` | | `carpet_coprime` | `189/(32*Pi^2) = 0.5984282409` | `63/64` | | `vicsek_coprime` | `27/(4*Pi^2) = 0.6839179896` | `9/8` | Nothing on this page upgrades them. The clean result is the unrestricted one: on the full stack the density is a theorem, and pi drops out of it by counting. > The early hunt looked for pi in an area and found a rational. Pi was one level up, in the > agreement between scales — and agreement between scales is coprimality.