"""Independent exact replay of the three-circle Neumann upper bound. Use x = r^2 and integrate P(x) and its derivative directly. The infinite part is bounded separately by a single annulus and an exponential majorant. Only Python's standard library is used. """ from fractions import Fraction as F def require(claim, reason): if not claim: raise ArithmeticError(reason) def square(coefficients): ans = [F(0) for _ in range(2 * len(coefficients) - 1)] for i, a in enumerate(coefficients): for j, b in enumerate(coefficients): ans[i + j] += a * b return ans def integral(coefficients, extra_power=0): return sum(a / (1 + i + extra_power) for i, a in enumerate(coefficients)) def evaluate(coefficients, x): value = F(0) for a in reversed(coefficients): value = value * x + a return value def atan_upper(x, terms): require(terms % 2 == 1 and 0 < x < 1, 'alternating upper bound') return sum((-1)**i * x**(2*i + 1) / (2*i + 1) for i in range(terms)) def main(): # g(r) = r P(r^2), while g'(r) = L(r^2). P = list(map(F, ('1', '-2/5', '9/100', '-7/200'))) L = [(2*i + 1)*a for i, a in enumerate(P)] # L'(x) = L_1 + 2 L_2 x + 3 L_3 x^2 <= L_1 + 2 L_2 < 0. require(L[2] > 0 > L[3] and L[1] + 2*L[2] < 0, 'L is decreasing') require(sum(L) == F(1, 200) and sum(P) == F(131, 200), 'radial endpoints') P2 = square(P) energy = integral(square(L)) + integral(P2) M = lambda j: j * integral(P2, j) target = F(30433, 100000) levels = tuple(map(F, ('9/22', '7/10', '15/17'))) centers = tuple(map(F, ('1/22', '10/21', '11/5'))) weights = tuple(F(n, 10**8) for n in (12422833, 1444049, 95966)) rows = list(zip(levels, centers, weights)) require(all(0 < t < 1 and b >= 0 and y > 0 for t, b, y in rows), 'dual signs') gain = sum(y * ((1+b)**2*t**4 - b*b) for t, b, y in rows) margin0 = M(1) + gain - target eps = F(1, 100000) require(margin0 > eps, 'constant coefficient') cutoff = 64 gaps = {} for k in range(1, cutoff): # 4 times the modal cost avoids halving a rational mode index. total4 = (k+1) * sum(y * (k-2*b)**2 * t**k for t, b, y in rows) gaps[k] = M(k+1) - target - total4/4 minimum = min(gaps, key=gaps.get) require(gaps[minimum] > eps, 'finite positive modes') # For k >= 64 ignore the shifts b in the costs and bound all masses on # 3/4 <= r <= 1. The ratio for (k+1) k^2 t^k decreases with k. K = cutoff require(max(centers) <= F(K, 2), 'shift majorant') ratio = max(levels) * F(K+2, K+1) * F(K+1, K)**2 require(ratio < 1, 'tail monotonicity of the majorant') tail_cost = F((K+1)*K*K, 4) * sum(y*t**K for t, _, y in rows) radius = F(3, 4) g_radius = radius * evaluate(P, radius**2) tail_mass = g_radius**2 * (1 - radius**(2*(K+1))) tail_margin = tail_mass - target - tail_cost require(tail_margin > F(29, 1000), 'entire infinite tail') # pi/4 = atan(1/2) + atan(1/3), with both angles in (0,pi/4). require((F(1,2)+F(1,3))/(1-F(1,2)*F(1,3)) == 1, 'tangent addition') pi_upper = 4 * (atan_upper(F(1,2),15) + atan_upper(F(1,3),11)) endpoint = F(517, 50) require(pi_upper*energy < endpoint*target, 'published spectral target') require(pi_upper*energy < F(6462,625)*(target+eps), 'sharper checked bound') print('PASS independent three-circle audit') print('energy', energy, 'target mass', target, 'g(1)', sum(P), "g'(1)", sum(L)) print('constant excess', float(margin0), 'least finite excess', float(gaps[minimum]), 'mode', minimum) print('tail excess', float(tail_margin), 'for every k >=', K) print('pi upper', float(pi_upper), 'area times eigenvalue upper', float(pi_upper*energy/(target+eps))) if __name__ == '__main__': main()