"""Verify the shared scalar constants using Python, mpmath and integer arithmetic. The only prime distribution input is the published interval discrepancy Delta(log x) for the sum of 1/p. See the product argument in the manuscript. All displayed inequalities below are tested on outward interval endpoints. """ from math import isqrt from mpmath import iv iv.dps = 45 I = iv.mpf T = 1_090_697 SCALE = 10**42 def odd_primes(limit): sieve = bytearray([1]) * (limit + 1) sieve[:2] = bytes(2) for n in range(2, isqrt(limit) + 1): if sieve[n]: sieve[n*n::n] = bytes((limit - n*n)//n + 1) return [n for n in range(3, limit + 1, 2) if sieve[n]] def discrepancy(log_x): return (2*iv.exp(-log_x/2) + I(".0000098"))/log_x + iv.exp(-log_x) def tail(x): # Sum_{n>=x} 2/((n-1)(n-2)) <= 2/(x-3) for x>3. return discrepancy(iv.ln(x)) + I(2)/(x-3) def multiply_local(lower, upper, prime): numerator = prime - 2 denominator = prime - 1 return (lower*numerator//denominator, (upper*numerator + denominator - 1)//denominator) def verify_products(primes): # Soft product with only 3 and 11 omitted. Removing more primes can # only decrease any inverse product over a fixed interval [u,Z). lower = upper = SCALE greatest = I(0) peak = 0 count = 0 for p in primes: log_p = iv.ln(p) if p == T: anchor_lower = (log_p*lower/SCALE).a break value_upper = (log_p*upper/SCALE).b if value_upper > greatest: greatest, peak = value_upper, p if p >= 13: count += 1 if p not in (3, 11): lower, upper = multiply_local(lower, upper, p) assert primes[-1] == T and count == 85_015 and peak == 1_090_681 assert greatest < anchor_lower assert iv.exp(tail(T)) < I("1.0002") # The function V_soft(x) log x increases between consecutive primes, # and takes its pre-jump value at p. Its limit at x=1 is zero. print("Fixed outer product: 85015 endpoints from 13 to T, plus the small primes; kappa = 1.0002.") # For v>=x, V(v)log v >= V(x)log x*exp(-tail(x)). These V products # use every odd prime, including the hard primes in the preceding test. for x, required in ((41, ".58"), (97, ".65"), (10_000, ".738")): lower = upper = SCALE for p in primes: if p >= x: break lower, upper = multiply_local(lower, upper, p) bound = I(lower)/SCALE * iv.ln(x) * iv.exp(-tail(x)) assert bound > I(required) print(f"V(v) log v > {required} for v >= {x}.") def verify_source(): coefficient = I(3)/5 peak = I(4)/45 B = iv.sqrt(I(35))/2 s = I(1)/2 + B log2 = iv.ln(2) raw_slope = coefficient/(2*B) euler_bound = 2**(-s)*log2 + 2**(1-s)*(log2/(s-1) + 1/(s-1)**2) raw_nonprincipal = coefficient/B*(iv.ln((s+1)/(2*iv.pi))/2 + euler_bound) raw_principal = coefficient/B*(1/s + 1/(s-1) + iv.ln(s/(2*iv.pi))/2) assert raw_slope < I(".101419") assert raw_nonprincipal < I("-.005490") and raw_principal < I(".080612") # Check the shifted contour constant without a table of gamma values. # In the convergent digamma series, take J=ceil(2+|t|). For # 3/4<=Re w<=5/4 and |Im w|=|t|/2 the first J absolute terms are # <= 10/3+2log J and the tail is <= J sum_{n>=J} n^-2 <= 3/2. # Use log J <= log(3/2)+log(2+|t|). One gamma factor may need # one recurrence, with |1/w|<=4. The other gamma factor needs none. psi_base = iv.euler + I(10)/3 + I(3)/2 + 2*iv.ln(I(3)/2) # At 3/2 the absolute logarithmic derivative is bounded by the # integral of (log x)x^-3/2 on [1,infty) plus twice its maximum. zeta_base = 4 + 2/(I("1.5")*iv.exp(1)) assert iv.ln(iv.pi) + psi_base + 2 + zeta_base < 40 # |W_A(-1/2+it)|<=min(1,t^-2); integrate log(2+t) using # log(2+t)<=log 3 (t<=1), <=log 3+log t (t>=1). assert 2/iv.pi < 2 assert (80 + 6*(2*iv.ln(3)+1))/iv.pi < 200 # At L>=42.83 all following expressions decrease. A term L^j exp(-bL) # decreases when L>=j/b. The worst source cutoff is Y<=N^.45. L = I("42.83") ratio = I(".45") assert L > 4 and L > 4*2 small_powers = coefficient*iv.ln(4)*( iv.exp((3*ratio-I("2.5"))*L) + iv.exp((5*ratio-I("2.5"))*L)) higher_powers = peak*iv.ln(4)*( iv.exp(-L/6) + L/log2*iv.exp(-L/4)) target_primes = peak*L**2/log2*iv.exp(-L/2) trivial_residue = iv.exp(-L/2) # Compact conductors have log f<=2000, and on the infinite range # log f<=log165+.49L. The following sum dominates either case. contour = 2*(I(2100) + iv.ln(165) + I(".49")*L)*iv.exp(-L) total = small_powers + higher_powers + target_primes + trivial_residue + contour assert total < I(".000333") assert raw_nonprincipal + total < 0 and raw_principal + total < I(".082") print("Filtered source: error allowance < .000333 sqrt(N); (c1,c0,cP)=(.101419,0,.082).") if __name__ == "__main__": verify_products(odd_primes(T)) verify_source()