"""Exact endpoint certificates; floating point only locates rational trials.""" from fractions import Fraction as F from math import ceil, exp, factorial, log from pathlib import Path import json from checks import parameters ELOW=F(163,60) EUP=sum((F(1,factorial(j)) for j in range(21)),F(0))+F(1,20*factorial(20)) def stationary(B,m,r,a): _,D,L,_,_=parameters(B,r) def fun(x):return m*D*log(1+2*L/x)-a*log(1+2/(x+2*r)) low,high=1e-100,1. while fun(high)>0:high*=2 for _ in range(180): mid=(low+high)/2 if fun(mid)>0:low=mid else:high=mid return high def certificate(B,m,r,a,u): _,D,L,K,_=parameters(B,r) assert a%2==0 and a>m*D*L f=((u+2*L)/u)**(m*D)*((u+2*r)/(u+2*r+2))**a U=(EUP**(2*(a+m-1))*K**(2*m)*(u+2*L)**(2*m*D*L) *2**(2*a)*(F(2*r)**(2*r)/F(2*r+2)**(2*r+2))**a) assert f<1 and U<1 return {'B':B,'m':m,'r':r,'a':a,'first_even_index':m+1, 'last_even_index':a+m-1,'u':str(u),'f_lt_1':True,'U_lt_1':True, 'f_approx':exp(log(f.numerator)-log(f.denominator)), 'U_approx':exp(log(U.numerator)-log(U.denominator))} def exp_bounds(x,N=80): assert 0<=x1 exclusions.append({'r':r,'profile_at_zero_for_a_18m_already_too_large':True}) # r>=9 is excluded by the degree condition a>m(2r+1)>=19m. e0=F(68,25) assert F(1001,50)19m, so cannot improve a<=18m.', 'optimization_scope':'Same factorial denominator normalization and absolute-value exponential profile; integer zero-range r. No global obstruction for other constructions is asserted.'} Path(__file__).with_suffix('.json').write_text(json.dumps(record,indent=2)+'\n') if __name__=='__main__':main()