# certify16.py -- exact certificates for the 10 representative bistochastic forms of had16.3 (had163reps.txt, from the # folder symmetry). Unknowns v = (x_2..x_16, y_2..y_16), with b_1 = 1 and b_j = x_j + i y_j; equations F(v) = 0 given by # x_j^2 + y_j^2 = 1 and |(Hb)_i|^2 = 16 for the rows i = 1..15, the last row following by orthogonality: 30 quadrics # with integer coefficients in 30 variables. # 1. Krawczyk test, in exact rational arithmetic: with z the rational center (Newton refined, by hpform.py) and R a # rational approximate inverse of J(z), on the box |v-z| <= r (infinity norm), J varies by at most 900r in the induced # infinity norm, so with q = |I-RJ(z)| + 900 r |R| the condition |RF(z)| + q r < r gives a unique zero in the box, # at which the Jacobian is invertible, so the zero is isolated in C^30. The test is done for r = 10^-60, which locates # the zero, and for r = 10^-6, which shows that it is the only zero in the larger box, as used by certorbits.py in # the folder symmetry, which reads the centers from certified16.txt, written here. # 2. Root of unity test: by the Bezout bound the isolated zeros are at most 2^30, so b_j has degree <= 2^31, and if # b_j is a root of unity of order n then n <= 2 phi(n)^2 <= 2^63. With theta the angle of b_j in turns, known up to # eps, a fraction k/n with n <= 2^63 and |theta - k/n| <= eps < 1/(2n^2) is a convergent of theta (Legendre), so it is # enough to check that all these convergents are at distance > eps. The angle is computed in rational interval # arithmetic, by the series atan(x) = sum_n 2^(2n) (n!)^2/(2n+1)! x^(2n+1)/(1+x^2)^(n+1), whose terms decrease by a # factor <= 1/2, truncated with a geometric bound on the tail, and with pi = 4 atan(1) computed the same way. Since H is real, the entries of the form in row 1 # are, up to the global phase, +-b_j, so a column j passing the test shows that the form is not Butson. import numpy as np, sys from fractions import Fraction as Fr from decimal import Decimal as D, getcontext from hpform import refine H=np.loadtxt('had163.txt').astype(int); N=16 reps=np.exp(2j*np.pi*np.loadtxt('../symmetry/had163reps.txt')) PREC=130; r=Fr(1,10**60); eps=Fr(1,10**59); Q0=2**63 def F(v): x=[Fr(1)]+v[:15]; y=[Fr(0)]+v[15:] out=[x[j]*x[j]+y[j]*y[j]-1 for j in range(1,N)] for i in range(N-1): R=sum(H[i,j]*x[j] for j in range(N)); I=sum(H[i,j]*y[j] for j in range(N)) out.append(R*R+I*I-16) return out def J(v): x=[Fr(1)]+v[:15]; y=[Fr(0)]+v[15:]; M=[] for j in range(1,N): row=[Fr(0)]*30; row[j-1]=2*x[j]; row[14+j]=2*y[j]; M.append(row) for i in range(N-1): R=sum(H[i,j]*x[j] for j in range(N)); I=sum(H[i,j]*y[j] for j in range(N)) M.append([2*R*H[i,j] for j in range(1,N)]+[2*I*H[i,j] for j in range(1,N)]) return M norm=lambda M: max(sum(abs(a) for a in row) for row in M) S_=10**150 def atan_iv(x): # rational lower and upper bounds for atan(x), 0 <= x <= 1 rational, in fixed point with unit 1/S_, rounding the # lower bounds down and the upper bounds up; the remaining terms decrease by a factor <= 1/2 a,b=x.numerator,x.denominator; d=a*a+b*b q0,q1=S_*a*a//d,-(-S_*a*a//d); t0,t1=S_*a*b//d,-(-S_*a*b//d); lo=hi=0; n=0 while t1>1: lo+=t0; hi+=t1 t0=t0*q0*(2*n+2)//(S_*(2*n+3)); t1=-(-t1*q1*(2*n+2)//(S_*(2*n+3))); n+=1 return Fr(lo,S_),Fr(hi+2*t1+n,S_) PI=atan_iv(Fr(1)); PI=(4*PI[0],4*PI[1]) def turns(x,y): # rational interval for the angle of x+iy in turns, x,y rational, not both 0 ax,ay=abs(x),abs(y); lo,hi=atan_iv(min(ax,ay)/max(ax,ay)) if ay>ax: lo,hi=PI[0]/2-hi,PI[1]/2-lo if x<0: lo,hi=PI[0]-hi,PI[1]-lo if y<0: lo,hi=2*PI[0]-hi,2*PI[1]-lo return min(lo/(2*PI[1]),lo/(2*PI[0])),max(hi/(2*PI[0]),hi/(2*PI[1])) def convergents(f): p0,q0,p1,q1=0,1,1,0 while True: a=f.numerator//f.denominator; p0,q0,p1,q1=p1,q1,a*p1+p0,a*q1+q0 yield Fr(p1,q1) if f==a: return f=1/(f-a) out=[] for c,b in enumerate(reps): for it in range(3000): u=H@b; u=u/abs(u); b=H.T@u; b=b/abs(b) b=b/b[0] Hd=[[D(int(h)) for h in row] for row in H]; Z=[[D(0)]*N for _ in range(N)] X,Y,err=refine(Hd,Z,list(b),prec=PREC) getcontext().prec=PREC+20 z=[Fr(X[j]) for j in range(1,N)]+[Fr(Y[j]) for j in range(1,N)] Jz=J(z); Rf=np.linalg.inv(np.array([[float(a) for a in row] for row in Jz])) R=[[Fr(float(a)) for a in row] for row in Rf] RJ=[[sum(R[i][k]*Jz[k][j] for k in range(30)) for j in range(30)] for i in range(30)] IRJ=[[(1 if i==j else 0)-RJ[i][j] for j in range(30)] for i in range(30)] Fz=F(z); RF=[sum(R[i][k]*Fz[k] for k in range(30)) for i in range(30)] ok=True for rr in (r,Fr(1,10**6)): q=norm(IRJ)+900*rr*norm(R); lhs=max(abs(a) for a in RF)+q*rr ok=ok and q<1 and lhseps for f in convergents(th) if f.denominator<=Q0): good.append(j+1) print(f"class {c}: Krawczyk {'passed' if ok else 'FAILED'} for r = 1e-60 and r = 1e-6 (q = {float(q):.2e} for r = 1e-6), " f"columns whose entry is not a root of unity: {len(good)} of 15, {good}",flush=True) open('certified16.txt','w').write('\n'.join(out)+'\n')