Opened 7 months ago

# Possible bug in residue and series

Reported by: Owned by: gh-dkwo major sage-9.2 symbolics residue, series, factor N/A

### Description

We are interested in computing the (iterated) residue of a function. First, we can use the fact that the pole is always simple to multiply and take the limit.

```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()
for xi,rhoi in zip(X,rho):
#    chi = chi.residue(xi==rhoi).combine().factor()
chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})
chi.factor()
```

This gives the correct result. If we instead employ the residue method

```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()
for xi,rhoi in zip(X,rho):
chi = chi.residue(xi==rhoi).combine().factor()
#    chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})
chi
```

it is wrong. I believe this is a bug in residue that comes from series.

As a side note, if we replace

```br(x) = 1-x
```

with

```br(x) = sqrt(x)-1/sqrt(x)
```

then the first method is still the only correct one, but it does not factorize all square roots to the simplest form.

### comment:1 Changed 4 months ago by mkoeppe

• Milestone changed from sage-9.1 to sage-9.2

Moving tickets to milestone sage-9.2 based on a review of last modification date, branch status, and severity.

Note: See TracTickets for help on using tickets.