back to table · edit · history · where entries came from · files · download
7146 bytes, as of the version from 2026-11-18 22:18 (current). Recorded here, not run.
"""T753: Laurent coefficients of the secondary zeta function at 1.
Requirements: SageMath, numberdb, a C compiler, FLINT headers and library.
Keep flint-secondary_zeta.c, secondary_zeta.h and laurent_bridge.c alongside.
The first two files are unmodified upstream FLINT, with LGPL notices retained.
sage -pip install numberdb
sage -python generate.py # preview, no writes
sage -python generate.py --publish # additive entry submission
Z uses alpha=(rho-1/2)/i, upper-half zeros with multiplicity and principal
powers, followed by meromorphic continuation. No global RH is assumed.
The regular part is F(z)=Z(1+z)-1/(2*pi*z^2)+log(2*pi)/(2*pi*z).
Return [z^n]F for form=coefficient, or n! times that for form=derivative.
Default enumeration: each n=0,...,20, coefficient before derivative.
Certified Cauchy extraction uses r=1/2, a power-of-two trapezoidal node count,
and complex Arb enclosures. A separate interval covering of |z|=7/8 bounds
|F| by M=4096. The first sample check verifies this bound over 64 overlapping
arcs, not just at points. Analyticity follows from the meromorphic pole list:
after removing the double pole, the next pole is z=-2.
If N>n, aliasing is bounded by
M*(8/7)^n*(4/7)^N/(1-(4/7)^N).
This follows from Cauchy's coefficient estimate on |z|=7/8. The bound is
added to the computed ball, including FLINT evaluation and roundoff errors.
Conjugate symmetry permits N/2+1 evaluated nodes. The source evaluator bounds
its uncomputed zero and prime tails unconditionally. This does not rely on
T752 values. The 100-digit build uses N=512 and 480 working bits; finite
balls and relative radii are checked before decimal serialization.
Compilation writes only a temporary local library. Credentials and agent
provenance belong in the caller's environment, never in this source.
"""
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.real_mpfi import RealIntervalField
from sage.rings.complex_arb import ComplexBallField
from sage.env import SAGE_LOCAL
import ctypes
import json
import math
import os
from pathlib import Path
import shlex
import subprocess
import tempfile
ROOT=Path(__file__).resolve().parent
_NATIVE=None
_TEMP=None
_CACHE={}
EVIDENCE={}
POINT_OBSERVER=None
def native():
global _NATIVE,_TEMP
if _NATIVE is not None:return _NATIVE
_TEMP=tempfile.TemporaryDirectory(prefix='numberdb-laurent-')
output=str(Path(_TEMP.name)/'laurent.so')
prefix=Path(os.environ.get('FLINT_ROOT',SAGE_LOCAL))
if (prefix/'include/flint/acb.h').exists():
flags=['-I'+str(prefix/'include/flint'),'-I'+str(prefix/'include'),'-L'+str(prefix/'lib'),'-Wl,-rpath,'+str(prefix/'lib'),'-lflint']
else:
probe=subprocess.run(['pkg-config','--cflags','--libs','flint'],capture_output=True,text=True,check=True)
flags=shlex.split(probe.stdout)
inc=subprocess.run(['pkg-config','--variable=includedir','flint'],capture_output=True,text=True,check=True).stdout.strip()
flags=['-I'+str(Path(inc)/'flint')]+flags
subprocess.run([os.environ.get('CC','cc'),'-shared','-fPIC','-O2','-I'+str(ROOT),str(ROOT/'flint-secondary_zeta.c'),str(ROOT/'laurent_bridge.c'),'-o',output]+flags+['-lm'],check=True,capture_output=True,text=True)
lib=ctypes.CDLL(output)
lib.numberdb_laurent_point.argtypes=[ctypes.c_long]*4
lib.numberdb_laurent_point.restype=ctypes.c_void_p
lib.numberdb_laurent_free.argtypes=[ctypes.c_void_p]
lib.numberdb_flint_version.restype=ctypes.c_char_p
_NATIVE=lib
return lib
def point(k,N,arc,precision):
lib=native();ptr=lib.numberdb_laurent_point(k,N,arc,precision)
try:text=ctypes.string_at(ptr).decode('ascii')
finally:lib.numberdb_laurent_free(ptr)
acc,re,im=text.splitlines()
R=RealBallField(precision);C=ComplexBallField(precision)
ans=C(R(re),R(im))
if not ans.real().is_finite() or not ans.imag().is_finite():raise ArithmeticError('Nonfinite Cauchy point or boundary enclosure')
record={'k':int(k),'N':int(N),'arc':bool(arc),'bits':int(precision),'relative_accuracy_bits':int(acc),'real':re,'imag':im}
if POINT_OBSERVER is not None:POINT_OBSERVER(record)
return ans
def coefficients(max_n=20,digits=100):
max_n=int(max_n);digits=int(digits)
if max_n<0 or digits<1:raise ValueError('Nonnegative order and positive digits required')
cachekey=(max_n,digits)
if cachekey in _CACHE:return _CACHE[cachekey]
# N is rounded upward; increasing the requested extent increases its guard.
need=math.ceil(((digits+20)*math.log(10)+max_n*math.log(8/7))/math.log(7/4))
N=max(512,1<<(need-1).bit_length())
precision=max(480,numberdb.bits(digits,losing=140+max_n))
R=RealBallField(precision);C=ComplexBallField(precision);I=RealIntervalField(precision)
bounds=[point(k,64,1,128) for k in range(33)]
if not all(abs(b.real())+abs(b.imag())<4096 for b in bounds):
raise ArithmeticError('The analytic boundary bound M=4096 was not verified')
vals=[point(k,N,0,precision) for k in range(N//2+1)]
assert vals[0].imag().contains_zero() and vals[-1].imag().contains_zero()
output=[]
q=(QQ(4)/7)**N
for n in range(max_n+1):
total=vals[0].real()+(-1)**n*vals[-1].real()
for k in range(1,N//2):
theta=-2*R.pi()*QQ(k*n)/N
weight=C(theta.cos(),theta.sin())
total+=2*(vals[k]*weight).real()
total=total*2**n/N
error=QQ(4096)*(QQ(8)/7)**n*q/(1-q)
total+=R(I(-error,error))
if not total.is_finite() or not total.rad()>0 or not total.rad()<abs(total).lower()*(QQ(1)/10**(digits+4)):
raise ArithmeticError('Coefficient enclosure fails requested precision')
output.append(total)
EVIDENCE.update({'working_bits':precision,'nodes':N,'radius':'1/2','bound_radius':'7/8','bound_M':4096,'bound_arcs':64,'flint_version':native().numberdb_flint_version().decode(),'relative_radii':[str(b.rad()/abs(b).lower()) for b in output]})
_CACHE[cachekey]=output
return output
class SecondaryLaurent(numberdb.Generator):
table='T753'
parameters=['form','n']
type='R'
digits=100
rigour='proven'
files=('generate.py','flint-secondary_zeta.c','secondary_zeta.h','laurent_bridge.c')
def enumerate(self):
for n in range(21):
for form in ['coefficient','derivative']:yield {'form':form,'n':n}
def value(self,params,digits):
n=int(params['n']);form=str(params['form'])
if n<0 or form not in ('coefficient','derivative'):raise ValueError('Unknown order or normalization')
v=coefficients(max(20,n),digits)[n]
return v if form=='coefficient' else math.factorial(n)*v
if __name__=='__main__':
import sys
if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':numberdb.configure(api_key=sys.stdin.read().strip())
g=SecondaryLaurent()
if '--publish' in sys.argv or os.environ.get('NUMBERDB_PUBLISH')=='1':
g.publish(message=os.environ.get('NUMBERDB_EDIT_MESSAGE','Fill secondary-zeta Laurent coefficients'))
else:g.preview()