"""Interval certificate for the contour exponent in the accompanying note. Requires mpmath; all inputs are exact rationals enclosed by iv arithmetic. The composite midpoint error bound is proved in the note. """ from mpmath import iv iv.dps = 40 q = lambda n,d=1: iv.mpf(n)/d R=q(107,100); a=q(71,10**6); b=q(377,500) alpha=q(3,40); lam=q(37,40) m=(a+b)/2; ell=(b-a)/2 x=(R+m)/ell; G=iv.ln(x+iv.sqrt(x*x-1)); r=iv.exp(-G) assert r.b < q(1,6).a assert ell.b < q(38,100).a and a.a > q(1,125**2).b and b.b < 1 # Uniform derivative bounds used in the paper. assert (iv.sqrt(ell/2)).b < q(44,100).a assert (4*iv.pi*q(44,100)).b < 6 assert ((2+12/alpha)*q(44,100)**2+4*iv.pi*q(95,2)).b < 630 v0=-2+12*alpha*(1-iv.ln(alpha)) assert v0.a>0 and (v0+4*iv.pi).b < 16 assert (630*q(36,25)+12*q(7,10)+16*q(14,10)).b < 1000 def V(t): y=iv.sqrt(t) def J(c): return c*iv.ln(t+c*c)-2*c+2*y*iv.atan2(c,y) return 2*iv.pi*y+J(1)-6*J(alpha) def Jminus(c): y=iv.sqrt(R) return c*iv.ln(R-c*c)-2*c+y*iv.ln((y+c)/(y-c)) M=16384 H=q(0) for j in range(M): cos=iv.cos(iv.pi*q(2*j+1,2*M)) P=(1-r*r)/(1+2*r*cos+r*r) H+=V(m+ell*cos)*P/M err=1000*iv.pi**2/(24*M*M) base=6*Jminus(alpha)-Jminus(1)+2*lam*G upper=base+H+err rho=q(7469585,10**6) assert upper.b < rho.a mu=rho*lam/(q(138500086,10**8)-q(1288003,10**6)) assert mu.b < q(712322,10000).a print('r =',r) print('midpoint exponent =',base+H) print('midpoint error bound =',err) print('upper bound =',upper) print('mu bound =',mu) # Exact rational transfer using Kadlec's reported decay estimate. from fractions import Fraction new_mu = Fraction(37,40)*Fraction(7469585,10**6)/(Fraction(13854176085,10**10)-Fraction(1288003,10**6)) assert new_mu == Fraction(13818732250,194829217) assert new_mu < Fraction(709275,10000) print('combined bound (conditional on cited decay) =',new_mu,float(new_mu))