reproducible researcharXiv-ready

Hearing the Zeros: Reproducible Numerical Experiments with Riemann's Explicit Formula

Eugen Soloviov · Independent Researcher · ORCID 0009-0006-3148-111X

Six reproducible experiments that read the explicit formula as harmonic analysis in both directions: zeros rebuild the primes, primes reveal the zeros.

Abstract

Riemann’s explicit formula writes the prime staircase \(\psi(x)\) as a smooth main term minus one oscillating wave for every nontrivial zero of \(\zeta(s)\). We give six small, fully reproducible experiments that read this formula as harmonic analysis in both directions. Summing waves from the first 1000 zeros brings \(\psi(19.5)\) to within \(0.019\) of its true value \(19.2657\). Truncation produces a Gibbs overshoot of \(8.9\)–\(9.2\%\) at prime jumps, which a Hann taper reduces to \(0.64\%\). In the other direction, a windowed cosine transform of the prime powers up to \(10^6\) recovers the first ten zero ordinates with maximum error \(8\times10^{-4}\). A sum of cosines over 1000 zeros alone has dips exactly at \(\log p^k\), and their depths match Landau’s 1912 prediction \(\tfrac{G}{4\pi}\log p/\sqrt{n}\) to within \(0.2\%\), while composites such as \(6\), \(10\) and \(12\) give no dip (normalized depth below \(0.004\)). Bohr averages of \(\zeta(2+it)n^{it}\) recover \(n^{-2}\) with error \(1.4\times10^{-3}\) at \(T=1600\). Finally, Riemann’s \(R(x)\) is closer to \(\pi(x)\) than \(\mathrm{Li}(x)\) at every tested cutoff, but naively subtracting zero terms from \(R(x)\) does not converge monotonically. All numbers in this paper are regenerated by one script and checked against the text automatically.

This is the interactive web rendering of the paper (math via KaTeX, vector figures). The PDF is the authoritative version; every number is reproducible from the open-source code and cached zeros.


1 Introduction

The von Mangoldt form of Riemann’s explicit formula states, for \(x>1\) not a prime power, \[\psi(x)=\sum_{n\le x}\Lambda(n)=x-\sum_{\rho}\frac{x^{\rho}}{\rho}-\log(2\pi)-\tfrac12\log(1-x^{-2}), \label{eq:explicit}\] where \(\rho\) runs over the nontrivial zeros of \(\zeta(s)\) in order of increasing \(|\Im\rho|\) (Mazur and Stein 2016; Kedlaya, n.d.). If \(\rho=\tfrac12+i\gamma\), the pair \(\rho,\bar\rho\) contributes a wave \(2\sqrt{x}\,|\rho|^{-1}\cos(\gamma\log x-\arg\rho)\). In the variable \(u=\log x\) every zero is a pure frequency \(\gamma\). The formula is therefore a Fourier-type expansion of the prime staircase, and by Weil’s form of the explicit formula (Weil 1952) the roles of primes and zeros can be exchanged.

This duality is classical. Our aim is a compact, reproducible set of numerical checks that a reader can rerun on a laptop in seconds, together with the measurements that make each claim quantitative: convergence of the wave sum, the size of the Gibbs overshoot and how tapers remove it, the resolution with which primes reveal zeros, the depth of the dips with which zeros reveal primes, Bohr’s extraction of single Dirichlet coefficients, and the behaviour of Riemann’s \(R(x)\). Related numerical studies include Riesel and Göhl (Riesel and Göhl 1970), Odlyzko (Odlyzko 1987), Baillie (Baillie 2011) and the physics literature on prime-power spectra (Sakhr, Bhaduri, and Zyl 2003; Main et al. 1998).

All experiments use the first 1000 zero ordinates, \(\gamma_1=14.1347\) to \(\gamma_{1000}=G=1419.4225\), cached in the repository. The zeros used lie on the critical line, which is verified far beyond this height (Platt and Trudgian 2021). Exact definitions are collected in paper/FORMULAS.md.

2 Waves: rebuilding \(\psi(x)\) from zeros

We evaluate the truncation \(\psi_N(x)\) of (1) keeping the first \(N\) zero pairs and compare it with the midpoint value \(\psi_0(x)\). At \(x=19.5\), where \(\psi(19.5)=\log(2^4 3^2\cdot5\cdot7\cdot11\cdot13\cdot17\cdot19)=19.2657\):

zero pairs \(N\) \(\psi_N(19.5)\) absolute error
0 17.6634 1.6022
5 18.6306 0.6350
30 19.4876 0.2219
1000 19.2464 0.0193

Convergence is not monotone: with 30 zeros the estimate overshoots the true value. Each wave has period \(2\pi/\gamma_k\) in \(\log x\) and envelope \(2\sqrt{x}/|\rho_k|\), so higher zeros add finer and weaker detail. Over the fixed test grid the maximum error at \(N=1000\) is \(0.124\).

3 The Gibbs phenomenon and smoothing

A sharp truncation of (1) rings at every jump of \(\psi\), as a truncated Fourier series does at a discontinuity. For a classical Fourier series the overshoot tends to \(100(\mathrm{Si}(\pi)/\pi-\tfrac12)=8.949\%\) of the jump. We measure the overshoot above the plateau \(\psi(p)\) to the right of \(p=7,11,13\), as a percentage of the jump \(\log p\), and compare four weights \(w_k\) with \(r=\gamma_k/\gamma_N\): raw (\(1\)), Fejér (\(1-r\)), Gaussian (\(e^{-r^2}\)) and Hann (\((1+\cos\pi r)/2\)). Mean absolute error (MAE) is taken on \(x=1.5,1.55,\dots,50\).

weight (\(N=1000\)) worst overshoot, % MAE
raw 9.152 0.0281
Fejér 0.000 0.0450
Gaussian 2.213 0.0143
Hann 0.637 0.0171

The raw overshoot, \(8.9\)–\(9.2\%\) across the three primes, is the Fourier value. Fejér weights remove it at the cost of the largest MAE; the Hann taper keeps both small and first meets the joint criterion (MAE \(\le0.25\), overshoot \(\le2\%\)) at \(N=100\). Gibbs phenomena for related orthogonal expansions are studied in (Davis and Hagelstein 2022).

4 Primes reveal the zeros

We reverse the direction. With a Hann window \(W\) on \(u=\log n\in[\log2,\log X]\) we form \[S_X(t)=\Bigl|\sum_{n\le X}\frac{\Lambda(n)}{\sqrt n}W(\log n)\cos(t\log n)-\int e^{u/2}W(u)\cos(tu)\,du\Bigr|,\] the windowed cosine spectrum of the prime powers with the smooth density removed, and pick its ten largest peaks in \(t\in[10,50]\).

cutoff \(X\) first peak zeros resolved max error spacing \(2\pi/\log(X/2)\)
\(10^3\) 14.13457 9 0.0293 1.011
\(10^4\) 14.13480 10 0.0027 0.738
\(10^5\) 14.13472 10 0.00069 0.581
\(10^6\) 14.13474 10 0.00080 0.479

The peaks sit at the zero ordinates (\(\gamma_1=14.13473\), \(\gamma_2=21.02204\)). The resolution is set by the length of the record in \(\log n\): two zeros closer than about \(2\pi/\log(X/2)\) cannot be separated, which is the usual time–frequency limit of spectral analysis. At \(X=10^3\) the third zero is not resolved.

5 Zeros reveal the primes

Now we use the zeros alone. Let \[F(t)=\sum_{k=1}^{1000}W_k\cos(\gamma_k t),\qquad W_k=\tfrac12\bigl(1+\cos(\pi\gamma_k/G)\bigr).\] By Landau’s theorem (Landau 1912), \(\sum_{0<\gamma\le T}\cos(\gamma\log n)\sim -\frac{T}{2\pi}\frac{\Lambda(n)}{\sqrt n}\) for fixed \(n\), the linear term vanishing unless \(n\) is a prime power. The taper replaces \(T\) by \(\int_0^G W=G/2\), so \(F\) should have a dip at \(t=\log p^a\) of depth \(\frac{G}{4\pi}\frac{\log p}{\sqrt{n}}\) and no dip at other integers. We measure the depth at \(t=\log n\) against the local level \(\mathrm{med}_+\{F(\log n\pm d):d=0.04,0.05,0.06\}\) (the upper median of the six values) and report the normalized depth \(\mathrm{depth}\cdot\sqrt n/(G/4\pi)\).

\(n\) normalized depth \(\log p\) relative error
2 0.6935 0.6931 \(0.05\%\)
4 0.6935 0.6931 \(0.05\%\)
8 0.6939 0.6931 \(0.11\%\)
3 1.0990 1.0986 \(0.04\%\)
27 1.0981 1.0986 \(-0.05\%\)
13 2.5661 2.5649 \(0.05\%\)
31 3.4333 3.4340 \(-0.02\%\)
6 0.0005 –
10 0.0009 –
12 0.0010 –
15 0.0013 –

Over all seventeen prime powers up to 31 the agreement is within \(0.2\%\) (worst case \(n=16\)), every composite up to 30 has normalized depth below \(0.004\), and the dips are located within \(10^{-4}\) of \(\log n\). Powers of the same prime (\(2,4,8,16\)) have the same normalized depth \(\log 2\), exactly the jump of \(\psi\) at those points. With fewer zeros the dips widen in proportion to \(2\pi/G\), the mirror image of the resolution limit of Section 4. The two experiments together are a numerical form of Weil’s explicit formula: the spectrum of the primes is the set of zeros, and the spectrum of the zeros is the set of \(\log p^a\) weighted by \(\Lambda\).

6 Bohr coefficients: one integer at a time

On \(\Re s=2\) the series \(\zeta(s)=\sum n^{-s}\) converges absolutely, and each \(n\) contributes the frequency \(\log n\) with amplitude \(n^{-2}\). Bohr’s mean (Bohr 1925) \[C_T(n)=\frac1T\int_0^T\zeta(2+it)\,n^{it}\,dt\;\longrightarrow\;n^{-2}\] extracts it. For \(n\in\{2,\dots,7,12\}\) the maximum error \(|C_T(n)-n^{-2}|\) falls from \(0.0244\) (\(T=100\)) to \(0.0047\) (\(T=400\)) and \(0.0014\) (\(T=1600\)). Unique factorization appears as the multiplicativity \(6^{-2}=2^{-2}3^{-2}\): the finite-time discrepancy \(|C_T(6)-C_T(2)C_T(3)|\) is \(7.5\times10^{-4}\) at \(T=1600\). Because \(\log2\) and \(\log3\) are linearly independent over \(\mathbb{Q}\), the frequencies \(\log p\) behave as independent phases and every \(\log n\) is an integer combination of them. This is why the zeros in Section 5 see only prime powers: \(\log 6=\log2+\log3\) carries no new base frequency.

7 Counting primes: \(R(x)\) and the zero correction

Riemann’s function \(R(x)=\sum_{m\ge1}\frac{\mu(m)}{m}\mathrm{Li}(x^{1/m})\), computed by Gram’s series, is much closer to \(\pi(x)\) than \(\mathrm{Li}(x)\):

\(x\) \(\pi(x)\) \(R(x)\) \(\mathrm{Li}(x)\)
\(10^2\) 25 25.66 30.13
\(10^3\) 168 168.36 177.61
\(10^4\) 1229 1226.93 1246.14
\(10^5\) 9592 9587.43 9629.81
\(10^6\) 78498 78527.40 78627.55

A tempting refinement subtracts the zero terms, \(H_N(x)=R(x)-2\sum_{k\le N}\Re\,R(x^{\rho_k})\). It is not a reliable approximation: at \(x=1000\) the error moves from \(+0.138\) with 10 zero pairs to \(-0.241\) with 100, and Grobner proves that this series diverges under height ordering (Grobner 2026). The correct route corrects \(J(x)=\sum_{p^a\le x}1/a\) by the explicit formula and then applies Möbius inversion. At the jump \(x=7\) this gives \(3.4943\) with 100 zero pairs and \(3.5001\) with 1000, converging to the midpoint value \(3.5\). Error terms of truncated explicit formulas are analysed in (Cully-Hugill and Johnston 2021; Doron 1995).

8 Discussion

The experiments show the explicit formula as an exact two-way spectral pair with a hard resolution limit on each side: a finite list of primes blurs the zeros, and a finite list of zeros blurs the primes. The same limit governs any spectral analysis of a finite time series, which is the practical lesson we draw for applied work. Nothing here bears on the truth of the Riemann hypothesis; all computations use zeros already known to lie on the critical line.

Reproducibility

Code, cached zeros and results are at https://github.com/suenot/riemann-explicit-formula. Three commands reproduce and check everything:

Baillie, Robert. 2011. “Experiments with Zeta Zeros and Perron’s Formula.” arXiv:1103.6226. https://arxiv.org/abs/1103.6226.
Bohr, Harald. 1925. “Zur Theorie der fastperiodischen Funktionen. I. Eine Verallgemeinerung der Theorie der Fourierreihen.” Acta Mathematica 45: 29–127. https://doi.org/10.1007/BF02395468.
Cully-Hugill, Michaela, and Daniel R. Johnston. 2021. “On the Error Term in the Explicit Formula of Riemann–von Mangoldt.” arXiv:2111.10001. https://arxiv.org/abs/2111.10001.
Davis, John M., and Paul Hagelstein. 2022. “Gibbs Phenomena for Some Classical Orthogonal Polynomials.” Journal of Mathematical Analysis and Applications 505 (1): 125574. https://doi.org/10.1016/j.jmaa.2021.125574.
Doron, Eyal. 1995. “Do Spectral Trace Formulae Converge?” arXiv:chao-dyn/9502025. https://arxiv.org/abs/chao-dyn/9502025.
Grobner, Harald. 2026. “On Divergence Related to Riemann–von Mangoldt’s Explicit Formula of the Prime-Counting Function.” arXiv:2609.02713v2. https://arxiv.org/abs/2609.02713v2.
Kedlaya, Kiran S. n.d. “von Mangoldt’s Formula.” Notes on Analytic Number Theory. https://kskedlaya.org/ant/chap-von-mangoldt.html.
Landau, Edmund. 1912. “Über die Nullstellen der Zetafunktion.” Mathematische Annalen 71 (4): 548–64. https://doi.org/10.1007/BF01456808.
Main, Jörg, Vladimir A. Mandelshtam, Günter Wunner, and Howard S. Taylor. 1998. “Harmonic Inversion as a General Method for Periodic Orbit Quantization.” Nonlinearity 11 (4): 1015–35. https://doi.org/10.1088/0951-7715/11/4/014.
Mazur, Barry, and William Stein. 2016. Prime Numbers and the Riemann Hypothesis. Cambridge University Press. https://doi.org/10.1017/CBO9781316182277.
Odlyzko, Andrew M. 1987. “On the Distribution of Spacings Between Zeros of the Zeta Function.” Mathematics of Computation 48 (177): 273–308. https://doi.org/10.1090/S0025-5718-1987-0866115-0.
Platt, Dave, and Tim Trudgian. 2021. “The Riemann Hypothesis Is True up to \(3\cdot10^{12}\).” Bulletin of the London Mathematical Society 53 (3): 792–97. https://doi.org/10.1112/blms.12460.
Riesel, Hans, and Gunnar Göhl. 1970. “Some Calculations Related to Riemann’s Prime Number Formula.” Mathematics of Computation 24 (112): 969–83. https://doi.org/10.1090/S0025-5718-1970-0277489-3.
Sakhr, Jamal, Rajat K. Bhaduri, and Brandon P. van Zyl. 2003. “Zeta Function Zeros, Powers of Primes, and Quantum Chaos.” Physical Review E 68: 026206. https://doi.org/10.1103/PhysRevE.68.026206.
Weil, André. 1952. “Sur Les "formules explicites" de La Théorie Des Nombres Premiers.” Meddelanden Från Lunds Universitets Matematiska Seminarium, 252–65.