#!/usr/bin/env python3 """Check the stationarity and polynomial identities for the two-angle bound (V10).""" import sympy as sp def equal(left, right): if sp.cancel(left - right) != 0: raise ArithmeticError("Winding identity failed") a, b, x, y, kappa, T, logarithm = sp.symbols("a b x y kappa T logarithm") u, v = a + b, x + y Z = 1 - a*b z, h = Z/u, (1 - x*y)/v M = 1 + a**2 W = a + z s0 = v/(kappa*u**2) s = (x+h)/(kappa*W**2) equal(W, M/u) equal(v*(x+h), 1+x**2) # Gram on visit k, with det S = 1/(4*kappa**2) and mu_k=4*M. equal((s/8)*(s0/8) - (x/(8*kappa*M))**2, 1/(64*kappa**2*M**2)) delta = u+z-(a*(y+h)+b*(x+h)+z*v)/kappa left_share, right_share = a/T, a/u stationarity = (2*x/(kappa*M) - 1 - left_share - right_share + a**2/M - logarithm + (1-s)/left_share + (1-s0)/right_share) row = (s*T + s0*u - 2*a*x/(kappa*M) - u - T + a**2/u + a**2/T + a/M + a*logarithm) equal(row, -a*stationarity) integral = (s-1)*(T-W) + a*logarithm + a**2*(1/T-1/W) equal(integral - delta/(u*W), row) arm_bound = u*W*(1/a-z)*((x+h)/W**2 - 3*kappa/4) polynomial = (b*u**2*(1+x**2) - 3*kappa*b*(1+a**2)**2*v/4 - kappa*a*v*(u**2+Z) + a*u*(a*(1+y**2)+b*(1+x**2)) + a*Z*v**2) equal(a*u*v*(arm_bound-kappa*delta), polynomial) equal(delta.xreplace({a:b,b:a,x:y,y:x}), delta) print("PASS: switch measurements, stationarity, shared integral, and cleared polynomial.")