back to table · edit · history · where entries came from · files · download
3771 bytes, as of the version from 2026-10-25 19:59 (current). Recorded here, not run.
"""Favard constants K_r -- numberdb.org/T501.
Run with SageMath or passagemath:
sage -pip install numberdb
sage -python generate.py # verify every stored entry
sage -python checks.py # independent checks, no writes
sage -python generate.py --fill # fill the existing draft, key required
The table stores orders 0 through 20, with 100 significant digits and exact
K_0=1. For odd r the defining sum is lambda(r+1); for even r it is beta(r+1).
Arb evaluates these using Riemann and Hurwitz zeta functions. A 64-bit guard
means 397 working bits at 100 digits; checks.py measures every radius and
requires it to be less than 10^-110. Increasing the range requires rerunning
that measurement. The independent check counts alternating permutations and
uses their exact rational coefficients times pi^r at higher precision.
--fill writes entries and attached sources; it does not publish the table or
offer it for review. NUMBERDB_API_KEY is the usual client credential variable.
For the campaign runner, NUMBERDB_KEY_FROM_STDIN=1 reads the key from stdin,
and NUMBERDB_PUBLISH=1 selects the same entry-filling operation as --fill.
"""
import os
import sys
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
MAX_ORDER = 20
WORKING_GUARD = 64
SMALL_COMMENTS = {
0: r'$K_0=1$ exactly, by the alternating arctangent series.',
1: r'$K_1=\pi/2$.',
2: r'$K_2=\pi^2/8$.',
3: r'$K_3=\pi^3/24$.',
4: r'$K_4=5\pi^4/384$.',
5: r'$K_5=\pi^5/240$.',
}
def favard(r, digits=100):
"""Rigorous ball for K_r, or the exact integer at r=0."""
r = ZZ(r)
if r < 0:
raise ValueError('r must be a nonnegative integer')
if r == 0:
return ZZ(1)
field = RealBallField(numberdb.bits(digits, losing=WORKING_GUARD))
s = r + 1
if r % 2:
total = (1 - field(2)**(-s)) * field(s).zeta()
else:
complex_field = ComplexBallField(field.prec())
total_complex = (
complex_field(s).zeta(complex_field(QQ(1) / 4))
- complex_field(s).zeta(complex_field(QQ(3) / 4))
) / complex_field(4)**s
if (not total_complex.real().is_finite()
or not total_complex.imag().is_finite()
or not total_complex.imag().contains_zero()):
raise ArithmeticError('Hurwitz-zeta difference is not a finite real ball')
total = total_complex.real()
result = 4 * total / field.pi()
if not result.is_finite():
raise ArithmeticError('nonfinite Favard enclosure')
return result
class FavardConstants(numberdb.Generator):
table = 'T501'
parameters = ('r',)
type = 'R'
digits = 100
rigour = 'proven'
files = ('generate.py', 'checks.py', 'check.py', 'oeis-a000111-0-20.txt', 'README.md')
def enumerate(self, max_order=MAX_ORDER):
for r in range(max_order + 1):
yield {'r': str(r)}
def value(self, params, digits):
r = ZZ(params['r'])
value = favard(r, digits)
if r in SMALL_COMMENTS:
return {'number': value, 'comment': SMALL_COMMENTS[r]}
return value
if __name__ == '__main__':
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
os.environ['NUMBERDB_API_KEY'] = sys.stdin.read().strip()
generator = FavardConstants()
if '--fill' in sys.argv or os.environ.get('NUMBERDB_PUBLISH') == '1':
print(generator.publish(message='Fill checked Favard constants for orders zero through twenty'))
else:
report = generator.verify(sample=None)
print(report)
sys.exit(0 if report.ok else 1)