# order8.py -- bistochastic forms of BH(8,q) classes: find forms numerically, check isolation (Jacobian rank), # cluster them by invariants, and compute the algebraic degree of one representative per cluster. import numpy as np, sys, time from collections import defaultdict from formdegree import degree fname,cls=sys.argv[1],[int(c) for c in sys.argv[2].split(',')] L=[l.strip() for l in open(fname) if l.strip()] rng=np.random.default_rng(0) for c in cls: line=L[c-1]; q=int(line[5]) if line[5].isdigit() else ord(line[5])-48 E=np.array([ord(x)-48 for x in line[6:70]]).reshape(8,8); H=np.exp(2j*np.pi*E/q); N=8 B=np.exp(2j*np.pi*rng.random((3000,N))) for it in range(4000): U=B@H.T; U/=abs(U); B=U@H.conj(); B/=abs(B) # b -> ph(H^* u) res=np.abs(abs(B@H.T)-np.sqrt(N)).max(1); B=B[res<1e-10] # Jacobian rank of theta -> |H e^{i theta}|^2 S=B@H.T J=2*np.real(np.conj(S)[:,:,None]*1j*H[None]*B[:,None,:]); sv=np.linalg.svd(J,compute_uv=False) rk=(sv>1e-6*sv[:,:1]).sum(1) # fingerprint: sorted |row sums of B o B| of the bistochastic matrix A=np.conj(S/abs(S)); M=A[:,:,None]*H[None]*B[:,None,:] fp=np.round(np.concatenate([np.sort(abs((M*M).sum(2)),1),np.sort(abs((M*M*M).sum(2)),1)],1),5) groups=defaultdict(list) for k,f in enumerate(fp): groups[(f.tobytes(),rk[k])].append(k) print(f"BH(8,{q}) class {c}: {len(B)} converged of 3000; Jacobian ranks {dict(zip(*np.unique(rk,return_counts=True)))}; {len(groups)} invariant classes",flush=True) for (key,r),ks in sorted(groups.items(),key=lambda kv:-len(kv[1]))[:6]: if r 32'} (height {h}, {time.time()-t:.0f}s)",flush=True)