"""Independent interval audit, from source equations and coefficient data only. Rebuilds residuals with exact rational polynomial arithmetic. The reference time integral is rational in x=Omega_phi (unlike the submitted exp callback). Only meromorphic callbacks enter acb.integral. All interval cell bounds are validated with Arb; no claimant executable is imported or invoked. """ import os,json,time,math,sys from fractions import Fraction from flint import arb,acb,arb_poly,fmpq,fmpq_poly,ctx ctx.prec=192 HERE=os.path.dirname(os.path.abspath(__file__)) def ball(v): f=Fraction(str(v)); return arb(fmpq(f.numerator,f.denominator)) def span(a,b): return arb(a).union(arb(b)) def upper(v): return v.abs_upper() def peval(coeff,x): z=x*0 for v in reversed(coeff): z=z*x+v return z class Rat: def __init__(self,p,q=None): p=p if isinstance(p,fmpq_poly) else fmpq_poly(p) q=fmpq_poly([1]) if q is None else q g=p.gcd(q); self.p=p//g; self.q=q//g self.pc=[arb(c) for c in self.p]; self.qc=[arb(c) for c in self.q] self.ap=arb_poly(self.p); self.aq=arb_poly(self.q) @staticmethod def make(v): return v if isinstance(v,Rat) else Rat([fmpq(v)]) def __add__(a,b): b=Rat.make(b); return Rat(a.p*b.q+b.p*a.q,a.q*b.q) __radd__=__add__ def __neg__(a): return Rat(-a.p,a.q) def __sub__(a,b): return a+-Rat.make(b) def __rsub__(a,b): return Rat.make(b)+-a def __mul__(a,b): b=Rat.make(b); return Rat(a.p*b.p,a.q*b.q) __rmul__=__mul__ def __truediv__(a,b): b=Rat.make(b); return Rat(a.p*b.q,a.q*b.p) def __rtruediv__(a,b): return Rat.make(b)/a def __pow__(a,n): return Rat(a.p**n,a.q**n) def derivative(a): return Rat(a.p.derivative()*a.q-a.p*a.q.derivative(),a.q**2) def __call__(a,x): return peval(a.pc,x)/peval(a.qc,x) def centered(a,x): # Validated polynomial composition about the dyadic midpoint avoids # dependency inflation from residual coefficient cancellation. m=x.mid(); h=x-m; shift=arb_poly([m,1]) return a.ap(shift)(h)/a.aq(shift)(h) def readrat(data): return Rat(fmpq_poly([fmpq(s) for s in data['P']]),fmpq_poly([fmpq(s) for s in data['Q']])) def integrate(fn,a,b): a=arb(a); b=arb(b) value=acb.integral(lambda z,analytic:fn(z),acb(a.mid()),acb(b.mid()),rel_tol=arb('1e-32'),abs_tol=arb('1e-35'),eval_limit=100000) assert value.is_finite() and value.imag.contains(0),(str(a),str(b),str(value)) assert value.real.rad()0 and A>0 and A0 res=upper(r1.centered(xx))**2+upper(r2.centered(xx))**2 assert res<(contraction*delta)**2,(i,str(res)) # Jacobian derived by differentiating the two rational source equations. c=(1+1/w)/(2*(1-xx)); ca=Q*A/((1-xx)*w*w) j11=ca*(B-A)-c j12=c j21=-arb(q/p)*B*B*(1+Q*A*A)/((1-xx)*w*w) j22=arb('0.5')-2*arb(q/p)*A*B/((1-xx)*w) d1=j11+contraction; d2=j22+contraction; off=(j12+j21)/2 determinant=d1*d2-off*off assert d1<0 and d2<0 and determinant>0,(i,str(determinant)) maxres=max(maxres,res.upper()); mindet=min(mindet,determinant.lower()) maxA=max(maxA,upper(A)); maxB=max(maxB,upper(B)) print('Independent tube PASS',str(p),'delta',str(delta),'res2',str(maxres),flush=True) return a,b,{'radius':str(delta),'lambda':str(contraction),'splits':splits,'residual_squared_upper':str(maxres),'symmetric_jacobian_shift_determinant_lower':str(mindet),'A_abs_upper':str(maxA)},delta def candidate(p,data,d): row=next(r for r in data['rows'] if r['degree']==d) w=readrat(row); wi=-2/(p+2); x=Rat([0,1]); integrand=(w/wi-1)/x def lr(t): assert t>0 return t.log()+integrate(integrand,arb(0),t) # Rational positive coefficients certify Q>0 and -w>0 on the positive axis. assert all(c>0 for c in w.q) and all(c<0 for c in w.p) lo=ball('1'); hi=ball('3'); target=ball('17/8').log() assert lr(lo)target for _ in range(105): mid=(lo+hi)/2; val=lr(mid) if valtarget: hi=mid else: break T0=span(lo,hi); assert T0.rad()0 nd=1/(3*W*(1-xx)) ncell=nc+arb(0,(upper(nd)*h/2).upper()) for d,(w,T0,lr) in cands.items(): tc=T0*(k*nc).exp(); logrc=lr(tc); logom=-(1+logrc.exp()).log() lc=logom-(1-xc).log() tall=T0*(k*ncell).exp(); wall=w(tall) # Propagate candidate log-density over the entire time cell. lograll=logrc+arb(0,(3*upper(wall)*upper(nd)*h/2).upper()) candx=lograll.exp()/(1+lograll.exp()) derivative=(-wall*candx/W-xx)/(1-xx) bound=upper(lc)+h*upper(derivative)/2 boundpoint=bound.upper() if boundpoint>maxima[d]: maxima[d]=boundpoint; maxys[d]=str(y) cellcount=i+1 if ncell.upper() end and n<0 wi=arb(-2/(p+2)); gamma=1-(1-wi*wi)/(4*wi*wi-2*wi+1) beta=(36*wi**4-21*wi**3+7*wi*wi-1)/((4*wi*wi-2*wi+1)*(12*wi*wi-3*wi+1)) Tp=xmax/(1-gamma*xmax); T=Tp*(k*n).exp() Rpub=ball('17/8')*(k*n).exp()*(((gamma-1)/beta)*((1+beta*Tp)/(1+beta*T)).log()).exp() w1=Rat([fmpq(-2/(p+2)),fmpq(0)]) # [1/1] exact numerator/denominator from the independently rederived T series. from referee import series,pade from fractions import Fraction P1,Q1=pade(series(Fraction(str(p)))['w'],1) fake={'rows':[{'degree':1,'P':list(map(str,P1)),'Q':list(map(str,Q1))}]} wc,Tc,lrc=candidate(p,fake,1) Rc=lrc(Tc*(k*n).exp()).exp() ratios={'published_11':Rpub,'normalization_only_11':Rc,'wCDM':ball('17/8')*(-3*wi*n).exp(),'LambdaCDM':ball('17/8')*(3*n).exp()} out['controls_at_true_Omega_2over5']={} for name,R in ratios.items(): ratio=1/((1+R)*(1-x)); ome=abs(ratio-1); ee=abs(1/ratio.sqrt()-1) assert ome>maxima[6].exp()-1 and ee>(maxima[6]/2).exp()-1 out['controls_at_true_Omega_2over5'][name]={'Omega_m_error_interval':str(ome),'E_error_interval':str(ee)} out['status']='PASS'; out['elapsed_s']=time.time()-start json.dump(out,open(HERE+'/interval_'+ps.replace('/','_')+'.json','w'),indent=2) print(json.dumps(out,indent=2),flush=True) if __name__=='__main__': for p in (sys.argv[1:] or ['1','1/10']): audit(p)