Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

possible bug in residue function

I compute the residue of a function in two ways, using the fact that it has simple poles. It seems residue method gives the wrong anser (psi) to be compared to correct answer (chi).

   br(x) = 1-x
   q1,q2,q3,m = var('q1,q2,q3,m')
   assume(q1>0,q2>0,q3>0,m>0)
   q4 = (q1*q2*q3)^-1
   k = 2
   rho = [1,q4]
   X = [var("x%d" % i) for i in range(k)]
   chi1 = prod([ br(X[j]/m)/(br(X[j])*X[j]) for j in range(k)])
   chi2 = prod([ prod([ br(q1*q2*X[i]/X[j])*br(q1*q3*X[i]/X[j])*br(q2*q3*X[i]/X[j]) for i in range(k) if i != j]) for j in range(k)])
   chi3 = prod([ prod([ br(q1*X[i]/X[j])*br(q2*X[i]/X[j])*br(q3*X[i]/X[j])*br(q4*X[i]/X[j]) for i in range(k) if i != j]) for j in range (k)])
   chi = (chi1*chi2/chi3).factor()
   psi = chi
   for xi,rhoi in zip(X,rho):
        psi = psi.residue(xi==rhoi).combine().factor()
        chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})

Now we can print chi and psi and see that they're different. Is this a bug of residue or series?