back to table · edit · history · where entries came from · files · download
1134 bytes, as of the version from 2026-11-19 23:48 (current). Recorded here, not run.
"""Direct Laurent-product constant terms and exact ratio-bound controls."""
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RealField
from math import comb
import json
def mul(a,b):
out={}
for i,c in a.items():
for j,d in b.items():out[i+j]=out.get(i+j,ZZ(0))+c*d
return out
x={-2:ZZ(1),0:ZZ(2),2:ZZ(1)}
z={-2:ZZ(1),-1:ZZ(3),0:ZZ(3),1:ZZ(1)}
xn={0:ZZ(1)};zn={0:ZZ(1)};checks=[]
for n in range(1,21):
xn=mul(xn,x);zn=mul(zn,z)
ct=xn[0]**2*zn[0]
expected=ZZ(comb(2*n,n))**2*ZZ(comb(3*n,n))
assert ct==expected
ratio=QQ(6*n*(2*n+1)*(3*n+1)*(3*n+2))/QQ((n+1)**4)
assert ratio<108
assert 108*(n+1)**4-6*n*(2*n+1)*(3*n+1)*(3*n+2)==270*n**3+570*n**2+420*n+108
checks.append({'n':n,'constant_term':str(ct),'native_type':type(ct).__name__})
assert checks[0]['constant_term']=='12'
assert checks[0]['constant_term']!='24'
print('DEFINITION_RESULTS_JSON '+json.dumps({'constant_terms':checks,'known_answer_control':True,'negative_control_rejected':True,'ratio_difference_polynomial':'270*n^3+570*n^2+420*n+108, positive for n>=1'}))