generate.py

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

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

"""Discriminant of the Riemann xi Jensen polynomials -- numberdb.org/T704.

Run with SageMath and the numberdb client:
    sage -pip install numberdb
    sage -python generate.py             # verify every stored entry
    sage -python generate.py --fill      # fill this existing draft

No command offers, reviews or publishes the draft. The completion is
xi(s)=s(s-1) pi^(-s/2) Gamma(s/2) zeta(s)/2, and
J^(d,n)(X)=sum binomial(d,j)*gamma_(n+j)*X^j, with
gamma_m=m! [z^(2m)] xi(1/2+z). The raw discriminant includes the
leading coefficient. Parameters d=2..8 and n=0..20 are discrete indices.

Analytic Arb power series provide certified coefficients. A Sylvester
determinant evaluated by elimination in real ball arithmetic gives the
resultant with the derivative, including its sign and leading factor.
Every pivot must exclude zero. 896 bits are used; numerical-evidence.json
records the measured loss. All returned values have at least 350 accurate
bits. The separate checks.py uses theta integrals and root products.

The analytic-series construction follows the public generator of T659,
read from https://numberdb.org/files/T659/generate.py on 2026-11-10.
See argument-selection.md and certification.md for scope and bounds.
"""
import os
import sys
from functools import lru_cache
from math import comb, factorial
import numberdb.sage as numberdb
from sage.rings.complex_arb import ComplexBallField
from sage.rings.real_arb import RealBallField
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

WORKING_BITS = 896
MAX_DEGREE = 8
MAX_SHIFT = 20


def finite_narrow(x, bits=350):
    assert not x.is_NaN() and not x.is_infinity(), 'nonfinite enclosure'
    assert x.accuracy() >= bits, ('insufficient relative accuracy', x.accuracy(), bits)


@lru_cache(None)
def coefficients(max_index=28, bits=WORKING_BITS):
    C = ComplexBallField(bits)
    P = PolynomialRing(C, 'z')
    s = C(1)/2 + P.gen()
    length = 2*max_index + 1
    f = (s*(s-1)/2 * ((-s/2)*C.pi().log())._exp_series(length)
         * (s/2)._gamma_series(length) * s._zeta_series(length))
    for j in range(1, length, 2):
        assert not f[j].real().is_NaN() and f[j].contains_zero()
    result = []
    for j in range(max_index+1):
        assert f[2*j].imag().contains_zero()
        g = f[2*j].real()*factorial(j)
        finite_narrow(g)
        assert g > 0
        result.append(g)
    return tuple(result)


def polynomial_coefficients(d, n, gamma):
    return [comb(d, j)*gamma[n+j] for j in range(d+1)]


def determinant(rows):
    """Ball Gaussian elimination; a pivot is used only if it excludes zero."""
    a = [list(row) for row in rows]
    size = len(a)
    R = a[0][0].parent()
    result = R(1)
    for k in range(size):
        candidates = [i for i in range(k, size) if not a[i][k].contains_zero()]
        assert candidates, ('no certified pivot', k)
        pivot = max(candidates, key=lambda i: abs(a[i][k].mid()))
        if pivot != k:
            a[k], a[pivot] = a[pivot], a[k]
            result = -result
        value = a[k][k]
        result *= value
        for i in range(k+1, size):
            factor = a[i][k]/value
            for j in range(k+1, size):
                a[i][j] -= factor*a[k][j]
    return result


def discriminant(coeffs):
    d = len(coeffs)-1
    R = coeffs[0].parent()
    f = list(reversed(coeffs))
    df = [j*coeffs[j] for j in range(d, 0, -1)]
    rows = []
    for i in range(d-1):
        rows.append([R(0)]*i + f + [R(0)]*(d-2-i))
    for i in range(d):
        rows.append([R(0)]*i + df + [R(0)]*(d-1-i))
    return (-1)**(d*(d-1)//2)*determinant(rows)/coeffs[-1]


class JensenDiscriminants(numberdb.Generator):
    table = 'T704'
    parameters = ('d', 'n')
    type = 'R'
    digits = 100
    rigour = 'proven'
    files = ('generate.py', 'checks.py', 'argument-selection.md',
             'certification.md', 'numerical-evidence.json', 'skill-evidence.json',
             'T15.json', 'T381.json', 'T659.json', 'sources.json')

    def enumerate(self):
        for d in range(2, MAX_DEGREE+1):
            for n in range(MAX_SHIFT+1):
                yield {'d': d, 'n': n}

    def value(self, params, digits):
        assert digits <= 100, 'Reassess working precision before increasing digits.'
        d, n = int(params['d']), int(params['n'])
        assert 2 <= d <= MAX_DEGREE and 0 <= n <= MAX_SHIFT
        value = discriminant(polynomial_coefficients(d, n, coefficients()))
        finite_narrow(value)
        return value


if __name__ == '__main__':
    if '--stdin-key' in sys.argv or os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
        numberdb.configure(api_key=sys.stdin.read().strip())
    generator = JensenDiscriminants()
    if '--fill' in sys.argv or os.environ.get('NUMBERDB_PUBLISH') == '1':
        print(generator.publish(message='Fill 147 certified xi Jensen discriminants at 100 significant digits'))
    else:
        report = generator.verify(sample=None)
        print(report)
        sys.exit(0 if report.ok else 1)