generate.py

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

3407 bytes, as of the version from 2026-11-18 20:02 (current). Recorded here, not run.

"""T757: Moments of the Riemann zeta screw function.

Requires SageMath with Arb/FLINT and the numberdb Python package.
  sage -pip install numberdb
  sage -python generate.py             # verify all stored entries, no writes
  sage -python generate.py --publish   # fill the assigned draft, no offering

Suzuki arXiv:2206.03682v4 (1.13),(1.15) defines mu_n without n!
normalization. Remove the zeta pole before multiplying the completed product
at s=1+u. Native ball polynomial zeta/gamma/log routines enclose every
coefficient. The finite coefficient transform is exact integer arithmetic.
No zero truncation or RH assumption is used. The log series is the analytic
branch near xi(1)=1/2; its derivative is branch independent.

The default selection is every integer 0<=n<=50. The bound is practical,
not part of the infinite moment family's domain. Real balls are returned
without discarding their error; only serialization rounds to 100 digits.
Working precision starts at 768 bits and is increased if the retained
relative accuracy is below digits*log2(10)+64 bits. The builder records the
measured precision and compares all moments with a separate theta/Li route.
"""
import os
import sys
from functools import lru_cache
from math import factorial
import numberdb.sage as numberdb
from sage.rings.complex_arb import ComplexBallField
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.rational_field import QQ

@lru_cache(maxsize=8)
def moment_balls(digits=100, nmax=50):
    work = max(768, numberdb.bits(digits, losing=384))
    target = numberdb.bits(digits, losing=64)
    while True:
        C = ComplexBallField(work)
        P = PolynomialRing(C, 'u'); u = P.gen()
        length = nmax + 2
        s = 1 + u
        pole_removed = 1 + u * s._zeta_series(length, deflate=True)
        gamma = (s * QQ(1)/2)._gamma_series(length)
        pi_factor = (-s * C.pi().log()/2)._exp_series(length)
        xi = (s * pole_removed * gamma * pi_factor / 2).truncate(length)
        logxi = xi._log_series(length)
        sigmas = [(-1)**k * (k+1) * logxi[k+1] for k in range(nmax+1)]
        values = []
        for n in range(nmax+1):
            z = factorial(n)*sum(((n-k+1)*2**(n-k)*sigmas[k]
                                 for k in range(n+1)), C(0))
            # The entire completed function is real on the real axis.
            if not (z.real().is_finite() and z.imag().is_finite()) or not z.imag().contains_zero():
                raise ArithmeticError('Nonfinite/nonreal moment enclosure')
            values.append(z.real())
        if min(v.accuracy() for v in values) >= target:
            return tuple(values), work
        work *= 2
        if work > 8192:
            raise ArithmeticError('Moment precision failed to converge')

class ScrewMoments(numberdb.Generator):
    table = os.environ.get('NUMBERDB_TABLE', 'T757')
    parameters = ('n',)
    type = 'R'
    digits = 100
    rigour = 'proven'
    def enumerate(self, nmax=50):
        for n in range(nmax+1):
            yield {'n': n}
    def value(self, params, digits):
        n = int(params['n'])
        if n < 0: raise ValueError('Moment order must be nonnegative')
        return moment_balls(digits,max(50,n))[0][n]

if __name__ == '__main__':
    g = ScrewMoments()
    if '--publish' in sys.argv:
        print(g.publish())
    else:
        print(g.verify(sample=None))