# E125: Sacks spiral structure **size 101: 10,201 numbers and 1,252 primes** ```{figure} ../_static/experiments/e125_hero_101.png :width: 80% :alt: Sacks spiral preview (size 101) ``` **size 201: 40,401 numbers and 4,236 primes** ```{figure} ../_static/experiments/e125_hero_201.png :width: 80% :alt: Sacks spiral preview (size 201) ``` **size 301: 90,601 numbers and 8,769 primes** ```{figure} ../_static/experiments/e125_hero_301.png :width: 80% :alt: Sacks spiral preview (size 301) ``` **size 401: 160,801 numbers and 14,752 primes** ```{figure} ../_static/experiments/e125_hero_401.png :width: 80% :alt: Sacks spiral preview (size 401) ``` **size 999: 998,001 numbers and 78,359 primes** ```{figure} ../_static/experiments/e125_hero_999.png :width: 80% :alt: Sacks spiral preview (size 999) ``` *Prime counts shown are $\pi(\text{size}^2)$, i.e., the number of primes $\le \text{size}^2$.* **Tags:** `number-theory`, `quantitative-exploration`, `visualization` See: {doc}`../tags`. ## Highlights - Places integers on a spiral using polar coordinates $r=\sqrt{n}$ and $\theta = 2\pi\sqrt{n}$. - Parameterizable run: vary `--size` from the command line (default: `301`). - Writes reproducible artifacts (`params.json`, `report.md`, and figures) into `out/e125/`. ## Goal Render the **Sacks spiral** and highlight primes as a point cloud to reveal spiral-aligned structure, then compare how the apparent density and “spiral fragments” change as `size` increases. ## Background (quick refresher) ### What is the Sacks spiral? In the **Sacks spiral**, each integer $n$ is mapped to polar coordinates $$r_n = \sqrt{n},\qquad \theta_n = 2\pi\sqrt{n},$$ and plotted as $(x,y) = (r\cos\theta,\ r\sin\theta)$. Highlighting primes yields striking spiral fragments and density variations. See {cite}`Brockmann2019PrimeTime`. ### Optional background pages - {doc}`../background/prime-numbers` ## Research question How does the visual “prime spiral density” change as `size` increases (i.e., as we include integers up to $\text{size}^2$), and which spiral-aligned structures persist across scales? ## Why this qualifies as a mathematical experiment - **Finite procedure:** compute primes up to $\text{size}^2$ and apply a deterministic mapping $n\mapsto(x,y)$. - **Observable(s):** spiral fragments, density contrasts, and how visibility changes with `size`. - **Parameter space:** `size` (and, if you extend it, marker size / rendering choices). - **Outcome:** figures and a short report capturing the key observation and caveats. - **Reproducibility:** outputs saved to `out/e125/` with a parameter snapshot. ## Experiment design - **Computation:** for integers $1,\dots,\text{size}^2$, compute a prime mask; map prime indices to $(x,y)$ via the Sacks rule. - **Coordinates:** Cartesian coordinates $(x,y)$ are computed from $r=\sqrt{n}$ and $\theta=2\pi\sqrt{n}$ via $(x,y)=(r\cos\theta,\ r\sin\theta)$. - **Prime classification:** primes are computed deterministically up to $\text{size}^2$ (sieve). - **Outputs:** one or more scatter plots of prime points (composites omitted). - **Artifacts written:** - `figures/fig_01_sacks_spiral*.png` (main figure) and `figures/e125_hero_.png` (published hero) - `params.json` - `report.md` ### Axis scaling note The run includes integers $n\le \text{size}^2$. With the Sacks choice $r=\sqrt{n}$, the maximal radius shown is $$r_{\max}=\sqrt{\text{size}^2}=\text{size},$$, so the plot naturally fits inside a disk of radius about `size`. ## How to run ```bash make run EXP=e125 ``` Override the experiment size: ```bash make run EXP=e125 ARGS="--size 501" ``` Direct invocation (always works): ```bash uv run --extra dev python -m mathxlab.experiments.e125 --out out/e125 --size 501 ``` ## Notes / pitfalls - Scatter plots are sensitive to marker size and resolution: the same data can look different depending on rendering. - Larger `size` means more numbers ($\text{size}^2$) and a longer run time. - “Looks-true” trap: a visually strong spiral does not by itself imply a theorem about primes. ## Extensions - Add a faint background of composite points (with transparency) to compare prime vs. composite geometry. - Plot multiple sizes on identical axes to compare density and visible spiral fragments. - Add simple quantitative summaries (e.g., radial density bins for primes vs. all numbers). ## Published run snapshot If this experiment is included in the docs gallery, include the published snapshot (report + params). ```{include} ../reports/e125.md :start-after: "" :end-before: "" ``` ::: {dropdown} params.json (snapshot) :open: ```{literalinclude} ../params/e125.json :language: json ``` ::: ## References - Exposition connecting multiple prime visualizations (includes Sacks spiral): {cite}`Brockmann2019PrimeTime`. - Recreational-math context and “pattern traps”: {cite}`gardner1983martin`, {cite}`hoffman1989archimedes`. See also {doc}`../references`. ## Related experiments - {doc}`e024` (Ulam spiral structure) - {doc}`e124` (Klauber triangle structure) - {doc}`e126` (Hexagonal number spiral structure) - {doc}`e127` (Quadratic prime-run atlas ($n^2 + a n + b$)) - {doc}`e128` (Quadratic modular obstructions (Euler-type)) - {doc}`e129` (Euler lucky constants for $n^2 + n + b$) ## Parameters (example) - size: `301` (implied total integers: `1..90,601`) ### Recommended `size` range The Sacks spiral run includes integers $1,\dots,\text{size}^2$, so runtime and memory scale roughly with $\text{size}^2$ (prime classification dominates). A practical range that works well for most runs: - **Minimum (still meaningful):** `size = 101` - **Default / recommended:** `size = 301` - **Comfortable upper range on typical laptops (varies):** `size = 999` - **Above ~`size = 1501`:** expect noticeably higher runtime (and potentially memory pressure), depending on the machine and the primality implementation. **Rule of thumb:** start with `301`, then try `501`, `701`, `901`. Increase further only if runtime remains acceptable. ## Summary We compute primes among the first 90,601 positive integers and plot prime indices using the Sacks polar mapping. Even at this moderate scale, visible spiral-aligned prime fragments emerge, with noticeable density variation across radii. ## Key observations - Prime points form dense spiral segments rather than appearing uniformly “random” in the plane. - The visibility of segments depends strongly on marker size and figure resolution. ## Interpretation The Sacks mapping is a deterministic geometric transform of the integer line. It tends to visually emphasize arithmetic structure (including sequences with prime-rich behavior), making it a useful exploratory visualization tool — but not a proof technique. ## Caveats - Rendering matters: marker size, DPI, and axis limits can change perceived structure. - Finite window: patterns can strengthen or weaken as `size` changes. - Without quantitative overlays, conclusions remain qualitative.