"""Exact certificate for maximum-density balls in dimensions 4 through 11. Run with Python 3.8 or newer. Only the standard library is used. Each row supplies the right endpoint of an interval and a polynomial degree and parity. A negative degree denotes an interval excluded by volume or count. """ from fractions import Fraction as F from functools import lru_cache from math import ceil, floor # ROW_DATA is appended at the end of this file. def require(condition, reason): if not condition: raise ArithmeticError(reason) def poly_value(poly, x): value = F(0) for coefficient in reversed(poly): value = value * x + coefficient return value def multiply(left, right): product = [F(0)] * (len(left) + len(right) - 1) for i, x in enumerate(left): for j, y in enumerate(right): product[i+j] += x*y return product @lru_cache(None) def moment(d, i): if i % 2: return F(0) if i == 0: return F(1) return moment(d, i-2) * F(i-1, d+i-2) def weighted_mean(d, mode, poly): def weight_moment(i): if mode == -1: return moment(d, i) return moment(d, i) - moment(d, i+1+mode) return sum(x * weight_moment(i) for i, x in enumerate(poly)) @lru_cache(None) def orthogonal(d, mode, j): """Monic orthogonal polynomial and its squared norm, by Stieltjes recurrence.""" if j == 0: return (F(1),), weighted_mean(d, mode, (F(1),)) p, norm = orthogonal(d, mode, j-1) shift = weighted_mean(d, mode, [0] + multiply(p, p)) / norm result = [F(0)] + list(p) for i, c in enumerate(p): result[i] -= shift*c if j >= 2: q, old_norm = orthogonal(d, mode, j-2) for i, c in enumerate(q): result[i] -= (norm/old_norm)*c h = weighted_mean(d, mode, multiply(result, result)) require(h > 0, 'nonpositive polynomial norm') return tuple(result), h def check_polynomial(d, s, count, degree, parity): q = [F(0)] * (degree+1) for j in range(degree+1): p, h = orthogonal(d, parity, j) factor = poly_value(p, s)/h for i, v in enumerate(p): q[i] += factor*v f = multiply(multiply(q, q), [-s, 1]) if parity: f = multiply(f, [1, 1]) at_one = sum(f) # Expand in the monic zonal basis by cancelling leading terms. for j in range(len(f)-1, 0, -1): p, _ = orthogonal(d, -1, j) c = f[j] require(c >= 0 and sum(p) > 0, 'negative zonal coefficient') for i in range(j+1): f[i] -= c*p[i] require(f[0] > 0 and count*f[0] > at_one, 'insufficient count bound') def verify(): for d in range(4, 12): require(4*8**d > (d+2)*7**d, 'radius cutoff') a = F(1, 2) checks = 0 for row in ROW_DATA[d].split(): endpoint, degree, parity = row.split(',') b, j, e = F(endpoint), int(degree), int(parity) require(a < b <= 3, 'interval ordering') first = 9 if d == 4 else 3 low = max(first, ceil(2*(2*a)**d)) if j < 0: require(2*(2*a)**d > (2*a+1)**d or low > floor(2*(2*b)**d), 'uncovered interval') else: require(e in (0, 1), 'invalid parity') inner = 0 if b < 1 else max(1, 2**(d+1)*(b-1/b)**d) check_polynomial(d, 1-1/(2*b*b), low-inner, j, e) checks += 1 a = b require(a == 3, 'incomplete radius range') print('d=%2d: PASS (%d polynomial checks)' % (d, checks), flush=True) ROW_DATA = { 4: """ 21/32,-1,0 47/64,1,0 193/256,1,0 99/128,1,0 203/256,1,0 13/16,1,0 421/512,1,0 213/256,1,0 109/128,1,0 223/256,2,0 57/64,2,0 119/128,2,0 31/32,2,0 129/128,2,0 67/64,2,0 139/128,2,0 9/8,2,0 77/64,3,0 41/32,3,0 87/64,3,0 23/16,4,0 97/64,4,0 51/32,4,0 107/64,4,0 7/4,5,0 117/64,5,0 61/32,5,0 127/64,6,0 33/16,6,0 137/64,6,0 71/32,7,0 147/64,7,0 19/8,8,0 157/64,8,0 81/32,9,0 167/64,10,0 339/128,8,0 43/16,-1,0 3,-1,0 """, 5: """ 69/128,-1,0 143/256,0,0 37/64,0,0 79/128,0,0 163/256,0,0 21/32,1,0 173/256,0,1 89/128,1,0 183/256,1,0 47/64,1,0 193/256,1,0 99/128,1,0 203/256,1,0 13/16,1,0 213/256,1,0 109/128,1,0 57/64,1,1 119/128,2,0 31/32,2,0 129/128,2,0 67/64,2,0 139/128,3,0 9/8,3,0 77/64,3,0 41/32,3,0 87/64,4,0 23/16,4,0 97/64,4,0 51/32,5,0 7/4,6,0 117/64,6,0 61/32,6,0 127/64,6,0 33/16,7,0 137/64,7,0 71/32,7,0 147/64,8,0 19/8,8,0 157/64,8,0 81/32,9,0 167/64,9,0 43/16,10,0 177/64,10,0 91/32,10,0 187/64,11,0 3,11,0 """, 6: """ 69/128,0,0 37/64,0,0 79/128,0,0 21/32,0,0 89/128,0,1 47/64,1,0 99/128,1,0 13/16,1,0 109/128,2,0 57/64,2,0 119/128,2,0 31/32,2,0 129/128,2,0 67/64,2,0 9/8,3,0 77/64,3,0 41/32,4,0 87/64,4,0 23/16,4,0 51/32,6,0 7/4,6,0 61/32,7,0 33/16,8,0 71/32,9,0 19/8,10,0 81/32,11,0 167/64,10,0 43/16,10,0 177/64,11,0 91/32,11,0 187/64,12,0 3,12,0 """, 7: """ 69/128,0,0 37/64,0,0 79/128,0,0 21/32,0,0 89/128,1,0 47/64,1,0 99/128,1,0 13/16,1,0 109/128,2,0 57/64,2,0 119/128,2,0 31/32,2,0 67/64,3,0 9/8,3,0 77/64,4,0 41/32,4,0 87/64,4,0 23/16,5,0 51/32,6,0 7/4,7,0 61/32,8,0 33/16,8,0 71/32,9,0 19/8,10,0 81/32,11,0 43/16,12,0 91/32,13,0 3,15,0 """, 8: """ 69/128,0,0 37/64,0,0 79/128,0,0 21/32,0,0 89/128,1,0 47/64,1,0 99/128,1,0 13/16,1,0 57/64,2,0 31/32,2,0 67/64,3,0 9/8,3,0 77/64,4,0 41/32,4,0 23/16,6,0 51/32,6,0 7/4,7,0 61/32,8,0 33/16,9,0 71/32,10,0 19/8,11,0 81/32,12,0 43/16,13,0 91/32,14,0 3,15,0 """, 9: """ 69/128,0,0 37/64,0,0 21/32,0,0 47/64,1,0 13/16,2,0 57/64,2,0 31/32,2,0 67/64,3,0 9/8,3,0 77/64,4,0 41/32,4,0 23/16,6,0 51/32,7,0 7/4,8,0 61/32,9,0 33/16,10,0 71/32,11,0 19/8,12,0 81/32,13,0 43/16,14,0 91/32,15,0 3,16,0 """, 10: """ 69/128,0,0 37/64,0,0 21/32,0,0 47/64,1,0 13/16,1,0 57/64,2,0 31/32,3,0 67/64,3,0 9/8,4,0 41/32,5,0 23/16,6,0 51/32,7,0 7/4,8,0 61/32,9,0 33/16,10,0 71/32,11,0 19/8,13,0 81/32,14,0 43/16,15,0 91/32,16,0 3,17,0 """, 11: """ 69/128,0,0 37/64,0,0 21/32,0,0 47/64,1,0 13/16,1,0 57/64,2,0 31/32,3,0 67/64,3,0 9/8,4,0 41/32,5,0 23/16,6,0 51/32,8,0 7/4,9,0 61/32,10,0 33/16,11,0 71/32,12,0 19/8,13,0 81/32,15,0 43/16,16,0 91/32,17,0 3,18,0 """, } if __name__ == "__main__": verify()