generate.py

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

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

"""Hardy Z pre-Schwarzian condition for Lehmer pairs -- numberdb.org/T727.

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 quantity is -(Z''/Z')' at each endpoint, combined as
Delta**2/3 times their sum minus 2. 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

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_f(derivatives):
    d1,d2,d3=derivatives
    assert not d1.contains_zero()
    return -d3/d1+(d2/d1)**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_f(da)+endpoint_f(db))/3-2
    assert result.is_finite() and result.accuracy()>=numberdb.bits(digits)+40
    return result

class HardyZPreSchwarzianCondition(numberdb.Generator):
    table='T727'
    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',
           'prefix-checkpoint.json','prefix-provenance.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=HardyZPreSchwarzianCondition()
    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 Hardy Z pre-Schwarzian values')))
    else:
        report=g.verify(sample=None);print(report);sys.exit(0 if report.ok else 1)