back to table · edit · history · where entries came from · files · download
2036 bytes, as of the version from 2026-11-17 16:08 (current). Recorded here, not run.
"""Check the independent source-to-source comparisons and displayed program.
Run under Sage with generate.py, program.py and checks.py beside this script.
"""
import json,math
import mpmath as mp
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.complex_arb import ComplexBallField
from generate import EvenPowerBessel, normalized
from program import even_power_determinant
from checks import recurrence,df
expected=recurrence();mp.mp.dps=190;relations=[]
for n in range(3,17):
r=(n+1)//2;k=r-1
if n%2:
D=mp.fprod(mp.mpf(2*j)**(k-j)*mp.pi**j/mp.sqrt(mp.mpf(2*j+1)**(2*j+1)) for j in range(1,k+1))
coefficient=mp.factorial(r-1)*mp.pi**r/2
# Exact algebraic cancellation of factors and powers of two.
assert QQ(2)**(r*(r-3)//2-sum(r-1-a for a in range(1,r))) == QQ(1)/2
else:
D=2*mp.pi**(mp.mpf(r*r)/2)/mp.gamma(mp.mpf(r)/2)*mp.fprod(mp.mpf(2*j-1)**(r-j)/mp.mpf(2*j)**j for j in range(1,r+1))
coefficient=df(2*r-1)*mp.gamma(mp.mpf(r)/2)*mp.pi**(r+mp.mpf(1)/2)/(mp.mpf(2)**(r+1)*mp.gamma(mp.mpf(r+1)/2))
assert -r*(r+3)//2+r*(r+1)//2-1 == -r-1
error=abs(D*coefficient/expected[n]-1);assert error<mp.mpf('1e-175')
relations.append({'n':n,'relative_error':mp.nstr(error,10)})
assert abs(expected[1]/(mp.pi/2)-1)<mp.mpf('1e-175')
assert abs(2*D*coefficient/expected[n]-1)>mp.mpf('0.1')
for params in EvenPowerBessel().enumerate():
a=even_power_determinant(params['n'],params['normalization']);b=normalized(params['n'],params['normalization'])
assert a.overlaps(b)
for t in ['bessel','period']:
assert even_power_determinant(17,t).overlaps(normalized(17,t))
print('ADDITIONAL_JSON='+json.dumps({'comparison_formulas':relations,'program_checked_entries':32,'extension_checks':[[17,'bessel'],[17,'period']],'known_answer_control':True,'negative_control_rejected':True,'note':'The transformation check uses independently transcribed source products but shares their theorem inputs; direct integral evidence is in checks-results.json.'}))