"""Deterministic checks for local joint boundary; Decimal values are not interval certificates.""" from decimal import Decimal as D, localcontext from pathlib import Path import json, random def power(r,a): return (a*r.ln()).exp() def construct(beta,r,sigma,eps): k=2*beta-1;p=1-beta;z=k.sqrt();rp=r+sigma*z;rm=r-sigma/z atoms=[(p,D(0),1,0,rp,D(1)),(k/2,D(0),1,1,rp,rm),(k/2,2*eps,1,1,rm,rp),(p,2*eps,0,1,D(1),rp)] vs=[] for j in range(2): v=[D(0)]*5 for mass,u,a1,a2,r1,r2 in atoms: a=(a1,a2)[j];t=(r1,r2)[j] for i,g in enumerate([D(1),t,t*t,t*t*t,power(t,1+2*u)]):v[i]+=mass*a*g vs.append(v) return atoms,vs def run(): with localcontext() as ctx: ctx.prec=80;checks={};rows=[] beta=D('.75');r=D('.1');eps=D('.1');k=2*beta-1;p=1-beta;L=-r.ln();C=16/r**2 F=lambda e:r*(1-power(r,4*e)) G=lambda e:1-(1+4*e)*power(r,4*e) slope=4*p*L*power(r,1+4*eps);coef=k.sqrt()*G(eps)/slope for sig in [D('1e-3'),D('1e-4'),D('1e-5'),D('1e-6'),D('1e-7')]: atoms,vs=construct(beta,r,sig,eps) expected=[beta,beta*r,beta*(r*r+sig*sig),beta*(r**3+3*r*sig**2+(k-1)*sig**3/k.sqrt())] assert sum(a[0] for a in atoms)==1 assert all(abs(v[i]-expected[i])0 for sig in [D('1e-3'),D('1e-4'),D('1e-5')]: rare=(1-sig**2/a**2)*f(r)+sig**2*(f(r-a)+f(r+a))/(2*a**2) sym=(f(r-sig)+f(r+sig))/2 ratios.append((rare-sym)/sig**2) checks['zero_error_quadratic_order']=abs(ratios[-1]-qcoef)0 result={'identity':'analytic construction diagnostics; not a global optimizer or interval arithmetic','checks':checks,'all_passed':all(checks.values()),'parameters':{'beta':str(beta),'r':str(r),'epsilon0':str(eps)},'radius_first_order_coefficient':str(coef),'zero_error_quadratic_coefficient':str(qcoef),'rows':rows} Path(__file__).with_name('local_boundary_output.json').write_text(json.dumps(result,indent=2)+'\n') print(json.dumps(result,indent=2)) if __name__=='__main__':run()