back to table · edit · history · where entries came from · files · download
5471 bytes, as of the version from 2026-10-25 19:59 (current). Recorded here, not run.
"""Reproduce and independently check Favard constants -- numberdb.org/T501.
Run with SageMath and the numberdb client installed:
sage -pip install numberdb
sage -python repair_verify_T501.py
For private drafts, set NUMBERDB_API_KEY, or pipe the key on stdin with
NUMBERDB_KEY_FROM_STDIN=1. This script reads T501 and T500 through the API,
prints JSON evidence, and makes no website writes.
The generator is the zeta/Hurwitz-zeta program in T501 at 397 bits.
The independent coefficients count alternating permutations by the rank of
the last entry: appending rank j sums earlier ranks less than j on an ascent,
and earlier ranks at least j on a descent. Exhaustive permutations through
order eight control the recurrence. The differential equation of sec+tan
provides another exact coefficient check. Arb evaluates the independent
pi-power formula at 600 bits and checks complete decimal enclosures.
"""
import json
import os
import sys
from decimal import Decimal
from itertools import permutations
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.env import SAGE_VERSION
def generate(r):
R = RealBallField(numberdb.bits(100, losing=64))
r = ZZ(r)
if r < 0:
raise ValueError('Require r >= 0')
if r == 0:
return ZZ(1)
s = r + 1
if r % 2:
return 4/R.pi() * (1-R(2)**(-s)) * R(s).zeta()
return (4/R.pi() * R(4)**(-s)
* (R(s).zeta(R(QQ(1)/4))-R(s).zeta(R(QQ(3)/4))))
def alternating_counts(last):
totals = [ZZ(1), ZZ(1)]
ranks = [ZZ(1)]
for n in range(2, last + 1):
ranks = [sum(ranks[:j]) if n % 2 == 0 else sum(ranks[j:])
for j in range(n)]
totals.append(ZZ(sum(ranks)))
return totals[:last + 1]
def value_text(row):
return row['number'] if isinstance(row, dict) else row
def check_decimal(text, value):
assert value.is_finite()
numerator, denominator = Decimal(text).as_integer_ratio()
center = QQ(numerator) / QQ(denominator)
if '.' not in text and 'e' not in text.lower():
assert value.is_exact() and value == center
return 0
decimal = Decimal(text)
digits = len(decimal.as_tuple().digits)
assert digits == 100, (text, digits)
unit = QQ(10) ** int(decimal.as_tuple().exponent)
assert RealBallField(600)(value.rad()) < RealBallField(600)(unit) / 1000
# Strict ball comparisons certify the entire ball lies in the interval.
assert value > center - unit and value < center + unit, text
return digits
def main():
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
numberdb.configure(api_key=sys.stdin.read().strip())
table = numberdb.table('T501')
companion = numberdb.table('T500')
assert set(table['Numbers']) == {str(n) for n in range(21)}
assert set(companion['Numbers']) == {str(n) for n in range(2, 21)}
assert table['Data properties']['digits'] == '100'
counts = alternating_counts(20)
for n in range(9):
brute = sum(all((p[i] < p[i+1]) if i % 2 == 0
else (p[i] > p[i+1]) for i in range(n-1))
for p in permutations(range(n)))
assert brute == counts[n], n
# F'= (1+F^2)/2, F(0)=1 for F=sec(x)+tan(x).
coefficients = [QQ(1)]
for n in range(20):
square = sum(coefficients[k]*coefficients[n-k] for k in range(n+1))
coefficients.append((square + int(n == 0)) / (2*ZZ(n+1)))
assert all(coefficients[n] * ZZ(n).factorial() == counts[n]
for n in range(21))
B = RealBallField(600)
independent = [B(counts[r]) * B.pi()**r / (ZZ(2)**r * ZZ(r).factorial())
for r in range(21)]
rows = []
for r in range(21):
text = value_text(table['Numbers'][str(r)])
ball = B(generate(r))
check_decimal(text, ball)
digits = check_decimal(text, independent[r])
assert ball.overlaps(independent[r])
rows.append({'r': r, 'A_r': str(counts[r]), 'digits': digits,
'number': text, 'generated_ball': str(ball),
'radius': str(ball.rad()),
'under_recorded_build_radius': bool(B(ball.rad()) < B('1.9e-119'))})
assert all(independent[r] < 4/B.pi() for r in range(0,21,2))
assert all(independent[r] > 4/B.pi() for r in range(1,21,2))
assert all(independent[r] < independent[r+2] for r in range(0,19,2))
assert all(independent[r] > independent[r+2] for r in range(1,18,2))
relations = 0
for n in range(2,21):
assert set(companion['Numbers'][str(n)]) == {str(k) for k in range(1,n)}
for k in range(1,n):
result = independent[n-k] / independent[n]**(QQ(n-k)/n)
check_decimal(value_text(companion['Numbers'][str(n)][str(k)]), result)
relations += 1
print(json.dumps({'sage_version': SAGE_VERSION,
'numberdb_version': numberdb.__version__,
'checks_passed': True, 'T501_rows': 21,
'approximate_rows_at_100_digits': 20,
'permutations_checked_through': 8,
'independent_exact_coefficients': 21,
'T500_relations': relations,
'working_bits': 397, 'independent_bits': 600,
'rows': rows}, indent=2))
if __name__ == '__main__':
main()