back to table · edit · history · where entries came from · files · download
957 bytes, as of the version from 2026-12-02 03:42 (current). Recorded here, not run.
"""Execute the displayed Program and compare it with recorded decimal intervals."""
import os,json,sys,hashlib
from pathlib import Path
from decimal import Decimal
from fractions import Fraction
import mpmath as mp
w=Path(__file__).parent
doc=json.loads((w/'document.json').read_text());namespace={}
exec(doc['Programs']['mpmath-example']['code'],namespace)
f=namespace['mean_crossing_clusters'];out=[];failures=[]
for r,text in doc['Numbers'].items():
v=f(r);d=Decimal(text);mid=Fraction(d);u=Fraction(10)**d.as_tuple().exponent
lo=mp.mpf((mid-u).numerator)/(mid-u).denominator;hi=mp.mpf((mid+u).numerator)/(mid+u).denominator
ok=mp.isfinite(v) and lo<v<hi
if not ok:failures.append(r)
out.append({'r':r,'stored_contains_example':bool(ok)})
print(json.dumps({'checked_entries':len(out),'total_entries':len(doc['Numbers']),'failures':failures,'mpmath':mp.__version__,'decimal_digits':mp.mp.dps,'entries':out},indent=2))
if failures:raise SystemExit(1)