Repository: sympy/sympy

Issue:
imageset(lambda x: x**2/(x**2 - 4), S.Reals) returns (1, ∞)
```
>>> f = x**2/(x**2 - 4)
>>> imageset(x, f, S.Reals)
(1, ∞)                 # this is wrong

>>> imageset(x, f, Interval(1, oo))
(-∞, -1/3] ∪ (1, ∞)                              # this is correct
```

Since `[1, ∞).is_subset(S.Reals)`

Discussion:

Patch:
diff --git a/sympy/sets/sets.py b/sympy/sets/sets.py
index 9e761ddcd8..ce747c602b 100644
--- a/sympy/sets/sets.py
+++ b/sympy/sets/sets.py
@@ -1063,8 +1063,8 @@ def _eval_imageset(self, f):
         else:
             return imageset(f, Interval(self.start, sing[0],
                                         self.left_open, True)) + \
-                Union(*[imageset(f, Interval(sing[i], sing[i + 1]), True, True)
-                        for i in range(1, len(sing) - 1)]) + \
+                Union(*[imageset(f, Interval(sing[i], sing[i + 1], True, True))
+                        for i in range(0, len(sing) - 1)]) + \
                 imageset(f, Interval(sing[-1], self.end, True, self.right_open))
 
     @property


Test patch:
diff --git a/sympy/sets/tests/test_sets.py b/sympy/sets/tests/test_sets.py
index f9a640dfb0..71f6cc8657 100644
--- a/sympy/sets/tests/test_sets.py
+++ b/sympy/sets/tests/test_sets.py
@@ -922,3 +922,10 @@ def test_issue_Symbol_inter():
         Intersection(r, FiniteSet(sin(x), cos(x)))
     assert Intersection(FiniteSet(x**2, 1, sin(x)), FiniteSet(x**2, 2, sin(x)), r) == \
         Intersection(r, FiniteSet(x**2, sin(x)))
+
+
+def test_issue_10113():
+    f = x**2/(x**2 - 4)
+    assert imageset(x, f, S.Reals) == Union(Interval(-oo, 0), Interval(1, oo, True, True))
+    assert imageset(x, f, Interval(-2, 2)) == Interval(-oo, 0)
+    assert imageset(x, f, Interval(-2, 3)) == Union(Interval(-oo, 0), Interval(S(9)/5, oo))