generate.py

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

4160 bytes, as of the version from 2026-11-16 22:11 (current). Recorded here, not run.

"""Riemann xi pre-Schwarzian condition for strong Lehmer pairs -- numberdb.org/T728.

Install numberdb in SageMath and download hardy_arb.pyx beside this file:
    sage -pip install numberdb
    sage -python generate.py                  # verify all stored entries
    sage -python checks.py                    # offline numerical checks
Set NUMBERDB_API_KEY and NUMBERDB_FILL_DRAFT=1 only to fill an authorized draft.
This never offers a draft, reviews it, or publishes it.

FLINT certifies the numbered zeta-zero enclosure and Hardy Z Taylor jet on
that full enclosure; derivatives are factorial times the Taylor coefficients.
The nonzero first derivatives certify simplicity. All intermediate quantities
are balls. The 200-bit guard leaves more than 100 digits after cancellation
at both ordinary and historical close pairs. See numerical-evidence.json.
"""
import os
import sys
from pathlib import Path
from functools import lru_cache
from math import factorial
import numberdb.sage as numberdb
from sage.misc.cython import cython_import
from sage.rings.rational_field import QQ
from sage.rings.complex_arb import ComplexBallField
from sage.rings.real_arb import RealBallField

WORKING_GUARD = 200
PAIR_INDICES = tuple(range(1,101)) + tuple(range(6707,6712))
ZERO_INDICES = tuple(sorted(set(PAIR_INDICES) | {n+1 for n in PAIR_INDICES}))

@lru_cache(maxsize=1)
def bridge():
    return cython_import(str(Path(__file__).with_name('hardy_arb.pyx')))

@lru_cache(maxsize=None)
def compute_zero(n,digits):
    prec=numberdb.bits(digits,losing=WORKING_GUARD)
    rho=bridge().zero(int(n),prec)
    assert rho.real()==QQ(1)/2
    gamma=rho.imag()
    assert gamma.is_finite() and gamma>0
    coefficients=bridge().jet(gamma,4,prec)
    assert coefficients[0].contains_zero()
    derivatives=[]
    for k in (1,2,3):
        c=coefficients[k]
        assert c.real().is_finite() and c.imag().is_finite() and c.imag().is_zero()
        d=c.real()*factorial(k)
        assert d.accuracy() >= numberdb.bits(digits)+60
        derivatives.append(d)
    assert not derivatives[0].contains_zero()
    return gamma,tuple(derivatives)

def endpoint_q(t,derivatives):
    """Return -Q_Xi at a zero, with the full root enclosure propagated."""
    d1,d2,d3=derivatives
    assert not d1.contains_zero()
    C=ComplexBallField(t.parent().precision())
    z=C(QQ(1)/4,t/2)
    ell=2*t/(t*t+QQ(1)/4)-z.psi().imag()/2
    ellprime=2*(QQ(1)/4-t*t)/(t*t+QQ(1)/4)**2-z.psi(1).real()/4
    # Xi=a Z; a has no zeros on the real line. Check the actual enclosed Xi'.
    a=-(t*t+QQ(1)/4)/2*RealBallField(t.parent().precision()).pi()**(-QQ(1)/4)*abs(z.gamma())
    assert a.is_finite() and not a.contains_zero() and not (a*d1).contains_zero()
    return -d3/d1+(d2/d1)**2+ell*d2/d1-3*ellprime+ell**2

def pair_value(n,digits):
    a,da=compute_zero(n,digits); b,db=compute_zero(n+1,digits)
    assert b>a
    result=(b-a)**2*(endpoint_q(a,da)+endpoint_q(b,db))
    assert result.is_finite() and result.accuracy()>=numberdb.bits(digits)+40
    return result

class XiStrongLehmerCondition(numberdb.Generator):
    table='T728'
    parameters=('n',)
    type='R'
    digits=100
    rigour='proven'
    files=('generate.py','hardy_arb.pyx','checks.py','check.py','dry_run.py',
           'argument-selection.md','numerical-evidence.json','skill-manifest.json',
           'finite-prefix-roots.json')
    def enumerate(self):
        for n in PAIR_INDICES: yield {'n':str(n)}
    def value(self,params,digits):
        n=int(params['n'])
        if n<1: raise ValueError('n must be positive')
        return pair_value(n,digits)

if __name__=='__main__':
    if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':
        key=sys.stdin.read().strip()
        if '=' in key: key=key.split('=',1)[1].strip().strip('\"\'')
        os.environ['NUMBERDB_API_KEY']=key
    g=XiStrongLehmerCondition()
    if os.environ.get('NUMBERDB_FILL_DRAFT')=='1' or os.environ.get('NUMBERDB_PUBLISH')=='1':
        print(g.publish(message=os.environ.get('NUMBERDB_EDIT_MESSAGE','Store certified xi pair diagnostics')))
    else:
        report=g.verify(sample=None);print(report);sys.exit(0 if report.ok else 1)