generate.py

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

5442 bytes, as of the version from 2026-11-28 10:04 (current). Recorded here, not run.

"""T851: Neumann spectral determinants of Euclidean balls.

Install: sage -pip install numberdb
Run: sage -python generate.py (offline values), --verify (all stored entries),
or --publish (add values to an explicitly authorized draft).
Configure credentials and agent provenance externally; the default never writes.

The scalar nonnegative Laplacian on the flat radius-one d-ball has homogeneous
Neumann conditions. Omit its one constant zero mode, count multiplicities,
and set logdet=-Z'(0), det=exp(logdet). The d=1 interval has length two.
Enumerate d=1..6 and det then logdet; six is a practical prefix of d>=1.

BGEK hep-th/9505157v1 (3.17), PDF p18, and section 5 give finite expressions.
The literal preprint is retained in source_derivative(). At d=3..6 add log(2)
to Z'(0): under boundary condition partial_n u+epsilon*u=0 the lowest eigenvalue
is d*epsilon+O(epsilon^2), not (d/2)*epsilon. This follows both by integration
of the PDE and by the l=0 Bessel series. checks.py reconstructs the contour
calculation after replacing that sector by positive J_(d/2) roots, so it does
not use this correction or the finite-expression coefficients as an oracle.
No claim about an uninspected journal erratum is made.

All coefficients are exact. Arb rigorously integrates the smooth polynomial
times log Gamma(1+x); polynomial times log(x) is integrated analytically.
Arb zeta derivatives, logs and exponentials propagate all enclosure errors.
Working precision is bits(digits,losing=192), 525 bits for 100 digits.
The interval determinant is exactly 4, returned as an integer.
"""
import argparse,os,sys
from functools import lru_cache
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.complex_arb import ComplexBallField


def gamma_integral(coefficients,a,C):
    """Certified integral of sum p_k*x^k log Gamma(x) from zero to a>0."""
    a=QQ(a);p=tuple(QQ(c) for c in coefficients)
    def integrand(x,analytic):
        poly=C(0)
        for c in reversed(p):poly=poly*x+c
        return poly*(x+1).log_gamma(analytic=analytic)
    smooth=C.integral(integrand,0,a)
    singular=sum(C(c*a**(k+1))*(C(a).log()/(k+1)-QQ(1)/(k+1)**2)
                 for k,c in enumerate(p))
    result=smooth-singular
    if not result.real().is_finite() or not result.imag().is_finite() or not result.imag().contains_zero():
        raise ArithmeticError('Nonfinite or nonreal integral enclosure')
    return result.real()


@lru_cache(maxsize=None)
def source_derivative(d,digits=100):
    """Literal BGEK preprint Neumann derivatives at radius one, uncorrected."""
    C=ComplexBallField(numberdb.bits(digits,losing=192));R=RealBallField(C.precision())
    z=lambda n:C(n).zetaderiv(1).real()
    log2=R(2).log()
    if d==2:return -QQ(7)/12+2*z(-1)+log2/6-R.pi().log()/2
    if d==3:
        return (-QQ(7)/32-QQ(7)/6*log2+R(3).log()-QQ(3)/4*z(-2)-z(-1)/2
                -2*gamma_integral([1],QQ(1)/2,C))
    if d==4:
        return (-QQ(493)/4320+QQ(61)/90*log2+z(-3)/3+z(-2)/2+z(-1)/6
                +gamma_integral([-2,2],1,C))
    if d==5:
        return (-QQ(19261)/46080-QQ(713)/720*log2+R(5).log()
                -QQ(5)/64*z(-4)-QQ(7)/48*z(-3)-z(-2)/32+z(-1)/48
                +gamma_integral([-QQ(13)/6,3,-1],QQ(3)/2,C))
    if d==6:
        return (-QQ(7087979)/32432400-QQ(1181)/3780*log2+R(3).log()
                +z(-5)/60+z(-4)/24-z(-2)/24-z(-1)/60
                +gamma_integral([-QQ(7)/3,QQ(23)/6,-2,QQ(1)/3],2,C))
    raise ValueError('Finite source expressions support d=2,...,6')


@lru_cache(maxsize=None)
def logdet(d,digits=100):
    R=RealBallField(numberdb.bits(digits,losing=192))
    if d==1:return R(4).log()
    derivative=source_derivative(d,digits)
    if d>=3:derivative+=R(2).log()
    result=-derivative
    if not result.is_finite():raise ArithmeticError('Nonfinite log determinant')
    return result


class BallNeumann(numberdb.Generator):
    table='T851'
    parameters=('d','convention')
    type='R'
    digits=100
    rigour='proven'
    files=('generate.py','checks.py','argument-selection.md','research.md',
           'validation-method.md','skill-manifest.json','versions.json',
           'check-results.json','numerical-evidence.json')
    def enumerate(self,limit=6):
        if not isinstance(limit,int) or not 1<=limit<=6:raise ValueError('1<=limit<=6')
        for d in range(1,limit+1):
            for c in ('det','logdet'):yield {'d':d,'convention':c}
    def value(self,params,digits):
        d=ZZ(params['d']);c=params['convention']
        if not 1<=d<=6 or c not in ('det','logdet'):raise ValueError('d=1..6; det or logdet')
        if d==1 and c=='det':return ZZ(4)
        result=logdet(int(d),digits)
        return result.exp() if c=='det' else result


if __name__=='__main__':
    p=argparse.ArgumentParser(description=__doc__);p.add_argument('--publish',action='store_true');p.add_argument('--verify',action='store_true');a=p.parse_args()
    if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':numberdb.configure(api_key=sys.stdin.read().strip())
    g=BallNeumann()
    if a.publish or os.environ.get('NUMBERDB_PUBLISH')=='1':print(g.publish(message=os.environ.get('NUMBERDB_EDIT_MESSAGE','Fill checked Neumann determinants')))
    elif a.verify:print(g.verify(sample=None))
    else:
        for par in g.enumerate():print(par,g.value(par,g.digits))