""" weyl.py -- checks the results on the Weyl-Cayley graphs over M_n (section 4): the formula Ad_A . Ad_B = (Tr(A^*B)/n) Ad_{A,B}, the twirling formula sum_g Ad_{U_g} = J, the commutation relation U_g U_h U_g^* = omega^{sigma(g,h)} U_h, and the fact that d_S has the spectrum of the Cayley graph of Z_n^2. Also the quantum square on M_2 from the introduction, and the Weyl cycle (sections 6 and 7): simple, without loops, valence 2, with n components. Results are written to weyl.log. """ import itertools import numpy as np from qspace import QSpace, Logger, close, weyl, ad rng = np.random.default_rng(2026) log = Logger("weyl.log") def components(qs, d): w = np.linalg.eigvals(qs.laplacian(d)) return int(np.sum(np.abs(w) < 1e-9)) for n in [2, 3, 4, 5]: qs = QSpace([n]) om = np.exp(2j * np.pi / n) A = np.linalg.qr(rng.normal(size=(n, n)) + 1j * rng.normal(size=(n, n)))[0] B = np.linalg.qr(rng.normal(size=(n, n)) + 1j * rng.normal(size=(n, n)))[0] f1 = close(qs.schur_fast(ad(qs, A), ad(qs, B)), np.trace(A.conj().T @ B) / n * ad(qs, A, B)) f2 = close(sum(ad(qs, weyl(n, g)) for g in itertools.product(range(n), repeat=2)), qs.J()) f3 = all(close(weyl(n, g) @ weyl(n, h) @ weyl(n, g).conj().T, om ** (g[1] * h[0] - g[0] * h[1]) * weyl(n, h)) for g in itertools.product(range(n), repeat=2) for h in itertools.product(range(n), repeat=2)) els = [g for g in itertools.product(range(n), repeat=2) if g != (0, 0)] S = set() for i in rng.permutation(len(els))[:3]: g = els[i] S.add(g) S.add(((-g[0]) % n, (-g[1]) % n)) dS = sum(ad(qs, weyl(n, g)) for g in S) pts = list(itertools.product(range(n), repeat=2)) C = np.zeros((n * n, n * n)) for a, p in enumerate(pts): for g in S: C[a, pts.index(((p[0] + g[0]) % n, (p[1] + g[1]) % n))] += 1 f4 = np.max(np.abs(np.sort(np.linalg.eigvals(dS).real) - np.sort(np.linalg.eigvals(C).real))) < 1e-8 f5 = close(qs.schur_fast(dS, dS), dS) and close(qs.sharp(dS), dS) and close(qs.adjoint(dS), dS) log(f"=== M_{n}: Ad_A.Ad_B formula {f1}, twirling {f2}, commutation {f3}, " f"Cayley spectrum {f4} (S = {sorted(S)}), simple real undirected {f5}") # the quantum square on M_2: d = Ad_U + Ad_Lambda, U and Lambda being the Pauli matrices X and Z qs = QSpace([2]) d = ad(qs, weyl(2, (1, 0))) + ad(qs, weyl(2, (0, 1))) I = qs.identity() log(f"=== quantum square on M_2, matrix in the basis e11, e12, e21, e22:") for row in d.real.round(6): log(" " + " ".join(f"{x:3g}" for x in row)) log(f" simple {close(qs.schur_fast(d, d), d)}, without loops {close(qs.schur_fast(d, I), 0 * I)}, " f"real {close(qs.sharp(d), d)}, undirected {close(qs.adjoint(d), d)}, valence 2 {close(qs.degree(d), 2 * qs.one())}") log(f" spectrum {sorted(float(x) + 0.0 for x in np.round(np.linalg.eigvals(d).real, 6))}, components {components(qs, d)}") # the Weyl cycle d(x) = U x U^* + U^* x U on M_n for n in [3, 4, 5]: qs = QSpace([n]) U = weyl(n, (1, 0)) d = ad(qs, U) + ad(qs, U.conj().T) I = qs.identity() log(f"=== Weyl cycle on M_{n}: simple {close(qs.schur_fast(d, d), d)}, " f"without loops {close(qs.schur_fast(d, I), 0 * I)}, valence 2 {close(qs.degree(d), 2 * qs.one())}, " f"components {components(qs, d)} (expected n)") log(f" spectrum {sorted(float(x) + 0.0 for x in np.round(np.linalg.eigvals(d).real, 4))}") log.save()