E126: Hexagonal number spiral structure¶
size 101: 10,201 numbers and 1,252 primes
size 201: 40,401 numbers and 4,236 primes
size 301: 90,601 numbers and 8,769 primes
size 401: 160,801 numbers and 14,752 primes
size 999: 998,001 numbers and 78,359 primes
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: Valid Tags.
Highlights¶
Arranges integers on a hexagonal lattice using a centered spiral enumeration.
Parameterizable run: vary
--sizefrom the command line (default:301).Writes reproducible artifacts (
params.json,report.md, and figures) intoout/e126/.
Goal¶
Render a hexagonal number spiral and highlight primes to reveal lattice-aligned structures,
then compare how that structure changes as size increases.
Background (quick refresher)¶
What is a hexagonal number spiral?¶
A hexagonal number spiral places integers on a hexagonal grid, starting at the center with \(1\) and then spiraling outward. Compared to the square-lattice Ulam spiral, the hex lattice emphasizes different geometric alignments and may reveal different-looking prime structures. See [Kurzweg, 2020].
Optional background pages¶
Research question¶
Which geometric structures appear when primes are highlighted on a hexagonal spiral, and how stable are they
as size increases (i.e., as we include integers up to \(\text{size}^2\))?
Why this qualifies as a mathematical experiment¶
Finite procedure: enumerate a finite spiral placement for integers \(1,\dots,\text{size}^2\) and run a deterministic primality test up to \(\text{size}^2\).
Observable(s): lattice-aligned streaks/clusters and how visibility changes with
size.Parameter space:
size(and, if you extend it, coordinate convention / rendering choices).Outcome: figures and a short report capturing the key observation and caveats.
Reproducibility: outputs saved to
out/e126/with a parameter snapshot.
Experiment design¶
Computation: map integers \(1,\dots,\text{size}^2\) to hex-lattice coordinates using a centered spiral enumeration; mark primes.
Coordinates: integers are mapped to axial hex coordinates \((q,r)\) on a hex grid and embedded into the plane via \(x = q + \tfrac{1}{2}r\) and \(y = \tfrac{\sqrt{3}}{2}r\).
Prime classification: primes are computed using a sieve up to \(\text{size}^2\).
Outputs: one or more scatter plots of prime points on the hex lattice (composites omitted).
Artifacts written:
figures/fig_01_hex_spiral*.png(main figure) andfigures/e126_hero_<size>.png(published hero)params.jsonreport.md
How to run¶
make run EXP=e126
Override the experiment size:
make run EXP=e126 ARGS="--size 501"
Direct invocation (always works):
uv run --extra dev python -m mathxlab.experiments.e126 --out out/e126 --size 501
Notes / pitfalls¶
Different conventions exist for hex-spiral enumeration; changing the convention can change visible structures.
Larger
sizemeans more numbers (\(\text{size}^2\)) and a longer run time.“Looks-true” trap: lattice-aligned streaks do not prove a statement about primes.
Extensions¶
Overlay ring boundaries (or distance-from-center contours) to relate features to the spiral geometry.
Add simple quantitative overlays: density by hex-ring index or by lattice direction.
Compare hex vs. square spirals at matched
N(same number of integers).
Published run snapshot¶
If this experiment is included in the docs gallery, include the published snapshot (report + params).
Reproduce:
make run EXP=e126
Parameters¶
size:
301(odd); visualizes integers1..90601.
Notes¶
Integers are placed by walking concentric hexagonal rings around the origin.
Prime-rich lines/curves are expected analogues of the Ulam spiral phenomena.
This experiment is deterministic;
seeddoes not change the output.
params.json (snapshot)
{
"size": 301
}
References¶
Hex spiral background and construction ideas: [Kurzweg, 2020].
Exposition connecting multiple prime visualizations: [Brockmann, 2019].
Recreational-math context and “pattern traps”: [Gardner, 1983], [Hoffman, 1989].
See also References.
Parameters (example)¶
size:
301(implied total integers:1..90,601)
Recommended size range¶
The hex spiral run includes integers \(1,\dots,\text{size}^2\), so runtime and memory scale roughly with \(\text{size}^2\) (because about \(\text{size}^2\) integers are classified as prime/not-prime).
A practical range that works well for most runs:
Minimum (still meaningful):
size = 101Default / recommended:
size = 301Comfortable upper range on typical laptops (varies):
size = 999Above ~
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 enumerate a hex-lattice spiral placement for the first 90,601 positive integers and highlight primes. At this scale, lattice-aligned structures can be visible: some directions show denser prime “streaks” than others.
Key observations¶
Prime points show directional structure aligned to the hex lattice.
Some structures are subtle and become easier to see with larger
sizeand careful marker sizing.
Interpretation¶
The hex spiral is an alternative geometry for indexing the same integers. As with the Ulam spiral, geometric placement can visually emphasize prime-rich progressions or polynomial-like sequences. This is a strong exploratory tool — but not evidence of a global law of primes.
Caveats¶
Different enumeration conventions change the picture.
Finite window: patterns can look stronger/weaker depending on the chosen
sizeand zoom level.Visualization choices matter: marker size, DPI, and axis limits can hide or exaggerate structure.