# matrices.py # Small Gram and Weingarten matrices, and integrals computed with them. We check: # (1) pairings of 4 points: the integrals of u_11^4, u_11 u_22 u_12 u_21 and u_11^2 u_22^2 # over the orthogonal group, its twist and its free version, and the integrals of # u_11 u_11* u_11 u_11* and u_11 u_11 u_11* u_11* in the symplectic cases, # (2) pairings of 6 points, in the order used in the paper, with the 5 noncrossing ones # first: the Weingarten matrix has entries a, b, c according to the number 3, 2, 1 # of blocks of the supremum, where a = (N^2 + 3 eps N - 2)/d, b = - eps (N + 2 eps)/d, # c = 2/d, with d = N (N - eps)(N - 2 eps)(N + 2 eps)(N + 4 eps), # (3) noncrossing pairings of 6 points: the Weingarten matrix is the matrix of polynomials # given in the paper, divided by N (N^2 - 1)(N^2 - 2), and the integral of u_11^6 over # the free orthogonal group is (5N - 7)/(N (N + 1)(N^2 - 2)), # (4) hyperoctahedral group, order 4: the inverse of the Gram matrix of the 3 pairings and # of the partition with 1 block is the matrix given in the paper, # (5) decorated partitions of 4 points: the inverse of the Gram matrix is the matrix given # in the paper, divided by 12 m (m - 1), and the integral of |u_11|^4 over the group # SU_2 wr S_m, computed with it, is 1/(3m). from fractions import Fraction from partitions import set_partitions, is_pairing, is_noncrossing, is_even, blocks from gram import loops, path_area from coordinates import integral def inverse(G): n = len(G) M = [[Fraction(a) for a in row] + [Fraction(int(i == j)) for j in range(n)] for i, row in enumerate(G)] for c in range(n): pivot = next(r for r in range(c, n) if M[r][c] != 0) M[c], M[pivot] = M[pivot], M[c] M[c] = [a / M[c][c] for a in M[c]] for r in range(n): if r != c and M[r][c] != 0: f = M[r][c] M[r] = [a - f * b for a, b in zip(M[r], M[c])] return [row[n:] for row in M] def ordered_pairings(): P = [p for p in set_partitions(6) if is_pairing(p)] NC = sorted([p for p in P if is_noncrossing(p)], key=lambda p: (path_area(p), p)) return NC + [p for p in P if not is_noncrossing(p)] def main(): good = True for N in (3, 4, 5, 8): F = Fraction ok = integral([1] * 4, [1] * 4, N, 1) == integral([1] * 4, [1] * 4, N, 1, -1) == F(3, N * (N + 2)) ok = ok and integral([1] * 4, [1] * 4, N, 1, free=True) == F(2, N * (N + 1)) r, c = [1, 2, 1, 2], [1, 2, 2, 1] ok = ok and integral(r, c, N, 1) == F(-1, N * (N - 1) * (N + 2)) and integral(r, c, N, 1, -1) == F(1, N * (N - 1) * (N + 2)) ok = ok and integral(r, c, N, 1, free=True) == 0 w = [1, 1, 2, 2] ok = ok and integral(w, w, N, 1) == integral(w, w, N, 1, -1) == F(N + 1, N * (N - 1) * (N + 2)) ok = ok and integral(w, w, N, 1, free=True) == F(1, N * N - 1) if N % 2 == 0: v = [1, 2, 1, 2] ok = ok and integral(v, v, N, -1) == integral(v, v, N, -1, -1) == integral(w, w, N, -1) == F(2, N * (N + 1)) ok = ok and integral(v, v, N, -1, free=True) == F(2, N * (N + 1)) and integral(w, w, N, -1, free=True) == F(1, N * N - 1) good = good and ok print('integrals of order 4:', good) P = ordered_pairings() L = [[loops(p, s) for s in P] for p in P] ok = all(sorted(row) == [1] * 8 + [2] * 6 + [3] for row in L) for eps in (1, -1): for N in (6, 7, 8, 9): W = inverse([[eps * (eps * N) ** l for l in row] for row in L]) d = Fraction(N * (N - eps) * (N - 2 * eps) * (N + 2 * eps) * (N + 4 * eps)) value = {3: (N * N + 3 * eps * N - 2) / d, 2: -eps * (N + 2 * eps) / d, 1: 2 / d} ok = ok and all(W[i][j] == value[L[i][j]] for i in range(15) for j in range(15)) ok = ok and all(sum(row) == Fraction(1, N * (N + 2 * eps) * (N + 4 * eps)) for row in W) print('pairings of 6 points, Weingarten matrix:', ok) good = good and ok ok = True for eps in (1, -1): for N in (2, 3, 4, 7): e = -eps * N M = [[N * N, e, e, 2, e], [e, N * N - 1, 1, e, 1], [e, 1, N * N - 1, e, 1], [2, e, e, N * N, e], [e, 1, 1, e, N * N - 1]] W = inverse([[eps * (eps * N) ** L[i][j] for j in range(5)] for i in range(5)]) D = N * (N * N - 1) * (N * N - 2) ok = ok and all(W[i][j] * D == M[i][j] for i in range(5) for j in range(5)) if eps == 1: ok = ok and integral([1] * 6, [1] * 6, N, 1, free=True) == Fraction(5 * N - 7, N * (N + 1) * (N * N - 2)) print('noncrossing pairings of 6 points, Weingarten matrix:', ok) good = good and ok E = sorted([p for p in set_partitions(4) if is_even(p)], key=lambda p: -len(blocks(p))) ok = True for N in (2, 3, 5): W = inverse([[N ** loops(p, s) for s in E] for p in E]) M = [[1, 0, 0, -1], [0, 1, 0, -1], [0, 0, 1, -1], [-1, -1, -1, N + 2]] ok = ok and all(W[i][j] * N * (N - 1) == M[i][j] for i in range(4) for j in range(4)) ok = ok and sum(sum(row) for row in W) == Fraction(1, N) print('hyperoctahedral group, order 4:', ok) good = good and ok from wreath import decorated D4 = decorated(4) key = lambda x: (len(blocks(x[0])), [tuple(b) for b in blocks(x[1])] != [(0, 1), (2, 3)], [tuple(b) for b in blocks(x[1])] == [(0, 2), (1, 3)]) D4 = sorted(D4, key=key) ok = [[tuple(b) for b in blocks(n)] for (p, n) in D4] == [[(0, 1), (2, 3)], [(0, 3), (1, 2)], [(0, 1), (2, 3)], [(0, 3), (1, 2)], [(0, 2), (1, 3)]] for m in (2, 3, 4, 7): G = [[m ** loops(p, p2) * (-2) ** loops(n, n2) for (p2, n2) in D4] for (p, n) in D4] M = [[4 * m + 2, 2 * m + 1, -3, 0, 3], [2 * m + 1, 4 * m + 2, 0, -3, 3], [-3, 0, 3, 0, 0], [0, -3, 0, 3, 0], [3, 3, 0, 0, 3]] W = inverse(G) ok = ok and all(W[i][j] * 12 * m * (m - 1) == M[i][j] for i in range(5) for j in range(5)) ok = ok and G[0] == [4 * m, -2 * m, 4 * m, -2 * m, -2 * m] and G[4] == [-2 * m, -2 * m, -2 * m, -2 * m, 4 * m * m] delta = [1, -1, 1, -1, 0] ok = ok and sum(delta[i] * W[i][j] * delta[j] for i in range(5) for j in range(5)) == Fraction(1, 3 * m) print('decorated partitions of 4 points:', ok) good = good and ok print('all checks passed' if good else 'some checks failed') if __name__ == '__main__': main()