Repository: sympy/sympy

Issue:
Simplification bug on alternating series.
Hi!
```python
from sympy import *
n = Symbol('n', odd=true, nonzero=true)
x = (-1)**(n/2 - Rational(1,2)) - (-1)**(3*n/2 - Rational(1,2))
print( x.subs(n,1)) # 2
print( x.subs(n,3)) # -2
print( x.subs(n,5)) # 2
print(simplify(x)) # -> 2 bug
```
I think this should be considered a bug.

Discussion:

Patch:
diff --git a/sympy/simplify/powsimp.py b/sympy/simplify/powsimp.py
index c7a84ae522..66c911d211 100644
--- a/sympy/simplify/powsimp.py
+++ b/sympy/simplify/powsimp.py
@@ -242,6 +242,8 @@ def bkey(b, e=None):
                 else:
                     c, m = e.as_coeff_Mul(rational=True)
                     if c is not S.One:
+                        if m.is_integer:
+                            return (b, Integer(c.q)), m*Integer(c.p)
                         return (b**m, Integer(c.q)), Integer(c.p)
                     else:
                         return (b**e, S.One), S.One


Test patch:
diff --git a/sympy/simplify/tests/test_powsimp.py b/sympy/simplify/tests/test_powsimp.py
index 9d552fee49..8e4011c44b 100644
--- a/sympy/simplify/tests/test_powsimp.py
+++ b/sympy/simplify/tests/test_powsimp.py
@@ -1,6 +1,7 @@
 from sympy import (
     symbols, powsimp, symbols, MatrixSymbol, sqrt, pi, Mul, gamma, Function,
-    S, I, exp, simplify, sin, E, log, hyper, Symbol, Dummy, powdenest, root)
+    S, I, exp, simplify, sin, E, log, hyper, Symbol, Dummy, powdenest, root,
+    Rational)
 
 from sympy.abc import x, y, z, t, a, b, c, d, e, f, g, h, i, k
 
@@ -281,3 +282,16 @@ def test_issue_from_PR1599():
     assert (powsimp(root(n1, 3)*root(n2, 3)*root(n3, 3)*root(n4, 3)) ==
         -(-1)**(S(1)/3)*
         (-n1)**(S(1)/3)*(-n2)**(S(1)/3)*(-n3)**(S(1)/3)*(-n4)**(S(1)/3))
+
+
+def test_issue_10195():
+    a = Symbol('a', integer=True)
+    l = Symbol('l', even=True, nonzero=True)
+    n = Symbol('n', odd=True)
+    e_x = (-1)**(n/2 - Rational(1, 2)) - (-1)**(3*n/2 - Rational(1, 2))
+    assert powsimp((-1)**(l/2)) == I**l
+    assert powsimp((-1)**(n/2)) == I**n
+    assert powsimp((-1)**(3*n/2)) == -I**n
+    assert powsimp(e_x) == (-1)**(n/2 - Rational(1, 2)) + (-1)**(3*n/2 +
+            Rational(1,2))
+    assert powsimp((-1)**(3*a/2)) == (-I)**a