"""Interval certificate for the degree-nine fixed-fan Neumann trials.""" from fractions import Fraction as F from functools import cache from math import comb, factorial from certify_vertex_kernel import I, mat, vertices from kernel_poly import avg, derivative, mul, sqrt_bounds P = {ij:F(c,333) for ij,c in { (1,0):1000,(2,1):-537,(3,2):83,(0,4):89,(1,5):-10,(6,0):-17}.items()} W2 = {ij:F(c,10000) for ij,c in { (1,1):14354,(2,0):74843,(0,3):65622,(2,2):-7531,(3,1):-181800, (0,5):6668,(1,4):-163133,(5,0):-16820,(3,3):-1566,(4,2):206183, (1,6):-12458,(2,5):177226,(6,1):29357,(7,0):2416,(0,8):416, (4,4):4096,(5,3):-90246,(2,7):5006,(3,6):-67660,(7,2):-15379, (8,1):-1413}.items()} W3 = {ij:F(c,10000) for ij,c in { (0,1):-1580,(0,2):101627,(1,2):-546,(3,0):58102,(1,3):-193837, (4,0):-22619,(2,3):23956,(4,1):-154971,(0,6):2657,(2,4):213330, (5,1):27945,(0,7):2768,(3,4):-33552,(5,2):161428,(1,7):-5112, (3,5):-94028,(6,2):-11530,(8,0):1603,(1,8):-3896,(4,5):17645, (6,3):-57858,(9,0):-435}.items()} ONE = {(0,0):F(1)} LAMBDA = I('4.352639','4.354790') D0, D1 = F('.025308'), F('.084159') @cache def moment(j,a,b): """Complex sector average of z**a*zbar**b on triangle (0,w**j,w**(j+1)).""" numer = [0]*5 for k in range(a+1): for l in range(b+1): idx=(j*(a-b)+k-l)%5 numer[idx] += comb(a,k)*comb(b,l)*factorial(k+l)*factorial(a+b-k-l) den=factorial(a+b+2) av=vertices() return tuple(sum((I(F(2*n,den))*av[i][d] for i,n in enumerate(numer)),I()) for d in range(2)) def sector_inner(j,p,s,q,t): """Real part of the averaged Hermitian product of i^s p and i^t q.""" product=mul(p,{(b,a):c for (a,b),c in q.items()}) phase=(s-t)%4 component=phase%2 sign=(1,-1,-1,1)[phase] return sum((I(c)*moment(j,a,b)[component]*sign for (a,b),c in product.items()),I()) @cache def grams(): polys=[ONE,P,W2,W3] means=[I(),I(),I(*avg(W2)),I()] assert avg(P)==avg(W3)==(0,0) assert all((a-b)%5 in (0,2) for a,b in W2) assert all((a-b)%5 in (3,4) for a,b in W3) grad=[(derivative(p,sign),i) for p in polys[1:] for i,sign in enumerate((1,-1))] result=[] for j in range(5): raw=[[sector_inner(j,p,0,q,0) for q in polys] for p in polys] mass=[[raw[i][k]-means[i]*raw[0][k]-means[k]*raw[i][0]+means[i]*means[k] for k in range(4)] for i in range(4)] energy=[[sector_inner(j,p,s,q,t) for q,t in grad] for p,s in grad] result.append((mass,energy)) return result def bil(form,x,y): return sum((x[i]*form[i][j]*y[j] for i in range(len(x)) for j in range(len(y)) if x[i] and y[j]),I()) def contraction(form, tensor, left, right): return sum((tensor[a][b]*bil(form,left[a],right[b]) for a in range(2) for b in range(2)),I()) def rowcomb(t,x): return [[sum((t[i][j]*x[j][k] for j in range(len(x))),I()) for k in range(len(x[0]))] for i in range(len(t))] def matrices(h): out=[] for j in range(5): fields=[mat(j,k) for k in range(2,5)] g=[[sum((h[i]*fields[i][a][b] for i in range(3)),I()) for b in range(2)] for a in range(2)] (a,b),(c,d)=g div,det=a+d,a*d-b*c k1=[[d-a,-b-c],[-b-c,a-d]] k2=[[a*a+b*b-det,a*c+b*d],[a*c+b*d,c*c+d*d-det]] out.append((div,det,k1,k2)) return out def rational_mid(x): return F(round((x.lo()+x.hi())*500),1000) @cache def evaluate(h): """Evaluate the real-direction quadratic comparison and polynomial cubic.""" geo=matrices(h) h2,h3,_=h mp=[0,1,0,0] mw=[0,0,h2,h3] gp=[[1,0,0,0,0,0],[0,1,0,0,0,0]] gw=[[0,0,h2,0,h3,0],[0,0,0,h2,0,h3]] unit=[[1,0],[0,1]] bar=sum((a[1] for a in geo),I())/5 dp=sum((d*m[0][1] for (m,_),(d,*_) in zip(grams(),geo)),I())/5 ep=sum((ep*m[0][1] for (m,_),(_,ep,_,_) in zip(grams(),geo)),I())/5 dw=sum((d*bil(m,[1,0,0,0],mw) for (m,_),(d,*_) in zip(grams(),geo)),I())/5 stiff2=mass2=stiff3=mass3=wn=gn=pm=pg=cmnum=cgnum=I() res=[] hnorm=dms=epsmax=F(0) for (m,g),(d,eps,k1,k2) in zip(grams(),geo): hk2=[[k2[i][j]+(bar if i==j else 0) for j in range(2)] for i in range(2)] hk3=[[-d*k2[i][j]+(bar-eps)*k1[i][j] for j in range(2)] for i in range(2)] p2=bil(m,mp,mp) pw=bil(m,mp,mw) w2=bil(m,mw,mw) ww=contraction(g,unit,gw,gw) pp=contraction(g,unit,gp,gp) stiff2+=contraction(g,hk2,gp,gp)+2*contraction(g,k1,gp,gw)+ww mass2+=eps*p2+2*d*pw+w2 stiff3+=contraction(g,hk3,gp,gp)+2*contraction(g,hk2,gp,gw)+contraction(g,k1,gw,gw) mass3+=2*eps*pw+d*w2 wn+=w2 gn+=ww pm+=p2 pg+=pp a,b=rowcomb(hk2,gp),rowcomb(k1,gw) rg=[[u+v for u,v in zip(l,r)] for l,r in zip(a,b)] rm=[-d*dp,eps,d*h2,d*h3] cgnum+=contraction(g,unit,rg,gp) cmnum+=bil(m,rm,mp) res.append((rg,rm)) hnorm=max(hnorm,max(sum(x.mag() for x in l) for l in hk2)) dms+=d.mag()**2/5 epsmax=max(epsmax,eps.mag()) q=stiff2/5-LAMBDA*(mass2/5-dp*dp) cubic=stiff3/5-LAMBDA*(mass3/5-2*dp*(ep+dw)) cg=rational_mid(cgnum/pg) cm=rational_mid(cmnum/pm) resid_g=resid_m=I() for (m,g),(rg,rm) in zip(grams(),res): ug=[[v-cg*p for v,p in zip(l,k)] for l,k in zip(rg,gp)] um=[v-cm*p for v,p in zip(rm,mp)] resid_g+=contraction(g,unit,ug,ug) resid_m+=bil(m,um,um) ng=sqrt_bounds((resid_g/5).hi())[1] nm=sqrt_bounds((resid_m/5).hi())[1] error=(2*ng*D1+(hnorm+2*abs(cg))*D1**2 +LAMBDA.hi()*(2*nm*D0+(epsmax+dms+2*abs(cm))*D0**2)) return I(q.lo()-error,q.hi()+error), cubic, gn/5, wn/5 def main(): axes=[(1,0,0),(0,1,0),(0,0,1)] e=[evaluate(h) for h in axes] qdiag=[a[0] for a in e] cross=(evaluate((0,1,1))[0]-evaluate((0,1,-1))[0])/4 print('projected quadratic diagonal upper',*(float(x.hi()) for x in qdiag)) print('projected mixed coefficient magnitude',float(cross.mag())) for a in e[:2]: print('corrector squared gradient, mass upper',float(a[2].hi()),float(a[3].hi())) cp=evaluate((1,1,0))[1] cm=evaluate((1,-1,0))[1] t1,t3=(cp-cm)/2,(cp+cm)/2 cp=evaluate((1,0,1))[1] cm=evaluate((1,0,-1))[1] t2,t5=(cp-cm)/2,(cp+cm)/2 t4=evaluate((1,1,1))[1]-t1-t2-t3-t5 print('polynomial cubic coefficient magnitudes', *(float(c.mag()) for c in (t1,t2,t3,t4,t5))) assert qdiag[0].hi() < -F('1.19') and qdiag[1].hi() < -F('15.45') assert qdiag[2].hi() < F('17.45') and cross.mag() < F('1.86') assert max(a[2].hi() for a in e[:2]) < 55 assert max(a[3].hi() for a in e[:2]) < F('4.5') assert all(c.mag()2 and gnorm**2>2*reg assert wnorm**2>F('4.5') and wgrad**2>55 root2=F('1.415') g,d,eps,k1,k2=map(F,('2.5','2.36','2.403','3.10','7.75')) # Near the kernel, |xi4|/r <= .3 |xi3|/r + offset. offset=F('.084') assert offset**2>(8*radius)**2*(1+F('.3')**2) v=F('.3') a,b,c,mix=map(F,('1.19','15.45','17.45','3.72')) constant=-a+(c+a)*offset**2 linear=2*(c+a)*v*offset+mix*offset square=b-a-(c+a)*v**2-mix*v assert square>0 and constant+linear**2/(4*square) < -F('1.02') # Fourth-order geometry and mass coefficient remainders on the radius. denom=(1-g*radius)**2 c3=d*k2+eps*k1 n3=(c3+eps*k2*radius)/denom a3=(c3+k1+(eps+1)*k2*radius)/denom m3=(2*root2*eps+(2+eps**2)*radius)/(1-radius**2) a4=(d*c3+eps*k2+eps*c3*radius)/denom + k2+n3*radius m4=(2+eps**2+2*root2*eps*radius)/(1-radius**2) # The maximum of x^2 y on the Euclidean unit sphere is 2/(3 sqrt(3)). # The maximum of xyz is 1/(3 sqrt(3)). assert F('.385')**2*27>4 and F('.193')**2*27>1 poly_cubic=F('.385')*sum(map(F,('14','4.4','.4','3.9')))+F('.193')*F('10.5') assert poly_cubic<11 projection_cubic=((c3+k1)*(2*gnorm*D1+D1**2)+2*(k2+1)*wgrad*D1 +reg*(2*root2*eps*(2*pnorm*D0+D0**2) +2*(eps+2)*wnorm*D0)) assert projection_cubic<31 fourth=(2*reg*(a4+m4)+2*(a3*gnorm*wgrad+reg*m3*pnorm*wnorm) +(k2+1+a3*radius)*55+reg*(eps+2+m3*radius)*F('4.5')) assert fourth<3100 trace_deficit=F('1.02')-42*radius-3100*radius**2 assert trace_deficit>=F('.29') complex_mass=(1+g*radius)**2*(pnorm+wnorm*radius)**2 assert trace_deficit/(complex_mass*reg)>F(1,50) transverse_deficit=F('1.7')*8-(k2+1+eps+2+(a3+m3)*radius) assert transverse_deficit/(1+g*radius)**2>F(1,50) print('certified full Fourier chart radius 1/100 and relative deficit r^2/50') if __name__=='__main__': main()