The centered prime sum and the explicit formula#

This notebook recomputes the numbers behind 4 · The centered prime sum: the centered prime sum \(G(y)\) from a sieve, the constant \(\log 2\pi\) and the band \(2+\gamma-\log 4\pi\) that RH would force, the first zeros of \(\zeta\), and the agreement between the prime side and the zero side of the explicit formula. Every number quoted in the text is computed here and compared with assets/figures/facts.json, from which the atlas figures were drawn.

The statistic, from a sieve#

\(G(y)=\sum_{n\le y}\Lambda(n)(y/n-1)-y\log y+(1+\gamma)y\) is evaluated from cumulative sums of \(\Lambda(n)\) and \(\Lambda(n)/n\) up to \(10^7\). As a check, it agrees with the naive definition at a few points:

ps = rhlib.PrimeSums.build(10_000_000)
rows = []
for y in (2.0, 10.5, 97.3, 1000.0, 12345.6):
    fast, naive = float(ps.G(y)), rhlib.centered_prime_sum_naive(y)
    rows.append((y, fast, naive, abs(fast - naive)))
    assert abs(fast - naive) < 1e-7 * max(1.0, y)
for r in rows:
    print(f"y = {r[0]:>8}:  G(y) = {r[1]: .9f}  naive {r[2]: .9f}  |diff| {r[3]:.0e}")
y =      2.0:  G(y) =  1.768136969  naive  1.768136969  |diff| 0e+00
y =     10.5:  G(y) =  1.833142009  naive  1.833142009  |diff| 2e-15
y =     97.3:  G(y) =  1.799195155  naive  1.799195155  |diff| 0e+00
y =   1000.0:  G(y) =  1.530913336  naive  1.530913336  |diff| 0e+00
y =  12345.6:  G(y) =  0.999913619  naive  0.999913619  |diff| 1e-10

Where \(\log 2\pi\) and the band come from#

From the explicit formula (see 4 · The centered prime sum),

\[ G(y)=\log 2\pi-\sum_\rho\frac{y^\rho}{\rho(\rho-1)}-\sum_{n\ge1}\frac{y^{-2n}}{2n(2n+1)}, \]

and under RH \(|G(y)-\log2\pi|\le(2+\gamma-\log4\pi)\sqrt y+O(y^{-2})\).

log2pi, band = rhlib.LOG_2PI, rhlib.RH_BAND
print(f"log 2π              = {log2pi:.10f}")
print(f"2 + γ − log 4π      = {band:.10f}")
assert round(band, 6) == fx['hero']['rh_band'] and round(log2pi, 4) == fx['ramp']['log_2pi']
log 2π              = 1.8378770664
2 + γ − log 4π      = 0.0461914179

The first zeros of \(\zeta\)#

The zeros are located by bisection on Hardy’s function \(Z(t)=e^{i\vartheta(t)}\zeta(\tfrac12+it)\), with \(\zeta\) computed by Euler–Maclaurin summation. A sanity check is the Riemann–von Mangoldt formula \(N(T)=\vartheta(T)/\pi+1+S(T)\): in this range the counts differ from \(\vartheta(T)/\pi+1\) by less than one.

zeros = rhlib.zeta_zeros(100)
print("first five:", ", ".join(f"{g:.6f}" for g in zeros[:5]))
print(f"100th     : {zeros[99]:.6f}")
for T in (30.0, 50.0, 100.0, 150.0, 200.0, 230.0):
    count = sum(1 for g in zeros if g < T)
    smooth = rhlib.rs_theta(T) / math.pi + 1
    print(f"T = {T:3.0f}:  N(T) = {count:3d},  θ(T)/π + 1 = {smooth:7.3f},  S(T) ≈ {count - smooth:+.3f}")
    assert abs(count - smooth) < 1
assert round(zeros[0], 6) == fx['zeros']['first'] and round(zeros[99], 6) == fx['zeros']['hundredth']
assert len(zeros) == fx['zeros']['count']
first five: 14.134725, 21.022040, 25.010858, 30.424876, 32.935062
100th     : 236.524230
T =  30:  N(T) =   3,  θ(T)/π + 1 =   3.565,  S(T) ≈ -0.565
T =  50:  N(T) =  10,  θ(T)/π + 1 =   9.423,  S(T) ≈ +0.577
T = 100:  N(T) =  29,  θ(T)/π + 1 =  29.002,  S(T) ≈ -0.002
T = 150:  N(T) =  52,  θ(T)/π + 1 =  52.746,  S(T) ≈ -0.746
T = 200:  N(T) =  79,  θ(T)/π + 1 =  79.193,  S(T) ≈ -0.193
T = 230:  N(T) =  96,  θ(T)/π + 1 =  96.057,  S(T) ≈ -0.057

The first zero has ordinate 14.134725 and the hundredth 236.524230.

The normalized prime sum up to \(10^7\)#

The quantity \(r(y)=(G(y)-\log2\pi)/\sqrt y\) is sampled at 400,000 logarithmically spaced points of \([10,10^7]\) (the same sampling as the atlas’s title figure).

hero = fx['hero']
ys = np.exp(np.linspace(math.log(hero['y_min']), math.log(hero['y_max']), hero['samples']))
r = (ps.G(ys) - log2pi) / np.sqrt(ys)
r_min, r_max = float(r.min()), float(r.max())
y_min_at, y_max_at = float(ys[np.argmin(r)]), float(ys[np.argmax(r)])
print(f"min r = {r_min:+.5f} at y ≈ {y_min_at:,.1f}")
print(f"max r = {r_max:+.5f} at y ≈ {y_max_at:,.1f}")
print(f"RH band ±{band:.5f};  largest |r| / band = {max(abs(r_min), r_max) / band:.3f}")
assert round(r_min, 5) == hero['r_min'] and round(r_max, 5) == hero['r_max']
assert round(y_min_at, 1) == hero['y_at_min'] and round(y_max_at, 1) == hero['y_at_max']
assert -band < r_min < r_max < band
min r = -0.02268 at y ≈ 319,441.4
max r = +0.01867 at y ≈ 3,099.7
RH band ±0.04619;  largest |r| / band = 0.491
_images/94b0a0eafa2c75b231f3ee6d8c4d0cf6cf0c6f7f85c099789352b80c70c57603.svg

The extreme values are -0.02268 and +0.01867, at most 0.49 of the band \(\pm\)0.046191. This is what RH predicts; it is of course not evidence about larger \(y\).

The sum over zeros reproduces the oscillation#

Truncating the explicit formula at the first \(K\) zeros (RH is not assumed: the zeros used were found on the line) and comparing with the prime side on \([100,2\cdot10^6]\):

ex = fx['explicit']
ys2 = np.exp(np.linspace(math.log(ex['y_range'][0]), math.log(ex['y_range'][1]), 1600))
g2 = (ps.G(ys2) - log2pi) / np.sqrt(ys2)
errs = {}
for K in (10, 25, 50, 100):
    ef = (rhlib.explicit_formula_G(ys2, zeros[:K]) - log2pi) / np.sqrt(ys2)
    errs[K] = float(np.max(np.abs(g2 - ef)))
    print(f"K = {K:3d} zeros (up to γ = {zeros[K - 1]:7.3f}):  max |difference| / √y = {errs[K]:.5f}")
assert round(errs[100], 5) == ex['max_abs_difference_normalized'] and ex['zeros_used'] == 100
K =  10 zeros (up to γ =  49.774):  max |difference| / √y = 0.00450
K =  25 zeros (up to γ =  88.809):  max |difference| / √y = 0.00191
K =  50 zeros (up to γ = 143.112):  max |difference| / √y = 0.00130
K = 100 zeros (up to γ = 236.524):  max |difference| / √y = 0.00064

With a hundred zeros the two sides agree to 0.00064 in the normalized scale (with ten zeros, to 0.0045). The dashed curve below is what a single hypothetical zero at \(\rho=0.62+40i\) would add: its normalized contribution grows like \(y^{0.12}\), so it would eventually leave any band — in both directions.

_images/e251582d08512ff98f75b7aa4d1c5201649528b98303fdc8d460efdbc791db9a.svg

How strong is the window condition, numerically#

Under RH, Schoenfeld’s bound \(|\psi(t)-t|<\sqrt t\log^2t/(8\pi)\) \((t\ge73.2)\) integrates to \(|G(x)|\le\frac{\sqrt x}{8\pi}(2\log^2x+8\log x+16)\) for \(x\ge73.2\) (How strong is the window condition?). On the sampled range the computed \(|G|\) uses only a tiny fraction of this allowance:

mask = ys >= 73.2
bound = np.sqrt(ys[mask]) / (8 * math.pi) * (2 * np.log(ys[mask]) ** 2 + 8 * np.log(ys[mask]) + 16)
ratio = np.abs(ps.G(ys[mask])) / bound
print(f"max |G(x)| / bound on [73.2, 10^7]: {ratio.max():.2e} (at x ≈ {ys[mask][np.argmax(ratio)]:,.0f})")
assert ratio.max() < 1
max |G(x)| / bound on [73.2, 10^7]: 6.05e-02 (at x ≈ 75)

The largest ratio is 6.0e-02. The one-sided window premise of the first verified cut is thus satisfied with an enormous margin wherever we can compute — which says nothing about all \(x\), and is exactly why that premise is as hard as RH itself.