# blocks.py -- a second look at the circulant matrices found by joshua.py, from joshua_output/joshua.json. At the singular # points the Gauss-Newton solutions of joshua.py are only accurate to about 7 digits, so that the zeros of the profile S # appear as numbers of size 1e-7, and some matrices were wrongly recorded as having c_2 = 2. Here each first row is first # snapped, when possible, to the nearest vector of roots of unity of order m, for m in a list of small orders, and kept # when this gives an exact Hadamard matrix. Then dim P_2 is computed twice, as the number of orbitals, the connected # components of the graph on the pairs of rows (i1,i2), (j1,j2) joined when |S(i1,j1,i2,j2)| > 1e-4, and as the # multiplicity of the eigenvalue 1 of T_2, up to 1e-6, the matrices where the 2 numbers differ being near-degenerate # points of continuous families. For dim P_2 > 2 we search for the block systems, that is, the unions of orbitals which # together with the diagonal are equivalence relations with blocks of size 1 < m < N, which exist for the matrices of # Dita type. For dim P_2 = 2 we report the zeros of S on the quadruples of distinct indices, and the norms of the # shift-invariant blocks computed by joshua.py. # Usage: python3 blocks.py import json, numpy as np, itertools def circ(h): N=len(h); return np.array([[h[(x-i)%N] for x in range(N)] for i in range(N)]) def profile(H): return np.einsum('ax,bx,cx,dx->abcd',H,H.conj(),H.conj(),H) def orbitals(S,tol=1e-4): N=S.shape[0]; adj=(np.abs(S)>tol).transpose(0,2,1,3).reshape(N*N,N*N); lab=np.arange(N*N) while True: new=np.minimum(np.where(adj,lab[None,:],N*N).min(axis=1),lab) if (new==lab).all(): return lab.reshape(N,N) lab=new def T2count(S,N): T=(np.abs(S)**2).transpose(0,2,1,3).reshape(N*N,N*N)/N**3 return int(np.sum(np.linalg.eigvalsh(T)>1-1e-6)) def block_systems(L,maxorb=16): N=len(L); diag={L[i,i] for i in range(N)}; off=sorted(set(L.ravel())-diag); found=set() if len(off)>maxorb: return None for r in range(1,len(off)): for sub in itertools.combinations(off,r): R=np.isin(L,list(sub))|np.eye(N,dtype=bool) if (R==R.T).all() and (((R.astype(int)@R.astype(int))>0)==R).all(): s={int(R[i].sum()) for i in range(N)} if len(s)==1: found.add(s.pop()) return sorted(found) def distinct(N): a,b,c,d=np.indices((N,)*4); return (a!=b)&(a!=c)&(a!=d)&(b!=c)&(b!=d)&(c!=d) db=json.load(open('joshua_output/joshua.json')) print("N, then: classes, dim P_2 = 2 (zero-free), near-degenerate, dim P_2 > 2 with block sizes, max norm of the blocks c=0") for N in sorted(db,key=int): n=int(N); wild=0; zf=0; near=0; nonwild=[]; mx=0 for r in db[N]["c2_two"]: h=np.array([complex(a,b) for a,b in r["row"]]); H=circ(h) for m in sorted({n,2*n,4*n,8*n,12,24,60,84,120,140}): hs=np.exp(2j*np.pi*np.round(np.angle(h)/(2*np.pi/m))/m) if np.abs(hs-h).max()<1e-4 and np.abs(circ(hs)@circ(hs).conj().T-n*np.eye(n)).max()<1e-9: H=circ(hs); break S=profile(H); L=orbitals(S); p2=len(set(L.ravel())); p2b=T2count(S,n) if p2!=p2b: near+=1; continue if p2==2: wild+=1; zf+=int(np.sum((np.abs(S)<1e-4)&distinct(n))==0) if r["norms"]: mx=max(mx,max(r["norms"][k][0] for k in r["norms"])) else: nonwild.append((p2,block_systems(L))) nw=", ".join("%d:%s"%(a,"many orbitals" if b is None else b) for a,b in sorted(nonwild,key=lambda t:t[0])) print("%2d: %3d classes, %3d (%3d), %2d near-degenerate, %s, %.4f"%(n,len(db[N]["c2_two"]),wild,zf,near,nw if nw else "none",mx)) # Finally, the linearized orthogonality equations of the 2-valued matrices coming from the quadratic residues, at the # primes p = 67, 71, 79, 83, whose kernel gives the defect: at p = 71 there is a cluster of small singular values. print("2-valued matrices of the quadratic residues: defect, and smallest nonzero singular value") for p in (67,71,79,83): QR={(x*x)%p for x in range(1,p)}; z=(1-p+2j*np.sqrt(p))/(p+1) H=circ(np.array([z if x in QR else 1 for x in range(p)],complex)); rows=[] for i in range(p): for j in range(i+1,p): w=H[i]*np.conj(H[j]); r=np.zeros((p,p),complex); r[i,:]+=w; r[j,:]-=w; rows.append(r.ravel()) L=np.array(rows); s=np.sort(np.linalg.svd(np.vstack([L.real,L.imag]),compute_uv=False)); k=int(np.sum(s<1e-12)) print(" p=%d: defect %d, smallest nonzero singular value %.3e"%(p,k-(p-1),s[k]))