#!/usr/bin/env python3 """Reproduce the class-one paper's enclosure using Arb/Acb. Run: python enclosure.py (with the dependency in requirements.txt). RH is used for the tail and hence for mu{0}, r_*, and the numerator. Every decimal input is passed to Arb as a string. Euler–Maclaurin: https://dlmf.nist.gov/25.2#E9 Bernoulli Fourier series: https://dlmf.nist.gov/24.8#E1 Hardy Z: https://dlmf.nist.gov/25.10#E1 """ from math import factorial import flint from flint import acb, arb, ctx, fmpq HEIGHT = 32 ORDINATE_LEFT = ( "14.134725141734693790457251983562", "21.022039638771554992628479593896", "25.010857580145688763213790992562", "30.424876125859513210311897530584", ) def require(condition, message): if not condition: raise ArithmeticError(message) class EulerMaclaurinZeta: """Sum through N-1 and start the Euler–Maclaurin tail at N.""" def __init__(self, cutoff, terms): self.cutoff = cutoff self.logs = [arb(k).log() for k in range(2, cutoff)] self.log_cutoff = arb(cutoff).log() self.coefficients = [ arb(fmpq.bernoulli(2 * k) / factorial(2 * k)) for k in range(1, terms + 1) ] def __call__(self, s): # DLMF 25.2.9, using the equivalent even-order remainder. n_to_minus_s = (-s * self.log_cutoff).exp() cutoff = self.cutoff total = 1 + sum((-s * log_k).exp() for log_k in self.logs) total += n_to_minus_s * (cutoff / (s - 1) + arb(1) / 2) rising = s power = n_to_minus_s / cutoff for k, coefficient in enumerate(self.coefficients, start=1): total += coefficient * rising * power rising *= s + 2 * k - 1 if k < len(self.coefficients): rising *= s + 2 * k power /= cutoff**2 # With m terms, the remainder in modulus is at most # |(s)_{2m}| * |B_{2m}|/(2m)! * integral_N^infty x^(-Re(s)-2m) dx. # The cosine series for the periodic Bernoulli polynomial bounds # its modulus by |B_{2m}|, the modulus attained at the integers. # At this point power = N^(1-s-2m), rising = (s)_{2m}. exponent = s.real + 2 * len(self.coefficients) - 1 require(exponent > 0, "Euler–Maclaurin remainder integral must converge") bound = abs(rising) * abs(self.coefficients[-1]) * abs(power) / exponent error = arb(0, bound.abs_upper()) return total + acb(error, error) def sign(x): if x > 0: return 1 if x < 0: return -1 return 0 def quadrant(z): real_sign, imag_sign = sign(z.real), sign(z.imag) require(real_sign and imag_sign, f"Uncertified endpoint quadrant: {z}") return { (1, 1): 0, (-1, 1): 1, (-1, -1): 2, (1, -1): 3, }[real_sign, imag_sign] def edge_count(rotated_zeta, start, end, q_start, q_end, depth=0): image = rotated_zeta(start.union(end)) if image.is_finite() and (sign(image.real) or sign(image.imag)): # A lift of the argument on a coordinate half-plane meets only # two neighboring quadrants. Its change in quadrant index is # therefore the signed representative of q_end - q_start mod 4. increment = (q_end - q_start + 1) % 4 - 1 require(increment != 2, "Opposite quadrants in one half-plane") return increment, 1 require(depth < 24, "Contour segment could not be certified after bisection") midpoint = (start + end) / 2 q_midpoint = quadrant(rotated_zeta(midpoint)) first, first_segments = edge_count( rotated_zeta, start, midpoint, q_start, q_midpoint, depth + 1 ) second, second_segments = edge_count( rotated_zeta, midpoint, end, q_midpoint, q_end, depth + 1 ) return first + second, first_segments + second_segments def count_zeros(): zeta = EulerMaclaurinZeta(cutoff=24, terms=18) rotation = acb(1, arb("0.2718281828459045235")) left = arb(1) / 4 corners = (acb(left, -HEIGHT), acb(2, -HEIGHT), acb(2, HEIGHT), acb(left, HEIGHT)) def rotated_zeta(s): return rotation * zeta(s) quadrants = [quadrant(rotated_zeta(s)) for s in corners] increments = [] print("Contour: 1/4 <= Re(s) <= 2, |Im(s)| <= 32, counterclockwise") print("Euler–Maclaurin: cutoff 24, 18 corrections; rotation 1 + 0.2718281828459045235i") for i, name in enumerate(("bottom", "right", "top", "left")): j = (i + 1) % 4 increment, segments = edge_count( rotated_zeta, corners[i], corners[j], quadrants[i], quadrants[j] ) increments.append(increment) print(f" {name:6s} {segments:5d} certified segments, quadrant increment {increment:+d}") require(sum(increments) % 4 == 0, "Closed contour did not give a whole winding") winding = sum(increments) // 4 # The only pole of zeta is the simple pole at 1, inside the contour. zeros = winding + 1 print(f"Winding number = {winding}; zeros with multiplicity = {zeros}") require(increments == [0, 0, -1, 29], "Paper's quadrant increments did not reproduce") require(winding == 7 and zeros == 8, "Paper's winding or zero count did not reproduce") return zeros def isolate_ordinates(zero_count, pi): zeta = EulerMaclaurinZeta(cutoff=128, terms=50) log_pi = pi.log() quarter = arb(1) / 4 width = arb("1e-30") def hardy(t): # lgamma is analytic on Re(z)>0 and agrees with the real logarithm # on the positive real axis. Z(t) is real by the functional equation. phase = acb(quarter, t / 2).lgamma().imag - t * log_pi / 2 return (acb(0, phase).exp() * zeta(acb(arb(1) / 2, t))).real intervals = [] previous = arb(0) print("Hardy Z: cutoff 128, 50 corrections; interval width 1e-30") for endpoint in ORDINATE_LEFT: lo = arb(endpoint) hi = lo + width require(previous < lo and hi < HEIGHT, "Ordinates must be disjoint and inside (0, 32)") previous = hi z_lo, z_hi = hardy(lo), hardy(hi) print(f" left endpoint {endpoint}") print(f" Z(left) = {z_lo.str(18)}") print(f" Z(right) = {z_hi.str(18)}") require(sign(z_lo) * sign(z_hi) == -1, "Hardy Z sign change did not certify") # Bound the oscillation across the entire interval by the mean-value theorem. psi = acb(quarter, lo.union(hi) / 2).digamma() phase_bound = abs((psi.real - log_pi) / 2).abs_upper() * width print(f" Phase variation bounded above by {phase_bound.str(18)} rad") require(phase_bound < arb("20e-30"), "Paper's phase variation bound did not certify") intervals.append((lo, hi)) # The sign changes and conjugation already account for eight zeros. # Counting multiplicity forces each of these eight zeros to be simple. # Any nontrivial zero outside the rectangle with |Im(s)| <= 32 # would reflect by the functional equation into the rectangle. require(2 * len(intervals) == zero_count, "Conjugate pairs did not exhaust the count") print("Four simple positive ordinates and their conjugates exhaust the count.") return intervals def real_point_bounds(intervals, pi): log_two_pi = (2 * pi).log() require(log_two_pi > 0, "Monotonicity of r_* requires log(2*pi) > 0") # For xi(s) = s(s-1) pi^(-s/2) Gamma(s/2) zeta(s)/2, # xi'/xi(1) = 1 + EulerGamma/2 - log(4*pi)/2, using the Laurent # constant of zeta at 1 and psi(1/2) = -EulerGamma - 2*log(2). # xi(s) = xi(1-s) gives D0 = 2*xi'/xi(1) by the Hadamard identity. d0 = 2 + arb.const_euler() - (4 * pi).log() d0_cap = arb(1) / 20 print(f"Under RH, D0 = {d0.str(25)}") require(0 < d0 and d0 < d0_cap, "D0 must lie in (0, 1/20)") # cosh(pi*t) >= exp(pi*t)/2 for t >= 0. The log derivative of # (1/4+t^2)^2 exp(-pi*t) is <= 4/t - pi for t >= HEIGHT. # Sum the squares of the positive D0 summands using sum(a_j^2) <= D0^2. require(arb(4) / HEIGHT < pi, "Tail majorant must decrease past 32") tail_bound = 2 * pi * (arb(1) / 4 + HEIGHT**2)**2 * (-pi * HEIGHT).exp() * d0_cap**2 print(f"Tail bound from D0 < 1/20 = {tail_bound.str(26)}") require(tail_bound < arb("3.605e-40"), "Paper's tail bound did not certify") # The weight decreases for positive t, and there are two zeros per pair. # Retain separate balls for the bound expressions to preserve their digits. mu_lo = sum(2 * pi / (pi * hi).cosh() for _, hi in intervals) mu_hi = sum(2 * pi / (pi * lo).cosh() for lo, _ in intervals) + tail_bound print(f"mu{{0}} lower bound expression = {mu_lo.str(45)}") print(f"mu{{0}} upper bound expression = {mu_hi.str(45)}") require( arb("6.5181605e-19") < mu_lo and mu_hi < arb("6.5181615e-19"), "Paper's rounded mu{0} did not certify", ) print("mu{0} rounds to 6.518161e-19") r_lo = 1 + 2 * log_two_pi / mu_hi r_hi = 1 + 2 * log_two_pi / mu_lo print(f"r_* lower bound expression = {r_lo.str(45)}") print(f"r_* upper bound expression = {r_hi.str(45)}") require( arb("5639249912025015212.748") < r_lo and r_hi < arb("5639249912025015212.752"), "Paper's r_* enclosure did not certify", ) require( arb(5639249912025015212) < r_lo and r_hi < arb(5639249912025015213), "r_* is not certified between the stated consecutive integers", ) print("5639249912025015212.748 < r_* < 5639249912025015212.752") print("These bounds are strictly between 5639249912025015212 and 5639249912025015213.") # The numerator at r is binom(r, 2) mu{0} - r log(2*pi). numerator = (3 * mu_lo - 3 * log_two_pi).union(3 * mu_hi - 3 * log_two_pi) print(f"Numerator at r = 3: {numerator.str(45)}") require( arb("-5.5145") < numerator and numerator < arb("-5.5135"), "Paper's rounded r = 3 numerator did not certify", ) print("Numerator at r = 3 rounds to -5.514") def main(): ctx.prec = 256 print(f"python-flint {flint.__version__}, {ctx.prec}-bit working precision") pi = arb.pi() zero_count = count_zeros() intervals = isolate_ordinates(zero_count, pi) real_point_bounds(intervals, pi) if __name__ == "__main__": main()