# complexglow.py -- the complex glow versus the Jones transfer matrix T_2, in floating point, the exact version being # glowmoments.py. For a complex Hadamard matrix H of order N, with a,b uniform on T^N, we compute the moments # E|Omega|^(2p), Omega = : the average over b is done by the multinomial formula # E_b|sum_k c_k b_k|^(2p) = sum_{|alpha|=p} (p!/alpha!)^2 prod_k |c_k|^(2 alpha_k), with c = H^t a, and the average over a, # a trigonometric polynomial of degree p in each a_j, is computed on the (2p+1)-th roots of unity, with a_1 = 1. We # compare E|Omega|^8 with R_2(H) = sum_{j,l} |sum_k H_jk^2 conj(H_lk)^2|^2, which is the sum of the squared flux phases # of the rectangles, and with N^3 Tr(T_2 F), where F is the flip of the 2 legs of T_2, and compute the examples of # Section 8. The universal polynomials are found by interpolation on the Fourier matrices F_N with N <= 7, after # rounding, and checked at N = 8, 9. import numpy as np, itertools from math import factorial from fractions import Fraction def moment(H,p,chunk=400000): N=len(H); q=2*p+1; w=np.exp(2j*np.pi*np.arange(q)/q); tot=0.0; cnt=0 it=itertools.product(range(q),repeat=N-1) while True: block=list(itertools.islice(it,chunk)) if not block: break A=np.array(block,dtype=int).reshape(len(block),N-1) a=np.ones((len(block),N),complex); a[:,1:]=w[A] x=np.abs(a@H)**2; poly=np.zeros((len(x),p+1)); poly[:,0]=1 for k in range(N): new=np.zeros_like(poly) for n in range(p+1): new[:,n:]+=poly[:,:p+1-n]*(x[:,[k]]**n)/factorial(n)**2 poly=new tot+=poly[:,p].sum(); cnt+=len(x) return factorial(p)**2*tot/cnt def R(H,k=2): K=H**k; G=K@K.conj().T; return np.sum(np.abs(G)**2).real def Xi(H): N=len(H); X=(H[:,None,:]*H.conj()[None,:,:]).reshape(N*N,N)/np.sqrt(N); return X@X.conj().T # def flipped_trace(H): N=len(H); T2=np.abs(Xi(H))**2/N; idx=np.arange(N*N); swap=(idx%N)*N+idx//N return np.sum(T2[idx,swap]) def dims(H): N=len(H); G=Xi(H); T2=np.abs(G)**2/N; c2=int(np.sum(np.linalg.eigvalsh(T2)>1-1e-8)) Gr=G.reshape(N,N,N,N) T3=np.einsum('bBaA,cCbB,aAcC->abcABC',Gr,Gr,Gr,optimize=True).reshape(N**3,N**3)/N c3=int(np.sum(np.linalg.eigvalsh(T3)>1-1e-7)); return c2,c3 def fourier(N): return np.exp(2j*np.pi*np.outer(np.arange(N),np.arange(N))/N) def solve(A,b): n=len(A); M=[row[:]+[bb] for row,bb in zip(A,b)] for c in range(n): p=next(r for r in range(c,n) if M[r][c]!=0); M[c],M[p]=M[p],M[c] for r in range(n): if r!=c and M[r][c]!=0: f=M[r][c]/M[c][c]; M[r]=[x-f*y for x,y in zip(M[r],M[c])] return [M[i][n]/M[i][i] for i in range(n)] print("(1) universal parts, from the Fourier matrices") vals={} for N in range(1,10): H=fourier(N); m=[moment(H,p) for p in (1,2,3,4)] vals[N]=[round(m[0]),round(m[1]),round(m[2]),round(m[3]-18*R(H))] print(f" N={N}: E|Omega|^2,4,6 = {vals[N][:3]}, E|Omega|^8 - 18 R_2 = {vals[N][3]}",flush=True) for idx,(lo,hi) in enumerate([(2,2),(2,4),(2,6),(2,8)]): ns=list(range(1,hi-lo+2)) c=solve([[Fraction(n)**k for k in range(lo,hi+1)] for n in ns],[Fraction(vals[n][idx]) for n in ns]) ok=all(sum(ci*Fraction(n)**(lo+i) for i,ci in enumerate(c))==vals[n][idx] for n in range(1,10)) poly=" + ".join(f"({ci})N^{lo+i}" for i,ci in reversed(list(enumerate(c))) if ci!=0) print(f" p={idx+1}: {poly} [checked for N=1..9: {ok}]") print("(2) examples: E|Omega|^8, R_2, N^3 Tr(T_2 F), flux harmonics R_1, R_3, and dim P_2, dim P_3") i=1j; w=np.exp(2j*np.pi/3) def F4q(t): q=np.exp(1j*t); return np.array([[1,1,1,1],[1,-1,1,-1],[1,q,-1,-q],[1,-q,-1,q]]) def dita6(t): F2=fourier(2); F3=fourier(3); q=np.exp(1j*t); Q=np.array([[1,1],[1,q],[1,q**2]]); H=np.zeros((6,6),complex) for a in range(3): for b in range(2): for c in range(3): for d in range(2): H[2*a+b,2*c+d]=Q[a,d]*F3[a,c]*F2[b,d] return H Haag=np.array([[1,1,1,1,1,1],[1,-1,i,i,-i,-i],[1,i,-1,-i,i,-i],[1,i,-i,-1,-i,i],[1,-i,i,-i,-1,i],[1,-i,-i,i,i,-1]]) Tao=np.array([[1,1,1,1,1,1],[1,1,w,w,w**2,w**2],[1,w,1,w**2,w**2,w],[1,w,w**2,1,w,w**2],[1,w**2,w**2,w,1,w],[1,w**2,w,w**2,w,1]]) ex=[(f"F_2 (x)_q F_2, q=e^({t}i)",F4q(t)) for t in (0,0.3,0.7,1.0,np.pi/4,np.pi/2)] ex+=[("F_5",fourier(5)),("F_6",fourier(6)),("F_3 (x)_Q F_2, t=0.4",dita6(0.4)),("F_3 (x)_Q F_2, t=1.1",dita6(1.1)), ("Haagerup",Haag),("Tao",Tao),("had12 (real)",np.loadtxt('matrices/had12.txt'))] for name,H in ex: N=len(H); assert np.allclose(H@H.conj().T,N*np.eye(N)),name m8=moment(H,4) if N<=6 else np.nan; c2,c3=dims(H) print(f" {name:26s} N={N:2d} E|Omega|^8={m8:.4f} R_2={R(H):.4f} N^3Tr(T2F)={N**3*flipped_trace(H):.4f}" f" N^3={N**3} N^4={N**4} R_1={R(H,1):.1f} R_3={R(H,3):.4f} dim P2={c2} dim P3={c3}",flush=True)