1 | initial version |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = {}
def br(x):
r = 1-1/x
for t,s in mysubs.items():
if r.subs({t:s})==0: # assume that this happens only in denominators
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew2():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='degrevlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
global mysubs
mysubs = dict( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(mysubs)
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx)
chi = chinum / chiden
return chi.factor()
2 | No.2 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = {}
def br(x):
r = 1-1/x
for t,s in mysubs.items():
if r.subs({t:s})==0: # assume that this happens only in denominators
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew2():
measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='degrevlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
global mysubs
mysubs = dict( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(mysubs)
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx)
dx
chi = chinum / chiden
return chi.factor()
3 | No.3 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = {}
def br(x):
r = 1-1/x
for t,s in mysubs.items():
if r.subs({t:s})==0: # assume that this happens only in denominators
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='degrevlex')
order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
global mysubs
mysubs = dict( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(mysubs)
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
return chi.factor()
4 | No.4 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = {}
def br(x):
r = 1-1/x
for t,s in mysubs.items():
mysubs:
if r.subs({t:s})==0: # assume that this happens only in denominators
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
order='degrevlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
global mysubs
mysubs = dict( list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(mysubs)
).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
return chi.factor()
5 | No.5 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = {}
def br(x):
r = 1-1/x
for t,s in mysubs:
if r.subs({t:s})==0: # assume that this happens only in denominators
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='degrevlex')
order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
return chi.factor()
6 | No.6 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = {}
def br(x):
r = 1-1/x
for t,s in mysubs:
if r.subs({t:s})==0: # assume that this happens only in denominators
the denominator of chi
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
return chi.factor()
7 | No.7 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = {}
[]
def br(x):
r = 1-1/x
for t,s in mysubs:
if r.subs({t:s})==0: # assume that this happens only in the denominator of chi
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
rho.reverse()
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
return chi.factor()
8 | No.8 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = []
poles = set()
def br(x):
r = 1-1/x
for t,s in mysubs:
if r.subs({t:s})==0: # assume that this happens only in the denominator of chi
assert t not in poles # to make sure each pole is processed only ones
poles.add(t)
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
rho.reverse()
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
return chi.factor()
9 | No.9 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = []
poles = set()
def br(x):
r = 1-1/x
for t,s in mysubs:
if r.subs({t:s})==0: # assume that this happens only in the denominator of chi
assert t not in poles # to make sure each pole is processed only ones
poles.add(t)
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
rho.reverse()
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
assert poles == set(X) # checking that there was one pole for each variable X[i]
return chi.factor()
10 | No.10 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = []
poles = set()
def br(x):
r = 1-1/x
for t,s in mysubs:
if r.subs({t:s})==0: # assume that this happens only in the denominator of chi
assert t not in poles # to make sure each pole is processed only ones
once
poles.add(t)
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
rho.reverse()
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
assert poles == set(X) # checking that there was one pole for each variable X[i]
return chi.factor()
11 | No.11 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = []
poles = set()
def br(x):
r = 1-1/x
for t,s in mysubs:
if r.subs({t:s})==0: # assume that this happens only in the denominator of chi
assert t not in poles # to make sure each pole is processed only once
poles.add(t)
while r.subs({t:s})==0:
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
rho.reverse()
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum / chiden
assert poles == set(X) # checking that there was one pole for each variable X[i]
return chi.factor()
12 | No.12 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = []
def br(x):
r = 1-1/x
for t,s in mysubs:
while r.subs({t:s})==0:
r = r.derivative(t)
r = r.subs({t:s})
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
F = R.fraction_field()
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
rho.reverse()
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = chinum F(chinum) / chiden
F(chiden)
return chi.factor()
13 | No.13 Revision |
You can try to perform substitution and cancellation of simple poles directly in your br
function, which significantly speed up things:
mysubs = []
def br(x):
r = 1-1/x
for t,s in mysubs:
m = 0
while r.subs({t:s})==0:
r = r.derivative(t)
m += 1
r = r.subs({t:s})
r.subs({t:s}) / factorial(m)
return r
def measNew():
k = 3
R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex')
F = R.fraction_field()
R.inject_variables()
K = 1 + q2 + q2^2 + q3 + q4
X = R.gens()[:k]
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
rho.reverse()
global mysubs
mysubs = list( zip(X,rho) )
chix = prod( br(X[j]) for j in range(k) )
chim = prod( br(X[j]/m) for j in range(k) )
chiup = prod( prod( br(q1*q2*X[i]/X[j]) * br(q1*q3*X[i]/X[j]) * br(q2*q3*X[i]/X[j]) * (br(X[i]/X[j]))^2 for i in range(j+1,k) ) for j in range(k) )
chiups = prod( prod( br(X[i]/(X[j]*q1*q2)) * br(X[i]/(X[j]*q1*q3)) * br(X[i]/(X[j]*q2*q3)) for i in range(j+1,k) ) for j in range(k))
chido = prod( prod( br(q1*X[i]/X[j]) * br(q2*X[i]/X[j]) * br(q3*X[i]/X[j]) * br(q1*q2*q3*X[i]/X[j]) for i in range(j+1,k) ) for j in range (k))
chidos = prod( prod( br(X[i]/(X[j]*q1)) * br(X[i]/(X[j]*q2)) * br(X[i]/(X[j]*q3)) * br(X[i]/(X[j]*q1*q2*q3)) for i in range(j+1,k) ) for j in range (k) )
dx = prod( X[j] for j in range(k) ).subs(dict(mysubs))
chinum = chim * chiup * chiups
chiden = chix * chido * chidos * dx
chi = F(chinum) / F(chiden)
return chi.factor()