Skip to content

Repository files navigation

Prime ↔ Logistic: Reproducible code for The Emergence of Prime Distribution from Low-Dimensional Deterministic Chaos

This repository contains the full set of Jupyter notebooks used to generate every quantitative figure in the paper:

Liang Wang. The Emergence of Prime Distribution from Low-Dimensional Deterministic Chaos. Research in Mathematics (in review), 2026 (Ms. No. 263595999).

Each notebook is self-contained: just open it (locally or in Google Colab, see badges below) and run all cells. The notebooks reproduce the exact figures shown in the paper.

Core research framework

Figure 1 of the paper — the theoretical pathway from the arithmetic sieve to symbolic sequences, mapped to deterministic orbits of the Logistic chaotic attractor. This is the conceptual backbone that every notebook below verifies on a different observable.


Quick links

# Notebook Paper figure Open in Colab
1 fig3-logistic_map.ipynb Fig. 3 — Symbolic partition of the Logistic map Colab
2 fig4-logistic_map_line.ipynb Fig. 4 — Physical localization of the prime sieve Colab
3 fig5-discrete_gap_spectrum.ipynb Fig. 5 — Discrete gap spectra (primes vs. Logistic vs. Cramér) Colab
4 fig6-max_lyapunov_exponent.ipynb Fig. 6 — Maximal Lyapunov exponent Colab
5 fig7-block_entropy.ipynb Fig. 7 — Block entropy and entropy rate Colab
6 fig8-twin_prime_density_logistic.ipynb Fig. 8 — Twin-prime density (L-R-L pattern) Colab
7 fig9-twin_prime_constant.ipynb Fig. 9 — Convergence to the twin-prime constant Colab
8 fig10-cramer_test.ipynb Fig. 10 — Test of Cramér's conjecture under the chaotic model Colab

Background in one paragraph

We model the prime distribution as the symbolic dynamics of a one-dimensional non-autonomous chaotic system: the Logistic map x → 1 − u x² with a slowly drifting parameter u(k) tied to the index of the sieve stage. The sieve sequence Q_k generated by successively introducing primes p_1, p_2, … turns out to coincide with the Metropolis–Stein–Stein (MSS) admissible sequence of the Logistic map, so each sieve stage corresponds to a precisely determined u value, and the limiting band-merging point u_c ≈ 1.5437 plays the role of the "edge of chaos" reached by the full prime distribution. The notebooks here verify this picture quantitatively along the dimensions used in the paper: spectral structure of gaps, short-range repulsion / Lyapunov exponent / block entropy, twin-prime constant, and the exponential gap distribution claimed by Cramér's conjecture.


Highlighted results

The repository ships eight notebooks; the four figures below are the headline results. The remaining four (Lyapunov exponent, block entropy, L-R-L density, twin-prime constant) are auxiliary diagnostics — open the corresponding .ipynb directly if you want to reproduce them.

Fig. 3 — Symbolic partition of the Logistic map

Fig 3

Bifurcation diagram of x → 1 − u x², colored by the symbolic partition. Trajectories with x > 0 are encoded as R (composite-like) and shown in blue; trajectories with x < 0 are encoded as L (prime-like) and shown in red. The dashed line marks the critical point x_c = 0. → fig3-logistic_map.ipynb

Fig. 4 — Physical localization of the prime sieve

Fig 4

Two-panel bifurcation diagram. The right panel zooms into u ∈ [1.44, 1.56] with three reference lines at u = 1.250 (period-2, sieve stage k=1), u ≈ 1.476 (high-order period, k=2 — introduction of prime 3), and u ≈ 1.5437 (band-merging / edge-of-chaos limit, k → ∞). Each prime sieve stage corresponds to a precisely determined u value. → fig4-logistic_map_line.ipynb

Fig. 5 — Discrete gap spectra

Fig 5

Discrete gap spectra of (a) renormalized real primes and (b) the Logistic-map orbit at u_c. Both spectra exhibit the same needle structure with resonance peaks at multiples of 6 (g = 6, 12, 18, …) and statistical correlation > 0.99. The classical Cramér stochastic model produces only a smooth exponential and cannot reproduce this discrete arithmetic rigidity. → fig5-discrete_gap_spectrum.ipynb

Fig. 10 — Test of Cramér's conjecture

Fig 10

Probability density of normalized gaps g/⟨g⟩ on a log scale. The aging chaotic model (green) collapses essentially perfectly onto the exponential e^{−x} predicted by Cramér's conjecture (red dashed) and matches the real-prime histogram (blue) over four decades. The unaged static model (gray dotted) fails. → fig10-cramer_test.ipynb


Requirements

python >= 3.9
numpy
matplotlib
sympy           # only for the prime-sieve in fig5/fig6/fig7/fig10

That's it — no GPU, no special libraries. A standard scientific Python environment (or a free Colab runtime) is enough.

pip install numpy matplotlib sympy
jupyter notebook

Reproducing the paper results

Each notebook is independent and reproduces exactly one figure of the paper. Notebooks are deterministic up to the floating-point order; the random-control plots use a fixed seed where applicable.

Some notebooks are data-heavy (e.g. fig7-block_entropy.ipynb uses primes up to 5 × 10⁶, fig9-twin_prime_constant.ipynb runs 10⁷ Logistic iterations). On a free Colab CPU instance these take roughly 5–15 minutes; on a modern laptop, 1–5 minutes. Constants such as PRIME_LIMIT, LOGISTIC_STEPS, MAX_BLOCK_SIZE are exposed at the top of each notebook so you can downscale them for a quick sanity run before launching the full version.

Citation

If you use this code, please cite:

@article{wang2026emergence_prime_chaos,
  title   = {The Emergence of Prime Distribution from Low-Dimensional Deterministic Chaos},
  author  = {Wang, Liang},
  journal = {Research in Mathematics (in review)},
  year    = {2026},
  note    = {Manuscript ID 263595999, under review}
}

License

Code released under the MIT License. The figures and the manuscript are © the author and subject to the publisher's policies.

About

The Emergence of Prime Distribution from Low-Dimensional Deterministic Chaos

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages