# itoexample.py -- the smallest case of Theorem 3.6: the Walsh matrix W_8, cocyclic over the dihedral group D_4 of # order 8 with extension group Q_16 (cocyclew8.json, from cocycle.py), and its explicit bistochastic forms obtained by # twisting along the cyclic subgroup Z_4. The group is relabeled as 1,r,r^2,r^3,s,rs,r^2s,r^3s, a trivialization phi_0 # of psi on , with values in the 8-th roots of unity, is extended as in Lemma 3.1, and the form B = D_a M_psi D_b, # with b = conj(phi)(1 on , w outside), is written as B = D_x K D_y, with K in M_8(Z_8), and x, y constant on cosets. import numpy as np, json, itertools data=json.load(open('cocyclew8.json')); N=8; z8=np.exp(2j*np.pi/8) def eorders(mult,psi): # element orders in the extension group E = {+-1} x G E=[(e,g) for e in (1,-1) for g in range(N)] mul=lambda a,b:(a[0]*b[0]*int(psi[a[1]][b[1]]),mult[a[1]][b[1]]) out=[] for x in E: y=x; k=1 while y!=(1,0): y=mul(y,x); k+=1 out.append(k) return sorted(out) for C in data: if C['group']!='D4' or not C['z_in_commutator']: continue mult=C['mult']; psi=np.array(C['psi']) if eorders(mult,psi)!=[1,2]+[4]*10+[8]*4: continue break def power(g,k): y=0 for _ in range(k): y=mult[y][g] return y r=next(g for g in range(N) if power(g,4)==0 and power(g,2)!=0) s=next(g for g in range(N) if g not in [power(r,k) for k in range(4)]) lab=[power(r,k) for k in range(4)]+[mult[power(r,k)][s] for k in range(4)] P=psi[np.ix_(lab,lab)].astype(int) # psi in the ordering 1,r,r^2,r^3,s,rs,r^2s,r^3s m=lambda a,b: lab.index(mult[lab[a]][lab[b]]) for e in range(8): # phi_0(r^a) by the recursion phi0(xr) = phi0(x) phi0(r)/psi(x,r) phi=[1+0j] for a in range(1,4): phi.append(phi[-1]*z8**e/P[a-1,1]) if all(abs(P[a,b]-phi[a]*phi[b]/phi[m(a,b)])<1e-9 for a in range(4) for b in range(4)): break phi=phi+[P[a,4]*phi[a] for a in range(4)] # phi(x s) = psi(x,s) phi_0(x), psi real f=np.conj(np.array(phi)); S0,S1=f[:4].sum(),f[4:].sum() w=1j*S0*np.conj(S1)/abs(S0*S1) b=f*np.array([1]*4+[w]*4); R=P@b; a=np.conj(R/abs(R)); B=a[:,None]*P*b[None,:] assert np.abs(B.sum(0)-B[0].sum()).max()<1e-9 and np.abs(B.sum(1)-B[0].sum()).max()<1e-9 and abs(abs(B[0].sum())-np.sqrt(8))<1e-9 y=np.array([1]*4+[w]*4); x=np.array([a[0]]*4+[a[4]]*4); K=B/(x[:,None]*y[None,:]) E=np.round(np.angle(K)/(2*np.pi)*8).astype(int)%8 assert np.abs(K-z8**E).max()<1e-9 print("element orders of E:",eorders(mult,psi)) print("psi, in the ordering 1,r,r^2,r^3,s,rs,r^2s,r^3s:"); print('\n'.join(' '.join('+' if v>0 else '-' for v in row) for row in P)) print("phi_0(r) = zeta_8^%d, S0 = %s, S1 = %s, w = %s" % (e,np.round(S0,6),np.round(S1,6),np.round(w,6))) print("K, entries zeta_8^k, the exponents k:"); print('\n'.join(' '.join(map(str,row)) for row in E)) print("x = %s on , %s outside; y = 1 on , w outside; line sums %s" % (np.round(x[0],6),np.round(x[4],6),np.round(B[0].sum(),6))) EB=np.round(np.angle(B)/(2*np.pi)*8,6)%8 if np.allclose(EB,np.round(EB)): print("here B itself has entries in Z_8, the exponents being:"); print('\n'.join(' '.join(str(int(round(v))%8) for v in row) for row in EB))