Repository: sympy/sympy

Issue:
Incorrect definite integral of exp(abs(x - 2))
```
from sympy import *
x, a, b = symbols('x a b', positive=True)
integrate(exp(abs(x - 2)), (x, a, b))
```
results in `-exp(a - 2) + exp(b - 2)` which is wrong: this is what the integral of `exp(x - 2)` would be. A concrete demonstration: 
```
>>> integrate(exp(abs(x-2)), (x, a, b)).subs({a: 1, b: 3})
-exp(-1) + E
>>> integrate(exp(abs(x-2)), (x, 1, 3))
-2 + 2*E
```
The second result, with explicit bounds of integration, is the correct one.

Based on Stack Overflow post [Symbolic definite integral expression does not yield the same result as numerical evaluation](https://stackoverflow.com/q/53162005)

Discussion:

Patch:
diff --git a/sympy/integrals/integrals.py b/sympy/integrals/integrals.py
index 99a558164b..9efaa71e1c 100644
--- a/sympy/integrals/integrals.py
+++ b/sympy/integrals/integrals.py
@@ -458,7 +458,7 @@ def doit(self, **hints):
 
             if function.has(Abs, sign) and (
                 (len(xab) < 3 and all(x.is_real for x in xab)) or
-                (len(xab) == 3 and all(x.is_real and x.is_finite for
+                (len(xab) == 3 and all(x.is_real and not x.is_infinite for
                  x in xab[1:]))):
                     # some improper integrals are better off with Abs
                     xr = Dummy("xr", real=True)


Test patch:
diff --git a/sympy/integrals/tests/test_integrals.py b/sympy/integrals/tests/test_integrals.py
index f6cc733fb7..c2fb5664ce 100644
--- a/sympy/integrals/tests/test_integrals.py
+++ b/sympy/integrals/tests/test_integrals.py
@@ -1425,3 +1425,13 @@ def test_issue_15292():
 
 def test_issue_4514():
     assert integrate(sin(2*x)/sin(x), x) == 2*sin(x)
+
+
+def test_issue_15457():
+    x, a, b = symbols('x a b', real=True)
+    definite = integrate(exp(Abs(x-2)), (x, a, b))
+    indefinite = integrate(exp(Abs(x-2)), x)
+    assert definite.subs({a: 1, b: 3}) == -2 + 2*E
+    assert indefinite.subs(x, 3) - indefinite.subs(x, 1) == -2 + 2*E
+    assert definite.subs({a: -3, b: -1}) == -exp(3) + exp(5)
+    assert indefinite.subs(x, -1) - indefinite.subs(x, -3) == -exp(3) + exp(5)