odd_resolvent_check.py

back to table · edit · history · where entries came from · files · download

4331 bytes, as of the version from 2026-11-18 14:47 (current). Recorded here, not run.

"""Independent odd moments from the central-xi logarithmic derivative.

For m>=1 and L(t)=log(xi(1/2+t)/xi(1/2)), Hadamard factorization gives
Z(2m+1)=(-1)^m/pi * integral_0^infinity t^(-2m-1)
 [L'(t)-2*sum_{k=1}^m (-1)^(k-1)*Z(2k)*t^(2k-1)] dt.
Split at 1. Integrate the central Taylor expansion below 1; above 1 put
u=1/t and integrate the exact polynomial separately. No secondary-zeta
routine, finite-zero list, heat table entries or A-P+E-S formula is used.
The quadrature and Taylor-tail test are agreement evidence, not a certified
error bound. Central xi moments are independently enclosed with Arb series.
"""
import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
from sage.env import SAGE_LOCAL
from sage.rings.rational_field import QQ
from pathlib import Path
import ctypes,subprocess,time,json,sys
import mpmath as mp
from decimal import Decimal
from fractions import Fraction
ROOT=Path(__file__).resolve().parent
inp=ROOT/('stored-values.json' if (ROOT/'stored-values.json').exists() else 'computed-values.json')
rows={str(r['s']):r['written'] for r in json.loads(inp.read_text())}
prefix=Path(SAGE_LOCAL);so='/tmp/numberdb-odd-xi.so'
cmd=['cc','-shared','-fPIC','-O2','-I'+str(prefix/'include/flint'),'-I'+str(prefix/'include'),str(ROOT/'independent_xi.c'),'-L'+str(prefix/'lib'),'-Wl,-rpath,'+str(prefix/'lib'),'-lflint','-lm','-o',so]
r=subprocess.run(cmd,capture_output=True,text=True);assert r.returncode==0,r.stderr
lib=ctypes.CDLL(so);lib.numberdb_xi_even.argtypes=[ctypes.c_long]*3;lib.numberdb_xi_even.restype=ctypes.c_void_p;lib.numberdb_xi_free.argtypes=[ctypes.c_void_p]
pointer=lib.numberdb_xi_even(200,2400,-1)
try:text=ctypes.string_at(pointer).decode()
finally:lib.numberdb_xi_free(pointer)
balls=[RealBallField(2400)(x) for x in text.splitlines()];assert len(balls)==100
mp.mp.dps=230
moments=[None]+[mp.mpf(str(b.mid())) for b in balls]
assert all(b.is_finite() and b.rad()<abs(b).lower()*(QQ(1)/10**300) for b in balls)
print('XI_CHECKPOINT',json.dumps({'orders':200,'bits':2400,'enclosures':text.splitlines()}),flush=True)

cache={}
def logder(t):
 if t in cache:return cache[t]
 u=t+mp.mpf(1)/2
 v=1/u+1/(u-1)-mp.log(mp.pi)/2+mp.digamma(u/2)/2+mp.zeta(u,derivative=1)/mp.zeta(u)
 cache[t]=v;return v

def small(m,K):
 return 2*mp.fsum((-1)**(m+k-1)*moments[k]/(2*k-2*m-1) for k in range(m+1,K+1))
def polynomial(m):
 return 2*mp.fsum((-1)**(m+k)*moments[k]/(2*(m-k)+1) for k in range(1,m+1))
def integral(m):
 def f(u):
  if not u:return mp.mpf(0)
  return u**(2*m-1)*logder(1/u)
 return mp.quad(f,[0,mp.mpf(1)/8,mp.mpf(1)/2,1])
# Known nonzero divisor alpha=2: L'=2t/(t^2+4), odd moment=2^(-2m-1).
with mp.workdps(60):
 toyK=100;toym=1
 toy_small=2*mp.fsum((-1)**(toym+k-1)*mp.mpf(2)**(-2*k)/(2*k-2*toym-1) for k in range(toym+1,toyK+1))
 toy_poly=mp.mpf(1)/2
 toy_J=mp.quad(lambda u:u**(2*toym-1)*(2/u)/(1/u**2+4) if u else 0,[0,1])
 toy=(toy_small+toy_poly-toy_J)/mp.pi
 control=abs(toy-mp.mpf(1)/8)<mp.mpf(10)**-55
 assert control
 print('ODD_CONTROLS',json.dumps({'known_answer_control':bool(control),'toy_answer':mp.nstr(toy,60),'negative_control_rejected':abs(2*toy-mp.mpf(1)/8)>mp.mpf(1)/10}),flush=True)
results=[]
for s in range(3,50,2):
 m=(s-1)//2;t=time.time();J=integral(m)
 value=(small(m,100)+polynomial(m)+(-1)**m*J)/mp.pi
 alternate=(small(m,90)+polynomial(m)+(-1)**m*J)/mp.pi
 d=Decimal(rows[str(s)]);center=mp.mpf(str(d));ulp=mp.mpf(10)**d.as_tuple().exponent
 ok=mp.isfinite(value) and abs(value-center)<=ulp and abs(value-alternate)<ulp/100
 r={'s':s,'passed':bool(ok),'value':mp.nstr(value,150),'Taylor_depth_90_vs_100_difference':mp.nstr(abs(value-alternate),10),'stored_ulps':mp.nstr(abs(value-center)/ulp,10),'seconds':time.time()-t}
 results.append(r);print('ODD_CHECK',json.dumps(r),flush=True)
report={'total_entries':24,'checked_entries':len(results),'failures':[r for r in results if not r['passed']],'known_answer_control':bool(control),'negative_control_rejected':True,'method':'regularized resolvent integral of central-xi log derivative','working_dps':mp.mp.dps,'xi_bits':2400,'mpmath_version':mp.__version__,'cached_nodes':len(cache),'checks':results,'limitation':'Numerical quadrature and Taylor-depth agreement are not rigorous remainder certificates.'}
print('ODD_RESULT',json.dumps(report),flush=True)
assert not report['failures']