check_source_heights.py

back to table · edit · history · where entries came from · files · download

1085 bytes, as of the version from 2026-11-27 09:27 (current). Recorded here, not run.

"""Check the 12 published in-range height controls in the retained geometry results."""
import numberdb.sage as numberdb
import json,pathlib,mpmath as mp
mp.mp.dps=140
w=pathlib.Path(__file__).resolve().parent;results=json.loads((w/'check-offline-results.json').read_text())
source={'tetrahedron':{7:'0.78871',8:'0.56419',9:'0.45320',20:'0.16397'},'cube':{7:'1.03799291',8:'0.76428546',9:'0.62216938',20:'0.23086908'},'octahedron':{5:'0.69128565',6:'0.48121183',7:'0.37938071',20:'0.11318462'}}
comparisons=[]
for cell,entries in source.items():
 for p,reported in entries.items():
  ball=results['geometry'][cell+','+str(p)]['height'];mid,rad=ball.strip('[]').split(' +/- ')
  m=mp.mpf(mid);r=mp.mpf(rad);unit=mp.power(10,-len(reported.split('.')[1]))
  error=abs(m-mp.mpf(reported));assert error+r<mp.mpf('0.51')*unit+mp.mpf('1e-9')
  comparisons.append({'cell':cell,'p':p,'reported':reported,'absolute_difference':mp.nstr(error,15),'enclosure_radius':rad})
print('SOURCE_HEIGHT_JSON='+json.dumps({'checked_source_heights':len(comparisons),'failures':[],'comparisons':comparisons}))