"""Outward interval certificate for the common ramped Chen selector on log N >= 1500.""" from math import gcd from mpmath import iv iv.dps = 35 I = iv.mpf L, a = I(1500), I(".49") beta, eta, b = map(I, ('.09', '.334', '.44')) ramp_power, ramp_width, sigma = I(5), I('.4'), I(2)/3 half, half_loss = I('.5'), I('.5') - a M, peak, kappa = I('.05'), I('.088889'), I('1.0002') Vconst, hard, density, rho = I('.738'), I('2.7'), I(8)/33, I(17)/361 z, y = beta*L, eta*L count = 0 for n in range(1,331): count += int(gcd(n,330) == 1) assert 33*count-8*n <= 66 assert count == 80 assert iv.exp(y) >= 2*iv.exp(z)-1 def enclose_integral(function, left, right, cells=12000): step = (right-left)/cells total = I(0) for j in range(cells): start = left + j*step end = left + (j+1)*step total += function(I([start.a, end.b])) return step*total def discrepancy(v): return (2*iv.exp(-v/2) + I('.0000098'))/v + iv.exp(-v) def theta_relative(v): return v**2*iv.exp(-v/2)/(8*iv.pi) theta_f = a/kappa s = theta_f/beta etap = eta + ramp_width/L C = 2*iv.exp(iv.euler) f = C/s*(iv.ln(s-1) + enclose_integral( lambda t: iv.ln(t-1)/t*iv.ln((s-1)/(t+1)), I(2), s-2)) mark = C*beta/theta_f*(iv.ln(eta*(theta_f-beta)/(beta*(theta_f-eta))) + enclose_integral(lambda t: iv.ln(t-1)/t*iv.ln((s-t-1)*(s-1)/(t+1)), I(2), s-2)) last_F = C*beta/(theta_f-etap) mean_log_threshold = 1/ramp_power-ramp_width/(iv.exp(ramp_power*ramp_width)-1) mark += last_F*(mean_log_threshold/(eta*L) + 2*(discrepancy(z)+1/(iv.exp(z)-1))) main_A = f - mark/2 K = 1-beta-2*eta J = lambda u: iv.ln((1-u-eta)/eta)/(1-u) mass = enclose_integral(lambda u: J(u)/u,beta,1-2*eta) dq, dr = discrepancy(z), discrepancy(y) Hq = iv.ln((1-2*eta)/beta)+dq Hr = iv.ln((1-beta-eta)/eta)+dr mass += 2*dq+6*dr+50*theta_relative(y) qfactor = (1+1/(iv.exp(z)-2))**(1+1/beta) main_B = iv.exp(iv.euler)*beta*kappa/(b-4/L)*iv.exp(dq)*qfactor*mass # Smoothed primitive source on the hard wheel, and one union of distinct soft moduli. E_A = hard*beta/(M*Vconst)*L*(I('.101419')*(iv.ln(165)+a*L)+I('.082'))*( density*rho*iv.exp(-half_loss*L)+2*iv.exp(-L/2)) # A single ramped prime-tail bound y^(-d)*(5+.02 log(1+|t|/2)) for all soft m. d = sigma-half B = iv.sqrt(d*(d+ramp_power)) s0 = half+B c = ramp_power/(2*B) h = ramp_width ramp = (1+iv.exp(-(ramp_power+d)*h))/(1-iv.exp(-ramp_power*h)) U = 1/(s0-1)+2*(s0-1)/(iv.exp(1)*s0) zero_offset = c*(iv.ln((s0+1)/(2*iv.pi))+1/(3*s0**2)+2*U) # Prime powers: k=2, then 3<=k<=ceil(log y'/log2), then k larger. kpp = 4*iv.ln(4)+2*iv.ln(4)*((y+h)/iv.ln(2)+1)*iv.exp(-y/6) kpp += iv.ln(2)*(1+2/(sigma*y/iv.ln(2)-1))/(1-2**(-sigma))*iv.exp(-y/2) triv = (ramp_power/(sigma*(sigma+ramp_power))+half*iv.ln(1+ramp_power/sigma))*iv.exp(-y/2) assert s0>1 and kpp+triv<6 and zero_offset<16 assert ramp*(c*(b+iv.ln(165)/L)+(I(16)+I(6))/L)/eta<5 assert ramp*c/y ramp_width + iv.ln(1/rho) and beta*L< a*L + iv.ln(rho) assert eta> I(1)/3 and etap2/L margin=main_A-main_B-E_A-E_B-E_finite for name in ('f','mark','main_A','mass','main_B','E_A','E_B','E_finite','margin','J2'): print(name,globals()[name]) assert margin>I('.01')