exterior_check.py

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

843 bytes, as of the version from 2026-11-02 01:06 (current). Recorded here, not run.

"""Check the displayed exterior moment formula directly for numberdb.org/T664."""
import numberdb.sage as numberdb
import mpmath as m
import json,math
from pathlib import Path
m.mp.dps=155
rows=json.load(Path(__file__).with_name('numerical-values.json').open())
for k in [13,14,15,16,-36]:
 u=m.mpf(k+4);r=16/abs(u);nmax=int(145*m.log(10)/(-m.log(r)))+10
 d0=1;d1=4;power=1/u;total=4*power
 for n in range(2,nmax+1):
  num=2*(2*n-1)*(5*n*n-5*n+2)*d1-64*(n-1)**3*d0
  assert num%n**3==0
  d=num//n**3;d0,d1=d1,d;power/=u;total+=d*power/n
 val=m.log(abs(u))-total
 # D_n=E(R4^(2n)) <= 16^n, hence omitted logarithmic tail bound.
 tail=r**(nmax+1)/((nmax+1)*(1-r))
 err=abs(val-m.mpf(rows[str(k)]['value210']))
 assert err<tail+m.mpf('1e-145')
 print(json.dumps({'k':k,'terms':nmax,'tail_bound':m.nstr(tail,10),'absolute_error':m.nstr(err,10)}))