← Interactive tools

The making of the Gilbreath decay-constants applet

A lightly edited transcript of the conversation that built the Gilbreath decay constants visualizer.

A curated transcript of the conversation (with Claude Code) that produced the Gilbreath decay-constants applet for tao-web — a companion to the Gilbreath array explorer that animates the Monte-Carlo convergence of the constants c_n. It was built in a single sitting alongside several unrelated site tasks; those are left out.

How to read this. As with the other transcripts, Terence's messages are shown mostly verbatim, and Claude's replies — the actual edits to two files, gilbreath-cn.js (the DOM-free math core) and gilbreath-cn.html (the app) — are replaced by short italic summaries. The math core was checked throughout with headless Node unit tests, and the UI wiring with a DOM-shim smoke test.


1. The idea

Terence (with the paper enclosed):

A quick new app request, which is a companion to the existing Gilbreath app. In our paper we made a figure (Figure 1) plotting theoretical and empirical versions of a certain sequence c_n, constructed using Monte Carlo simulation. I'm thinking of turning this figure into an interactive, animated applet, where one can specify the range of n and the number of simulations, and see the graph converge over time as in the probability visualizer (or show the individual instances of these random variables, e.g., the lower-n diagonal of a Gilbreath array with n exponential variables as initial data). In the paper we only computed the first 3 values of c_n exactly, but in the companion repository three further values were computed. This should be a quick project; could you execute as much of it as possible? I envisage only one phase of review will be needed before the final stages (review, making of, push).

Claude fetched the companion repository (michaelmross/Gilbreath): the exact-values file (c_0c_6 as reduced rationals) and the figure-generating code, to pin down precisely what c_n is — the expected entry E a(n,j) at depth n of the absolute-difference array of an iid standard-exponential top row, estimated by Monte Carlo. It sketched the plan: a DOM-free core (the array, the estimator, the exact table, the digit-sum law) with unit tests, then a canvas UI that animates the estimate converging.


2. Nailing the estimator — the left diagonal

Claude first coded the estimator to average all entries at each depth (the repo's deep-study script does that for lower variance). Terence then supplied the actual figure code:

Terence:

Perhaps you no longer need it, but here is cn.py in plain text … [the script draws max_n+1 exponentials, then repeatedly takes np.abs(np.diff(…)) and accumulates current_row[0] at each depth].

That settled a modelling choice. cn.py averages current_row[0] — the first entry of each row, i.e. the array's left diagonal a(n,0) — not the whole-row average. Both are unbiased for c_n by translation invariance, but the diagonal is what the paper's figure uses, and it is exactly the “individual instance” Terence had described. Claude rewrote the core around pyramidDiagonal, so the estimator, the sample-pyramid view, and the paper all agree. A seeded PRNG keeps runs reproducible; a headless test confirmed the Monte-Carlo estimates converge to the exact c_2=7/9, c_3=227/288, and c_4c_6 (worst deviation 0.0016 at half a million pyramids).


3. Scale, and the right attribution

Terence flagged a subtlety that shaped the whole visual design:

There may be some confusion between Figure 1 of my paper and Figure 1 of the Ross paper. Both are plotting c_n, but at different scales; the Ross paper plots over a far larger range of n in a log-log plot, while my paper plots c_n only up to n=20. For the purpose of an app it may not be possible to reach the scales of the Ross paper with the limited compute available, in which case a log-log plot may not be worthwhile.

So the app defaults to a linear c_n-vs-n plot to about n=20 — matching the CHT figure and cn.py — where the convergence and the non-monotone sawtooth are clear at browser-reachable depths; log-log is left as an optional toggle, with a note that its strands only separate over the far larger range (to 8192) that needs dedicated compute.

Terence on credit:

The empirical law associated to the binary expansion can be attributed to Michael Ross — see this document, hosted at Zenodo.

Claude split the attribution carefully. The stationary model, the bound Σ c_i ≥ log(n+e), and the exact c_0c_3 are Chase–Hunter–Tao (arXiv:2607.08712); the exact c_4c_6 and the digit-sum law c_n ≈ C λ^{s₂(n)}/n are Michael M. Ross's (Zenodo 10.5281/zenodo.21326026). Both credits appear in the app's provenance line and its notes, and the green law curve carries Ross's deep-window estimate λ=1.17, adjustable by a slider.

Terence also looked ahead to linking the apps from the paper:

Once this app is live one can link to it from the Gilbreath paper YAML, so one needs the capability to have multiple apps linked from a single paper entry.

Noted for the go-live step: the paper's link list already allows several entries, so the small remaining piece is a per-link label so two applet links (the array explorer and this one) read distinctly.


4. The build

With the model fixed, Claude built the app. The core (gilbreath-cn.js) exposes the binary digit sum, the Gilbreath array and its diagonal, a seeded Monte-Carlo estimator (running mean of a(n,0) with a standard error), the exact table, and Ross's law. The page (gilbreath-cn.html) is a canvas plot with Play / Step / Reset, sliders for depth, speed and λ, a readout table (Monte-Carlo c_n ± s.e. vs exact), and — alongside — one random sample pyramid with its left diagonal outlined, so the thing being averaged is visible. The exact c_0c_6 are drawn as open circles, the law as a curve fitted through those anchors. Seventeen core checks and a twenty-one-check DOM-shim smoke test passed before any manual look.


5. Review and publish

Terence, after a look:

Looks good to me. Let's run any remaining audits, write a making-of, and push.

An independent audit pass went over the core math and the rendering edge cases (empty estimator, min/max depth, the log-log toggle when a value is non-positive, the law fit); the app was then catalogued under Number theory, this transcript written, and everything validated, built, committed, pushed, and confirmed live.


From “turn Figure 1 into an applet” to a published tool: a linear c_n plot that animates the Monte-Carlo estimate converging onto the exactly-known constants and Ross's digit-sum law, with a live sample pyramid making the estimator concrete — a companion to the Gilbreath array explorer, and to two papers at once.