# Sections 2 and 7: explicit sign matrices, with exact checks. FIVE is singular, and is the sign matrix of 2 neutral local maxima of the # 1-norm on O(5). SIX, SEVEN, NINE, ELEVEN are the sign matrices of the best orthogonal matrices that we know at N = 6, 7, 9, 11, the # first 2 being optimal, by the exhaustive searches of census.py and seven.py, SEVEN being a normalized form of the sign matrix of the # Fano plane, and NEXT being a sign matrix on the second level at N = 7. We compute the characteristic polynomial of S S^t over the integers, we compare # it with its expected factorization, which gives Tr|S| in closed form, and we check that S is the sign matrix of its polar part. # Usage: python3 optimal.py import numpy as np from fractions import Fraction FIVE = ["+++++", "+-+-+", "++-+-", "+++--", "+----"] SIX = ["++++++", "+---++", "+--+-+", "+--++-", "+-+---", "++----"] NINE = ["+---+++--", "++-+++--+", "++----+++", "+-+++++++", "-+-+++++-", "+++--+-+-", "-++-+++-+", "---+-++-+", "++++--+--"] ELEVEN = ["+++++--++--", "+++-++++++-", "--+-++-++++", "+-+-+----+-", "+++--+-+--+", "---+++++---", "-++-+-+---+", "+-+++++-+-+", "+---+-+++-+", "--+---+++--", "-+--++--+--"] SEVEN = ["+++++++", "+--+--+", "+++---+", "++-+-+-", "+-+--+-", "+-+++--", "++--+--"] NEXT = ["+++++++", "+-----+", "+-+--+-", "++---+-", "+--++--", "+++-+--", "++++---"] def matrix(rows): return [[1 if c == "+" else -1 for c in r] for r in rows] def charpoly(G): # Faddeev-LeVerrier, in exact arithmetic: coefficients of det(x - G), leading one first n = len(G); M = [[Fraction(0)]*n for _ in range(n)]; c = [Fraction(1)] for k in range(1, n + 1): M = [[sum(G[i][l]*M[l][j] for l in range(n)) + (c[-1] if i == j else 0) for j in range(n)] for i in range(n)] c.append(-sum(sum(G[i][l]*M[l][i] for l in range(n)) for i in range(n))/k) return [int(x) for x in c] def product(factors): p = [1] for f, e in factors: for _ in range(e): p = [sum(p[i - j]*f[j] for j in range(len(f)) if 0 <= i - j < len(p)) for i in range(len(p) + len(f) - 1)] return p CASES = (("FIVE", FIVE, [([1, 0], 1), ([1, -8], 2), ([1, -9, 16], 1)], "4 sqrt(2) + sqrt(17)", 4*np.sqrt(2) + np.sqrt(17)), ("SIX", SIX, [([1, -10], 2), ([1, -4], 4)], "8 + 2 sqrt(10)", 8 + 2*np.sqrt(10)), ("SEVEN", SEVEN, [([1, -8], 6), ([1, -1], 1)], "1 + 12 sqrt(2)", 1 + 12*np.sqrt(2)), ("NEXT", NEXT, [([1, -4], 4), ([1, -9], 1), ([1, -12], 2)], "11 + 4 sqrt(3)", 11 + 4*np.sqrt(3)), ("NINE", NINE, [([1, -8], 6), ([1, -4], 1), ([1, -29, 196], 1)], "2 + 12 sqrt(2) + sqrt(57)", 2 + 12*np.sqrt(2) + np.sqrt(57)), ("ELEVEN", ELEVEN, [([1, -12], 4), ([1, -4], 1), ([1, -21, 100], 1), ([1, -24, 112], 2)], "2 + 8 sqrt(3) + sqrt(41) + 4 sqrt(6 + 2 sqrt(7))", 2 + 8*np.sqrt(3) + np.sqrt(41) + 4*np.sqrt(6 + 2*np.sqrt(7)))) if __name__ == "__main__": for name, rows, factors, formula, value in CASES: S = matrix(rows); n = len(S); G = [[sum(S[i][l]*S[j][l] for l in range(n)) for j in range(n)] for i in range(n)] A = np.array(S, float); w, s, vt = np.linalg.svd(A); d = np.ones(n); d[-1] = -1 fits = [bool(np.abs(U).min() > 1e-9 and (np.sign(U) == A).all()) for U in (w @ vt, (w*d) @ vt)] what = "S is the sign matrix of both the matrices U_+, U_-: %s" % (fits[0] and fits[1]) if s[-1] < 1e-9 else "S is the sign matrix of its polar part: %s" % fits[0] print("%s: characteristic polynomial of S S^t as expected: %s; Tr|S| = %s = %.6f (numerically %.6f), divided by N^1.5: %.6f; %s" % (name, charpoly(G) == product(factors), formula, value, s.sum(), value/n**1.5, what))