back to table · edit · history · where entries came from · files · download
3850 bytes, as of the version from 2026-10-27 01:11 (current). Recorded here, not run.
"""Verify the parameter descriptions and unchanged values of numberdb.org/T510.
Run with SageMath and numberdb installed:
sage -python repair_checks.py < NUMBERDB_API_KEY_FILE
A key is needed only while T510 is private. This script writes nothing.
The mpmath agreement checks do not establish the table's ball-arithmetic proof.
"""
import hashlib
import json
import sys
from urllib.request import Request, urlopen
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.env import SAGE_VERSION
import mpmath as mp
key = sys.stdin.read().strip()
req = Request('https://numberdb.org/api/table?id=T510',
headers={'Authorization': 'Bearer ' + key} if key else {})
with urlopen(req, timeout=45) as response:
doc = json.load(response)
assert list(doc['Parameters']) == ['ell', 'eta', 'rho']
assert [x['type'] for x in doc['Parameters'].values()] == ['Z', 'Q', 'Q']
def exact_rational(text):
numerator, _, denominator = text.partition('/')
return QQ(ZZ(numerator)) / ZZ(denominator or '1')
rows = []
for ell, couplings in doc['Numbers'].items():
assert ZZ(ell) >= 0
for eta, radii in couplings.items():
exact_rational(eta)
for rho, entry in radii.items():
assert exact_rational(rho) > 0
value = entry['number'] if isinstance(entry, dict) else entry
rows.append((ell, eta, rho, value))
expected = {(str(ell), eta, rho) for ell in range(4)
for eta in ['0','1/2','-1/2','1','-1','2','-2']
for rho in ['1/2','1','2']}
expected.update((str(ell), '2', '5') for ell in range(4))
assert {row[:3] for row in rows} == expected
assert len(rows) == 88
def rational_mp(text):
x = exact_rational(text)
return mp.mpf(str(x.numerator())) / mp.mpf(str(x.denominator()))
def ulp(text):
mantissa, _, exponent = text.lower().partition('e')
places = len(mantissa.partition('.')[2])
return mp.power(10, int(exponent or '0') - places)
with mp.workdps(220):
assert abs(mp.coulombf(0, 0, 1) - mp.sin(1)) < mp.mpf('1e-210')
max_error = mp.mpf(0)
max_drift = mp.mpf(0)
free_count = 0
for ell, eta, rho, written in rows:
with mp.workdps(160):
low = mp.coulombf(int(ell), rational_mp(eta), rational_mp(rho))
with mp.workdps(220):
high = mp.coulombf(int(ell), rational_mp(eta), rational_mp(rho))
assert mp.isfinite(low) and mp.isfinite(high)
error = abs(high - mp.mpf(written)) / ulp(written)
drift = abs(high - low) / ulp(written)
assert error < 1, (ell, eta, rho, mp.nstr(error,10))
assert drift < mp.mpf('1e-50')
max_error = max(max_error, error)
max_drift = max(max_drift, drift)
if eta == '0':
r = rational_mp(rho)
free = mp.sqrt(mp.pi*r/2) * mp.besselj(mp.mpf(ell)+mp.mpf('0.5'), r)
assert abs(high - free) < mp.mpf('1e-210')
free_count += 1
report = {
'tid': 'T510', 'parameters': list(doc['Parameters']),
'parameter_types': [x['type'] for x in doc['Parameters'].values()],
'entries_checked': len(rows), 'all_parameter_constraints_satisfied': True,
'coverage_matches_complete_note': True,
'numerical_method': 'mpmath.coulombf at 160 and 220 decimal digits',
'all_values_inside_stored_decimal_intervals': True,
'max_midpoint_error_ulps': mp.nstr(max_error,20),
'max_precision_drift_ulps': mp.nstr(max_drift,20),
'free_case_bessel_checks': free_count, 'sine_control_passed': True,
'numbers_sha256': hashlib.sha256(json.dumps(doc['Numbers'],ensure_ascii=False,separators=(',',':')).encode()).hexdigest(),
'versions': {'sage': SAGE_VERSION, 'mpmath': mp.__version__},
'scope': 'Agreement check only; does not recertify the generator ball bounds.'
}
print(json.dumps(report, indent=2))