"""Independent second-order audit using closed-form boundary integrals. Requires python-flint. No coefficients or routines are imported from local_certificate.py. The only spectral input is the square's root. """ from flint import acb, arb, ctx from itertools import combinations if not __debug__: raise RuntimeError('Run this verifier without Python optimization.') ctx.prec = 220 one = arb(1) def square_root(): # Interval safeguarded Newton by sign bisection. lo, hi, den = 9*(1<<155),10*(1<<155),10*(1<<155) for _ in range(154): middle = (lo+hi)//2 x = arb(middle)/den val = x.cos()*x.cosh()-x.sin()*x.sinh() if val>0: lo=middle else: assert val<0 hi=middle return arb(lo).union(arb(hi))/den k = square_root() s = k*k.tanh() def one_field(a,c,p,q): vertices=[((1+a)*x+c*y+p*x*y,c*x+(1-a)*y+q*x*y) for x,y in [(-1,-1),(1,-1),(1,1),(-1,1)]] L,E,B,m=0,0,0,0 for i in range(4): xs,ys=vertices[i]; xe,ye=vertices[(i+1)%4] x,y=(xe+xs)/2,(ye+ys)/2 dx,dy=(xe-xs)/2,(ye-ys)/2 h=(dx**2+dy**2).sqrt() def moment(f,g): v=k*acb(g*dy,f*dx) z=k*acb(g*y,f*x) m=2*v.sinh()/v if v!=0 else arb(2) return z.exp()*m fx=moment(2,0) gy=(moment(0,2)+moment(0,-2))/2 mixed=(moment(2,2)+moment(2,-2))/2 L+=2*h B+=h*(2-fx.real+gy.real-mixed.real)/4 m+=h*((moment(1,1)+moment(1,-1))/2).imag E+=k*(dy*fx.imag-dx*((moment(0,2)-moment(0,-2))/2).real)/4 l=L/8 return l*l*E-s*l*B+s*m*m/8 def score(x): a,c,p,q=x return (1+a)*one_field(a,c,p,q)+(1-a)*one_field(-a,c,q,p) origin=score([arb(0)]*4) assert origin.contains(0) step=one/(2**36) # For every v tested we have max |v_i|<=1. On the directional complex # circle R=1/10, the Cauchy height bound in local-proof.tex gives M<10^4. R=one/10 d=R*3 U=d.cosh()*(1+d).cosh() G=((2*d).cosh()+(2*(1+d)).cosh())/2 J=1+2*R+6*R**2 W2=(1+2*R)**2+(2*R)**2 M=2*(1+R)*W2*(4*J*G+16*s*U**2) assert M<10**4 and 8*R**2<1 err=M*step**2/R**4/(1-(step/R)**2) def second(v): v=[step*x for x in v] val=(score(v)+score([-z for z in v])-2*origin)/(2*step**2) return val+arb(0,err.upper()) bases=[[int(i==j) for j in range(4)] for i in range(4)] diag=[second(u) for u in bases] print('second coefficients',*[x.str(14) for x in diag]) for (i,a),(j,b) in combinations(enumerate(bases),2): cross=second([x+y for x,y in zip(a,b)])-diag[i]-diag[j] print('mixed',i,j,cross.str(3)) assert cross.contains(0) and abs(cross)