This repository contains a modular Python toolkit for studying the Riemann–Zeta function on the critical line and certifying its non-trivial zeros. It combines exact and asymptotic evaluations of Hardy's Z-function, interval arithmetic for rigorous certification, adaptive scanning techniques, and prime sieving methods. The original suite is described in the accompanying analysis documents; this README consolidates those descriptions, explains the purpose of each module, and shows how to run the tools yourself.
The non-trivial zeros of the Riemann–Zeta function play a central role in analytic number theory. Hardy's Z-function Z(t) evaluates zeta(1/2 + i*t) up to a phase so that zeros of Z(t) correspond to zeros on the critical line. Our suite implements a hybrid evaluation of Z(t): for small heights it calls mpmath's zeta and gamma, while for larger heights it uses the Riemann–Siegel formula. When strict rigor is needed, interval arithmetic via rigorous_Z.py returns an enclosure for Z(t) and its derivative together with a Lipschitz constant.
-
Adaptive scanning of Hardy's
Z-function.zeta_zero_finder.pyscans a height interval[T1, T2]with a step proportional to the local wavelength (Delta t ~= 2pi / log(t/(2pi))) so sign changes aren't skipped. Found brackets are refined by bisection, optional secant, and (optionally) Chebyshev interpolation. -
Rigorous certification with interval arithmetic.
run_block.pyuses interval evaluations ofZ(t)to certify zeros. For each detected sign change it callscertify_zero_unique, bisecting and then performing a uniqueness grid test to prove exactly one zero lies in the bracket. Certificates are written as JSON. -
Turing checks as a safety net. After each block, the number of detected zeros is compared with the Riemann–von–Mangoldt prediction. Mismatches trigger rescans (finer step, higher precision, Gram fallback).
-
Prime-counting via the explicit formula. Using certified zeros,
sieve_from_zeros_psi_rigorous.pyestimates psi(x+h) - psi(x) with smoothing kernels and a tail bound; if needed it runs a segmented sieve to produce rigorous bounds for pi(x).
This project includes simple launcher scripts so you can run the suite without learning all internal Python entrypoints first.
- Linux / macOS:
./suite_menu.sh(Bash) - Windows:
rieman-zeta-zero.bat(callsrieman-zeta-zero.ps1)
Both launchers ask only for:
- Hours (how long to run the batch; minimum
0.1) - SIEVE_MAX (upper bound for prime sieving; e.g.
100000for 1e5) - DPS (decimal precision for math; e.g.
80)
They then run three steps in order:
- compute zeros for about the requested time,
- do a Turing consistency check,
- run a rigorous sieve using the zeros just computed.
-
Python 3.10+ on PATH (Windows users: the scripts try
py -3, thenpython3, thenpython.) -
Project dependencies (from the repo root):
pip install -r requirements.txt export LC_ALL=C export LANG=C
-
Bash (Linux/macOS) or PowerShell (Windows). The Windows
.batfile launches PowerShell with a relaxed execution policy just for this run.
License notice (ACSL 1.4): The launcher prints the Anti-Capitalist Software License header on start. By using these scripts you agree to the terms. See
LICENSEfor the full text.
-
Open a terminal and
cdinto the repo folder. -
Make the script executable (first time only):
chmod +x suite_menu.sh
-
Run it:
./suite_menu.sh
-
You’ll be asked:
Hours (>= 0.1) [default 0.1]:SIEVE_MAX (>= 10) [default 1000000]:DPS (>= 1) [default 80]:
The script creates a timestamped working directory like temp_YYYYMMDD_HHMMSS in the current folder, with subfolders:
temp_YYYYMMDD_HHMMSS/
├─ logs/
└─ runs/
├─ batch/ # zeros, master_zeros.csv
└─ sieve/ # primes, bounds, windows, residues, gaps
- Open the repo folder in Explorer.
- Double-click
rieman-zeta-zero.bat. (It startsrieman-zeta-zero.ps1and prints the same ACSL header and prompts.) - Answer the three prompts. That’s it.
The working directory temp_YYYYMMDD_HHMMSS is created next to the scripts, with the same logs/ and runs/ layout as on Linux.
-
Batch (zeros): Runs
batch_until_deadline.pywith yourHoursvalue (e.g.,0.1→ ~0.1 hours). Output:runs/batch/master_zeros.csvand per-block files. -
Turing check: Validates zeros over a small, safe interval (e.g.,
T ∈ [0.1, 4]) with conservative defaults. If the direct CSV mode complains, the launcher automatically falls back to--zeros-root. -
Rigorous sieve: Calls
sieve_from_zeros_psi_rigorous.pyfromx = 2up to yourSIEVE_MAX, using:--kernel fejer--rigorous dusart--rigorous-tail on --tail-C 50--wheel 210Outputs go toruns/sieve/(primes list, bounds, windows, residues, gaps).
All console output is also written to logs/ (one file per step).
The batch runs in blocks. It will always finish the current block before stopping, even if the requested time has elapsed. That means:
Hours = 0.1(≈6 minutes) may actually take ~10–20 minutes depending on CPU speed and where the block ends.- This is expected and avoids truncated, low-quality outputs.
$ ./suite_menu.sh
============================================================
Anti-Capitalist Software License (ACSL), Version 1.4
... (license text) ...
============================================================
Hours (>= 0.1) [default 0.1]: 1
SIEVE_MAX (>= 10) [default 100000]: 100000
DPS (>= 1) [default 80]: 80
=== [00:01:07 UTC] 1/3 Batch run --tstart 10 --hours 1 --dps 80 ===
[batch] start t=10.000000, run for ~1.0h ...
[block 1] [10.000, 31.830] ...
[done] master_zeros.csv contains N zeros: runs/batch/master_zeros.csv
=== [..] 2/3 Turing (CSV) ... ===
[turing] Interval [0.100000, 4.000000] ...
=== [..] 3/3 Sieve [2, 100000] kernel=fejer rigor=dusart ===
[out] wrote primes: runs/sieve/primes_2_100000.txt
... Done. Logs: logs/
-
Python not foundInstall Python 3.10+ and make surepython/python3(Linux/macOS) orpy -3(Windows) is on PATH. -
master_zeros.csv not foundafter batch The batch finished too quickly or didn’t complete a block. IncreaseHoursand try again. -
Turing complains that
--zeros-rootis required The launcher already retries in a fallback mode. Checklogs/turing_*.logfor details. -
Sieve outputs are empty/small for tiny SIEVE_MAX That’s normal for very small ranges. Increase
SIEVE_MAXfor more meaningful results. -
Interrupting runs Avoid
Ctrl+Cduring a block; you might get partial results. If you must stop, rerun later with a largerHours.
Each run writes a dated working directory:
- All step logs:
logs/ - Batch zeros:
runs/batch/ - Sieve artifacts:
runs/sieve/
Keep these folders if you want to compare results or resume work later.
Requirements: Python 3.10+, mpmath, numpy.
python3 -m venv venv
source venv/bin/activate
pip install mpmath numpyClone or extract this repository and run the scripts from the project root. No compilation is required.
Each script supports -h/--help for details.
Core math utilities:
theta(t)— Riemann's theta function.Z(t)— hybrid Hardy's Z (exact below a switch, Riemann–Siegel above).Z_exact(t),Z_rs(t)— exact vs. RS helper paths.
Interval arithmetic:
eval_ZZp_interval(t, rad, dps)returns interval enclosures forZ(t),Z'(t)and a Lipschitz constant.sign_from_interval(iv)robustly decides the sign ofZon a small neighbourhood.
Adaptive scanner (approximate by default, with rigorous options):
- Scan
[T1,T2]with (Delta t proportional to 2*pi / log(t)). - Refine by bisection, optional secant and optional Chebyshev interpolation.
- Deduplicate close zeros (scale ~= local wavelength).
- Output CSV (and optionally JSON per block).
CLI options (selection):
--tmin, --tmax start and end heights
--block block size for batching write-out
--out CSV file to append zeros
--dps decimal precision (mpmath)
--bisect-steps bisection iterations per bracket
--no-sec disable secant refinement
--dedup remove near duplicates
--fixed-step override adaptive step with a constant step
--adapt-scale scaling for adaptive step (Delta t ~= adapt_scale * 2*pi/log(t))
--json also emit JSON certificates per block
--cheb enable Chebyshev interpolation refinement
--cheb-k number of Chebyshev nodes (degree = k-1)
Example:
python3 zeta_zero_finder.py \
--tmin 10 --tmax 50 --dps 80 \
--cheb --cheb-k 8 \
--out zeros_10_50.csvRigorous certification on [T1,T2] using interval arithmetic and repeated halving to avoid missed sign changes.
Parameters (programmatic use):
T1, T2— block endpointsscan_step— fixed step (ignored ifadaptive=True)adaptive— enable adaptive scanningadapt_scale— scale for adaptive stepmin_step,max_step— hard bounds for the stepeps— target bracket width for certificationdps— precision for interval calculations
Example:
python3 - <<'PY'
import run_block
print(run_block.run_block(20, 40, adaptive=True, adapt_scale=0.25, dps=60))
PYThe return object includes metadata (precision, step config) and a list of JSON-serializable certificates (interval, margins, uniqueness checks).
Run consecutive blocks until a time budget is consumed.
--tstart starting height
--hours wall-time budget in hours (float)
--outroot output directory (CSV/JSON per block)
--dps precision
--adapt-scale, --min-step, --max-step as in run_block
Example:
python3 batch_until_deadline.py --tstart 10 --hours 3 --outroot run3h --dps 60End-to-end wrapper: scanning -> certification -> Turing check across blocks; merges CSV/JSON and writes consolidated outputs.
Lightweight exploratory scanner (approximate). Supports adaptive step and repeated halving when no sign change is seen. Use for quick reconnaissance and then verify with run_block.py.
Example (API):
from zeros_by_scan import find_zeros_scan
zeros = find_zeros_scan(10.0, 60.0, adaptive=True, adapt_scale=0.25)
print(zeros)Uses Gram points g_n (solutions of theta(g_n) = n*pi) to bracket zeros efficiently; refine by bisection.
turing_check.py: Compare counted zeros with Riemann–von–Mangoldt expectation on bins; warn on discrepancies.turin_watchdog.py: Automate rescans on failing bins.
merge_zeros.py: merge overlapping CSV/JSON zero lists.count_certified.py: count certified zeros; optionally compare to theoretical counts.
Prime-counting via the explicit formula for psi(x) using certified zeros; supports Fejer/Parzen smoothing and a configurable tail bound. Can trigger a segmented sieve (mod 210) when necessary. Results written to prime_bounds.csv.
python3 run_certified_all.py \
--tmin 10 --tmax 100 --block 10 \
--dps 60 --adapt-scale 0.25 --min-step 0.002- Writes block CSV/JSON with certificates.
- Performs Turing checks; if a mismatch occurs, re-scan that block with finer settings.
python3 turing_check.py --csv runs/block_10_20/zeros.csv --t1 10 --t2 20python3 sieve_from_zeros_psi_rigorous.py \
--lower 1000000000 --upper 1000000000+1000000 \
--zeros runs/big_run/certified_zeros.csv \
--kernel fejer-
Repeated halving on scan (in
run_block.py,zeta_zero_finder.py,zeros_by_scan.py): if the full step shows no sign change, halve repeatedly until either a change is found or the step falls below about 1.5*min_step. This eliminates missed zeros in highly oscillatory regions. -
Chebyshev refinement (optional): after bisection (and optional secant), fit a Chebyshev polynomial on the bracket and take the closest root; improves accuracy with few evaluations.
-
Sharper Turing control: bin-wise Riemann–von–Mangoldt comparisons; automatic rescan hooks for blocks with mismatches.
-
Logging & modularity: consistent progress logs; results in CSV/JSON; components can be swapped (e.g., Arb-based certifier).
-
Precision vs. speed: increase
dpsand decreaseepsfor final certification runs; for exploration, keepdpsaround 60–80. -
RS regime caution: near the RS switch (e.g., t >= ~50) the main sum alone may give coarse brackets; prefer interval methods for certification.
-
Chebyshev stability: use moderate
--cheb-k(6–12). Validate with secant/Newton if the bracket is wide. -
Reproducibility: fix RNG seeds (if any) and record
dps, step parameters, and certificate metadata.
# Adaptive, approximate scan with Chebyshev refinement
python3 zeta_zero_finder.py --tmin 10 --tmax 60 --dps 80 --cheb --cheb-k 8 --out zeros_10_60.csv
# Rigorous certification on a single block
python3 - <<'PY'
import run_block
out = run_block.run_block(40, 60, adaptive=True, adapt_scale=0.25, min_step=0.002, dps=80)
print(out["certificates"])
PY
# Time-boxed batch run (e.g. 3 hours)
python3 batch_until_deadline.py --tstart 10 --hours 3 --outroot run3h --dps 60
# Merge and count
python3 merge_zeros.py --in runs/run3h --out merged/certified_zeros.csv
python3 count_certified.py --in merged/certified_zeros.csv- Classical references on Hardy's
Z, Riemann–Siegel, Gram points, Turing checks, and explicit prime-counting formulas. - Empirical reference lists of low-lying zeros (e.g., tables by Odlyzko) are useful for sanity checks in small intervals.
- The accompanying analysis PDFs in this repository describe design decisions, benchmarks, and further improvement ideas (e.g., Arb-based certifiers, FFT-accelerated evaluations, Gram-guided rescans).
Anti-Capitalist Software License (ACSL) 1.4
Copyright (c) 2025 Lino Casu and Carmen Wrede
Summary (non-binding, for convenience only):
- You may use, modify, and distribute this software, but not for the purpose of generating profit, advertising, or in service of capitalist enterprise.
- You may not use it on behalf of organizations or individuals who fund, support, or perform exploitation, oppression, surveillance, policing, incarceration, or warfare.
- Any distribution must keep this license and attribution intact and apply the same license to derivative works.
- The full legal text is provided in the
LICENSEfile of this repository.
If the LICENSE file is not yet present, create a new file named LICENSE at the repository root and paste the complete text of ACSL v1.4 with the copyright line:
Anti-Capitalist Software License (ACSL), Version 1.4
Copyright (c) 2025 Lino Casu and Carmen Wrede