# coordinates.py # Integrals of the coordinates, computed with the super-easy Weingarten formula. For the # pairings of 2n points, the integral of u_{i1 j1} ... u_{i2n j2n} is the sum over the # pairings p, s of d_p(i) d_s(j) W(p,s), where W is the inverse of the Gram matrix # eps^n (eps N)^loops, and where d_p(i) is the usual Kronecker symbol when eps = 1, and # the symplectic one when eps = -1, namely (-1)^crossings times the product of the # entries J[i_y][i_x] over the strings x < y. In the symplectic case the adjoint of u_11 # is u_22. The sign q^(n(i)+n(j)) is trivial for the multi-indices used here. We check: # (1) the entries of the Weingarten matrix on 4 points, which are (N + eps)/d on the # diagonal and -eps/d off the diagonal, with d = N (N - eps) (N + 2 eps), # (2) orthogonal group: the integral of u_11^(2p) is (2p-1)!!/(N (N+2) ... (N+2p-2)), # (3) symplectic group: the integral of |u_11|^(2p) is p!/(N (N+1) ... (N+p-1)), # (4) free symplectic group at N = 2, which is SU_2: the integral of |u_11|^(2p) is 1/(p+1), # (5) free case, large N: N^2 times the integral of u_11 u_11 u_11* u_11* is close to 2 # in the orthogonal case, and to 1 in the symplectic case, and N^p times the integral # of (u_11 u_11*)^p is close to the Catalan number, in both cases. from fractions import Fraction from math import comb from partitions import set_partitions, is_pairing, is_noncrossing, blocks from gram import loops def number(word, eps): # the number n(i), with the pairs being {1,2}, {3,4}, ... when eps = -1 c = [x if eps == 1 else (x + 1) // 2 for x in word] return sum(1 for r in range(len(c)) for s in range(r + 1, len(c)) if c[r] < c[s]) def symbol(p, word, eps): strings = [tuple(b) for b in blocks(p)] if eps == 1: return 1 if all(word[x] == word[y] for (x, y) in strings) else 0 J = lambda a, b: (1 if a % 2 == 0 else -1) if (a + 1) // 2 == (b + 1) // 2 and a != b else 0 value = 1 for (x, y) in strings: value *= J(word[y], word[x]) cross = sum(1 for (a, b) in strings for (c, d) in strings if a < c < b < d) return (-1) ** cross * value def solve(G, v): # solution of G x = v, with exact arithmetic n = len(G) M = [[Fraction(a) for a in row] + [Fraction(b)] for row, b in zip(G, v)] 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 [M[r][n] for r in range(n)] def integral(rows, columns, N, eps, q=1, free=False): n = len(rows) // 2 D = [p for p in set_partitions(2 * n) if is_pairing(p) and (is_noncrossing(p) or not free)] G = [[eps ** n * (eps * N) ** loops(p, s) for s in D] for p in D] a = [symbol(p, rows, eps) for p in D] b = [symbol(p, columns, eps) for p in D] x = solve(G, b) return q ** (number(rows, eps) + number(columns, eps)) * sum(s * t for s, t in zip(a, x)) def catalan(p): return comb(2 * p, p) // (p + 1) def main(): good = True for eps in (1, -1): for N in (4, 6, 8): D = [p for p in set_partitions(4) if is_pairing(p)] d = Fraction(N * (N - eps) * (N + 2 * eps)) for s in range(3): x = solve([[(eps * N) ** loops(p, t) for t in D] for p in D], [1 if t == s else 0 for t in range(3)]) good = good and all(x[t] == ((N + eps) / d if t == s else -eps / d) for t in range(3)) print('Weingarten matrix on 4 points:', good) for N in (3, 4, 5, 6): for p in (1, 2, 3): value = Fraction(1) for r in range(p): value *= Fraction(2 * r + 1, N + 2 * r) ok = all(integral([1] * (2 * p), [1] * (2 * p), N, 1, q) == value for q in (1, -1)) good = good and ok print('orthogonal group, moments of u_11:', good) for N in (4, 6, 8): for p in range(1, N // 2 + 1): if p > 3: continue value = Fraction(1) for r in range(p): value *= Fraction(r + 1, N + r) ok = all(integral([1, 2] * p, [1, 2] * p, N, -1, q) == value for q in (1, -1)) ok = ok and integral([1] * p + [2] * p, [1] * p + [2] * p, N, -1) == value good = good and ok print('symplectic group, moments of |u_11|^2:', good) ok = all(integral([1, 2] * p, [1, 2] * p, 2, -1, free=True) == Fraction(1, p + 1) for p in (1, 2, 3, 4)) good = good and ok print('free symplectic group at N = 2:', ok) N = 10 ** 6 close = lambda x, y: abs(x - y) < Fraction(1, 1000) ok = close(N ** 2 * integral([1, 1, 1, 1], [1, 1, 1, 1], N, 1, free=True), 2) ok = ok and close(N ** 2 * integral([1, 1, 2, 2], [1, 1, 2, 2], N, -1, free=True), 1) for p in (1, 2, 3, 4): ok = ok and close(N ** p * integral([1] * (2 * p), [1] * (2 * p), N, 1, free=True), catalan(p)) ok = ok and close(N ** p * integral([1, 2] * p, [1, 2] * p, N, -1, free=True), catalan(p)) good = good and ok print('free case, large N, semicircular and circular behavior:', ok) print('all checks passed' if good else 'some checks failed') if __name__ == '__main__': main()