# p12twist.py -- an explicit bistochastic form of the Paley matrix P12 (p12.txt, same ordering as in section 4) over the # 24-th roots of unity, up to a common phase, obtained as a twist along a subgroup Z_6 of D_6 (cocycle_p12.json), as in # twist.py: with phi extended from a trivialization phi_0 on Z_6 as in Lemma 3.1, and w = i S0 conj(S1)/|S0 S1|, the # column multipliers conj(phi)(1 on Z_6, w outside) are transported to P12, the rows are rephased, and the result is # divided by its first entry. Prints the exponents k of the entries zeta_24^k, and the common line sum. import numpy as np, json, itertools H=np.loadtxt('p12.txt'); N=12; z24=np.exp(2j*np.pi/24) C=next(c for c in json.load(open('cocycle_p12.json')) if c['group']=='D6') rl,cl,mult,psi=C['rows'],C['cols'],np.array(C['mult']),np.array(C['psi'],float); cs=H[np.ix_(rl,cl)][0,:] def gen(S): S=set(S)|{0} while True: T=S|{int(mult[a][b]) for a in S for b in S} if T==S: return S S=T G0=next(sorted(gen([g])) for g in range(N) if len(gen([g]))==6) # the cyclic subgroup Z_6 g=next(x for x in G0 if len(gen([x]))==6); t=next(h for h in range(N) if h not in G0) for v in range(N): phi={0:1+0j}; x=0 for k in range(5): y=int(mult[x][g]); phi[y]=phi[x]*np.exp(2j*np.pi*v/N)/psi[x,g]; x=y if not all(abs(psi[a,b]-phi[a]*phi[b]/phi[int(mult[a][b])])<1e-9 for a in G0 for b in G0): continue for x in G0: phi[int(mult[x][t])]=psi[x,t]*phi[x] f=np.conj(np.array([phi[h] for h in range(N)])); S0=f[G0].sum(); S1=f[[h for h in range(N) if h not in G0]].sum() if abs(abs(S0)**2-8)>1e-9: continue w=1j*S0*np.conj(S1)/abs(S0*S1); beta=f*np.where(np.isin(np.arange(N),G0),1,w) b=np.zeros(N,complex); b[cl]=cs*beta; s=H@b; a=np.conj(s/abs(s)); B=a[:,None]*H*b[None,:]; B=B/B[0,0] E=np.angle(B)/(2*np.pi)*24 if np.allclose(E,np.round(E)): break E=np.round(E).astype(int)%24 assert np.abs(B-z24**E).max()<1e-9 and np.allclose(B.sum(0),B.sum(0)[0]) and np.allclose(B.sum(1),B.sum(0)[0]) print(f"|S0|^2 = {abs(S0)**2:.6f}, w = zeta_24^{round(np.angle(w)/(2*np.pi)*24)%24}, line sums {np.round(B.sum(0)[0],6)}") print("exponents k of the entries zeta_24^k:"); print('\n'.join(' '.join(f"{k:2d}" for k in row) for row in E))