# The 4 mutually unbiased bases of C^3 coming from the 4 lines through 0 in F_3^2, their Hadamard transition # matrices, and the action of the Clifford group (and of complex conjugation) on them, via A_4 and S_4. import numpy as np, itertools out = open("cantona-output.txt", "w") def say(s): print(s, flush=True); out.write(s + "\n"); out.flush() N = 3; w = np.exp(2j * np.pi / 3) G = [(i, j) for i in range(3) for j in range(3)] def W(g): i, j = g; M = np.zeros((N, N), complex) for k in range(N): M[k, (k + j) % N] = w ** (k * i) return M lines = [(0, 1), (1, 0), (1, 1), (1, 2)] def norm(v): return tuple(x % 3 for x in v) def line_of(g): for L in lines: if norm(g) in [norm(L), norm((2 * L[0], 2 * L[1]))]: return L B = {L: np.linalg.eig(W(L))[1] for L in lines} say("4 mutually unbiased bases: %s" % all(np.allclose(np.abs(B[a].conj().T @ B[b]) ** 2, 1 / 3) for a in lines for b in lines if a != b)) say("transition matrices times sqrt(3) are complex Hadamard: %s" % all(np.allclose(np.abs(np.sqrt(3) * B[a].conj().T @ B[b]), 1) for a in lines for b in lines if a != b)) # Clifford generators: Fourier matrix and phase gate F = np.array([[w ** (a * b) for b in range(3)] for a in range(3)]) / np.sqrt(3) P = np.diag([1, 1, w]) def induced(U): A = {} for g in [(1, 0), (0, 1)]: X = U @ W(g) @ U.conj().T for h in G: if abs(abs(np.trace(W(h).conj().T @ X) / 3) - 1) < 1e-9: A[g] = h return np.array([[A[(1, 0)][0], A[(0, 1)][0]], [A[(1, 0)][1], A[(0, 1)][1]]]) % 3 AF, AP = induced(F), induced(P) say("Fourier induces %s, phase gate induces %s, determinants %d %d" % (AF.tolist(), AP.tolist(), round(np.linalg.det(AF)) % 3, round(np.linalg.det(AP)) % 3)) for nm, U, A in [("Fourier", F, AF), ("phase gate", P, AP)]: ok = True for L in lines: M = A @ np.array(L) % 3; L2 = line_of(tuple(M)) C = np.abs(B[L2].conj().T @ (U @ B[L])) ok = ok and np.allclose(np.sort(C, axis=0)[-1], 1) say("%s maps each basis B_L to B_(AL): %s" % (nm, ok)) def generate(gens): key = lambda A: tuple((A % 3).flatten()) S = {key(np.eye(2, dtype=int))}; frontier = [np.eye(2, dtype=int)] while frontier: nf = [] for A in frontier: for g in gens: Bm = (g @ A) % 3 if key(Bm) not in S: S.add(key(Bm)); nf.append(Bm) frontier = nf return [np.array(k).reshape(2, 2) for k in S] def action_on_lines(A): return tuple(lines.index(line_of(tuple(A @ np.array(L) % 3))) for L in lines) def orders(perms): res = {} for p in perms: q, o = p, 1 while q != tuple(range(4)): q = tuple(p[i] for i in q); o += 1 res[o] = res.get(o, 0) + 1 return dict(sorted(res.items())) SL = generate([AF, AP]); im = set(action_on_lines(A) for A in SL) say("group generated by the Clifford generators: order %d (SL_2(3) has order 24)" % len(SL)) say("induced action on the 4 lines: image of order %d, element orders %s (A_4: {1:1,2:3,3:8})" % (len(im), orders(im))) Cc = np.array([[2, 0], [0, 1]]) # complex conjugation sends W_(i,j) to W_(-i,j) say("complex conjugation sends W_(i,j) to W_(-i,j): %s" % all(np.allclose(W(g).conj(), W(((-g[0]) % 3, g[1]))) for g in G)) GL = generate([AF, AP, Cc]); im2 = set(action_on_lines(A) for A in GL) say("with complex conjugation: order %d (GL_2(3) has order 48), image on lines of order %d, element orders %s (S_4: {1:1,2:9,3:8,4:6})" % (len(GL), len(im2), orders(im2))) D = np.diag([1, 1, w]); Fn = np.array([[w ** (a * b) for b in range(3)] for a in range(3)]) / np.sqrt(3) expl = {"I": np.eye(3), "F/sqrt3": Fn, "D F/sqrt3": D @ Fn, "D^2 F/sqrt3": D @ D @ Fn} for nm, M in expl.items(): match = [L for L in lines if np.allclose(np.sort(np.abs(B[L].conj().T @ M), axis=0)[-1], 1)] say("explicit basis %s, with D = diag(1,1,w), equals B_L for L = %s" % (nm, match)) say("done")