back to table · edit · history · where entries came from · files · download
1028 bytes, as of the version from 2026-10-31 12:22 (current). Recorded here, not run.
import pathlib,json
import numberdb.sage as numberdb
import mpmath as mp
import generate,dry_run
p=pathlib.Path(__file__).resolve().parent
assert dry_run.main([str(p/'generate.py')])==0
with mp.workdps(100):
worst=mp.mpf(0)
for d in range(2,11):
for text in ['0.001','0.01','0.1','0.25','0.5','0.75','0.9','0.99','0.999']:
t=mp.mpf(text)
lam=mp.hyp2f1(1,1-mp.mpf(d)/2,mp.mpf(1)/2,t*t)
im=mp.sqrt(mp.pi)*mp.gamma(mp.mpf(d)/2)/mp.gamma(mp.mpf(d-1)/2)*t*((1-t)*(1+t))**(mp.mpf(d-3)/2)
worst=max(worst,abs(generate.phase(d,t)-mp.atan2(im,lam)))
assert worst<mp.mpf('1e-95')
print('PHASE_HYPERGEOMETRIC_MAX_ERROR',mp.nstr(worst,12))
# Execute the literal Programs snippet in the proposed document.
doc=json.loads((p/'document.json').read_text()); ns={}
exec(doc['Programs']['mpmath-example']['code'],ns)
expected=json.loads((p/'moments.json').read_text())['3']['moments'][2]
assert abs(ns['alpha']-mp.mpf(expected))<mp.mpf('1e-140')
print('PROGRAM_SNIPPET_OK')