back to table · edit · history · where entries came from · files · download
7169 bytes, as of the version from 2026-11-18 22:18 (current). Recorded here, not run.
"""Independent Laurent coefficients from the central-xi resolvent Mellin integral.
Let D(t)=d/dt log xi(1/2+t). For 1<Re(s)<2, the central Hadamard product
gives Z(s)=sin(pi*s/2)/pi * integral_0^infty t^(-s)*D(t)dt.
For z=s-1 subtract D(t)'s large-t term (log(t)-log(2*pi))/2 at t>=1.
Then Z(1+z)=cos(pi*z/2)/pi*(1/(2*z^2)-log(2*pi)/(2*z)+I(z)).
I_n=[z^n]I comes from logarithmic moments of the subtracted integral.
Below t=1 use fresh central-xi Arb power series, never T752 rows. On
1<=t<=1024 use composite Gauss-Legendre integration in u=log(t), with
mpmath zeta derivatives and digamma. Beyond 1024 integrate the inverse-power
digamma expansion analytically. Quadrature and tail-depth agreement are
heuristic checks, not a second rigorous certificate. Neither the secondary
evaluator nor its A-P+E-S decomposition or zeros are used here.
"""
import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
from sage.rings.rational_field import QQ
from sage.env import SAGE_LOCAL
from pathlib import Path
import ctypes,subprocess,json,sys,time,math
from decimal import Decimal
import mpmath as mp
ROOT=Path(__file__).resolve().parent
inp=ROOT/('stored-values.json' if (ROOT/'stored-values.json').exists() else 'computed-values.json')
rows=json.loads(inp.read_text())
prefix=Path(SAGE_LOCAL);so='/tmp/numberdb-laurent-independent-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]
ptr=lib.numberdb_xi_even(200,2400,-1)
try:raw=ctypes.string_at(ptr).decode()
finally:lib.numberdb_xi_free(ptr)
balls=[RealBallField(2400)(x) for x in raw.splitlines()]
assert len(balls)==100 and 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':raw.splitlines()}),flush=True)
def convolution(I,n,A=mp.mpf(1)/2,B=None):
if B is None:B=-mp.log(2*mp.pi)/2
cos=lambda j: (-1)**(j//2)*(mp.pi/2)**j/mp.factorial(j) if j%2==0 else mp.mpf(0)
return (mp.fsum(cos(j)*I[n-j] for j in range(0,n+1,2))+A*cos(n+2)+B*cos(n+1))/mp.pi
def run(dps,nodes,K):
mp.mp.dps=dps;start=time.time();mom=[None]+[mp.mpf(str(b.mid())) for b in balls]
small=[2*mp.fsum((-1)**(k-1)*mom[k]/mp.mpf(2*k-1)**(n+1) for k in range(1,K+1)) for n in range(21)]
x,w=mp.gauss_quadrature(nodes,'legendre')
T=mp.mpf(1024);L=mp.log(T);panels=16
integ=[mp.mpf(0)]*21
for panel in range(panels):
a=L*panel/panels;b=L*(panel+1)/panels
for j in range(nodes):
u=(a+b)/2+(b-a)*x[j]/2;t=mp.exp(u);v=t+mp.mpf(1)/2
D=1/v+1/(v-1)-mp.log(mp.pi)/2+mp.digamma(v/2)/2+mp.zeta(v,derivative=1)/mp.zeta(v)
f=(D-(u-mp.log(2*mp.pi))/2)*w[j]*(b-a)/2
power=mp.mpf(1)
for n in range(21):
integ[n]+=f*power
power*=u/(n+1)
print('INTEGRAL_PANEL',json.dumps({'dps':dps,'nodes':nodes,'panel':panel+1,'panels':panels,'seconds':time.time()-start}),flush=True)
# Bernoulli polynomials at 1/4, evaluated at the check's working precision.
bern=[mp.bernpoly(k,mp.mpf(1)/4) for k in range(1,K+1)]
acoef=[(1+(-1)**(k-1))*mp.mpf(1)/2**(k-1)+(-1)**(k-1)*mp.mpf(2)**(k-1)*bern[k-1]/k for k in range(1,K+1)]
tail=[mp.fsum(acoef[k-1]*mp.gammainc(n+1,k*L,mp.inf)/mp.factorial(n)/mp.mpf(k)**(n+1) for k in range(1,K+1)) for n in range(21)]
I=[small[n]+(-1)**n*(integ[n]+tail[n]) for n in range(21)]
c=[convolution(I,n) for n in range(21)]
print('INDEPENDENT_PASS',json.dumps({'dps':dps,'nodes':nodes,'depth':K,'seconds':time.time()-start,'coefficients':[mp.nstr(v,160) for v in c],'moments':[mp.nstr(v,160) for v in I]}),flush=True)
return c
first=run(170,80,80)
second=run(210,112,100)
checks=[];failures=[]
for row in rows:
form=row['params']['form'];n=int(row['params']['n']);factor=1 if form=='coefficient' else math.factorial(n)
value=second[n]*factor;other=first[n]*factor
d=Decimal(row.get('written',row.get('number')));center=mp.mpf(str(d));ulp=mp.mpf(10)**d.as_tuple().exponent
passed=mp.isfinite(value) and abs(value-center)<=ulp and abs(value-other)<ulp/100
check={'params':row['params'],'passed':bool(passed),'value':mp.nstr(value,150),'stored_ulps':mp.nstr(abs(value-center)/ulp,12),'two_pass_difference':mp.nstr(abs(value-other),12)}
checks.append(check)
if not passed:failures.append(check)
print('CHECK',json.dumps(check),flush=True)
# A one-zero mock divisor alpha=2 has Z(s)=2^(-s), with no principal part.
# Its Mellin integral is elementary; the moments are computed independently
# by quadrature, and convolved exactly as above.
with mp.workdps(65):
toyI=[]
for n in range(5):
f=lambda t:2*t/(t*t+4)/t*(-mp.log(t))**n/mp.factorial(n)
toyI.append(mp.quad(f,[0,1,2,mp.inf]))
toy=[convolution(toyI,n,A=0,B=0) for n in range(5)]
target=[(-mp.log(2))**n/(2*mp.factorial(n)) for n in range(5)]
known=all(abs(a-b)<mp.mpf('1e-55') for a,b in zip(toy,target))
negative=abs(2*toy[0]-target[0])>mp.mpf('0.4') and abs(2*toy[2]-target[2])>mp.mpf('0.1')
controls={'toy_coefficients':[mp.nstr(v,60) for v in toy],'toy_expected':[mp.nstr(v,60) for v in target],'missing_factor_two_rejected':bool(abs(2*toy[0]-target[0])>mp.mpf('0.4')),'missing_factorial_n2_rejected':bool(abs(2*toy[2]-target[2])>mp.mpf('0.1'))}
# Explicit target normalization controls at low and high order.
factorial_controls=all(abs(second[n]*math.factorial(n)-second[n])>abs(second[n])/2 for n in [2,20])
# Leading asymmetric pole sign contributes to c1; flipping it is detectable.
wrong_pole=abs(2*(-mp.log(2*mp.pi)/2)*(-mp.pi**2/8)/mp.pi)>mp.mpf('0.1')
report={'total_entries':len(rows),'checked_entries':len(checks),'failures':failures,'known_answer_control':bool(known),'negative_control_rejected':bool(negative and factorial_controls and wrong_pole),'controls':controls,'factorial_controls_n2_n20':bool(factorial_controls),'wrong_single_pole_sign_rejected':bool(wrong_pole),'checks':checks,'method':'central-xi resolvent Mellin logarithmic moments with analytic pole subtraction','independence':'Fresh Arb central series and mpmath digamma/zeta quadrature; no secondary-zeta routine, A-P+E-S implementation, rounded sibling values or finite zero list. Shared xi/Hadamard theory and underlying Arb for small-t moments are disclosed.','working_dps':[170,210],'Gauss_Legendre_nodes':[80,112],'central_and_tail_depths':[80,100],'split_t':1024,'mpmath_version':mp.__version__,'limitations':'Quadrature and asymptotic remainder depths are agreement checks, not rigorous independent error certificates. The generator separately provides rigorous balls and alias bounds.'}
print('INDEPENDENT_RESULT',json.dumps(report),flush=True)
assert known and negative and factorial_controls and wrong_pole and not failures