Repository: sympy/sympy

Issue:
Incorrect residue of `x**2*cot(pi*x)/(x**4 + 1)`
```
x = Symbol('x')
residue(x**2*cot(pi*x)/(x**4 + 1), x, -sqrt(2)/2 - sqrt(2)*I/2)
```
~Gives `AttributeError: 'int' object has no attribute 'removeO'`~
Now it gives wrong result

Discussion:

Patch:
diff --git a/sympy/core/mul.py b/sympy/core/mul.py
index 5fb540a627..db84a3a62e 100644
--- a/sympy/core/mul.py
+++ b/sympy/core/mul.py
@@ -1904,7 +1904,7 @@ def coeff_exp(term, x):
                 res += Order(x**n, x)
             return res
 
-        res = 0
+        res = S.Zero
         ords2 = [Add.make_args(factor) for factor in facs]
 
         for fac in product(*ords2):


Test patch:
diff --git a/sympy/series/tests/test_residues.py b/sympy/series/tests/test_residues.py
index e3b3f38e08..0a599f6a3e 100644
--- a/sympy/series/tests/test_residues.py
+++ b/sympy/series/tests/test_residues.py
@@ -1,5 +1,5 @@
 from sympy import (residue, Symbol, Function, sin, I, exp, log, pi,
-                   factorial, sqrt, Rational)
+                   factorial, sqrt, Rational, cot)
 from sympy.testing.pytest import XFAIL, raises
 from sympy.abc import x, z, a, s
 
@@ -75,3 +75,7 @@ def test_issue_6499():
 
 def test_issue_14037():
     assert residue(sin(x**50)/x**51, x, 0) == 1
+
+
+def test_issue_21176():
+    assert residue(x**2*cot(pi*x)/(x**4 + 1), x, -sqrt(2)/2 - sqrt(2)*I/2) == 0