Repository: sympy/sympy

Issue:
exp(I*pi/4) is not evaluated
`>>> exp(I*pi/2)`
`I`

`>>> exp(I*pi/4)`
`exp(I*pi/4)`

`>>> Sum((exp(pi*I/2)/2)**n, (n, 0, oo)).doit()`
`4/5 + 2*I/5`

`>>> Sum((exp(pi*I/4)/2)**n, (n, 0, oo)).doit()`
`Sum((exp(I*pi/4)/2)**n, (n, 0, oo))`

Discussion:

Patch:
diff --git a/sympy/functions/elementary/exponential.py b/sympy/functions/elementary/exponential.py
index a5eafc29fd..3d4c07ab25 100644
--- a/sympy/functions/elementary/exponential.py
+++ b/sympy/functions/elementary/exponential.py
@@ -456,6 +456,15 @@ def _eval_rewrite_as_tanh(self, arg):
         from sympy import tanh
         return (1 + tanh(arg/2))/(1 - tanh(arg/2))
 
+    def _eval_rewrite_as_sqrt(self, arg):
+        from sympy.functions.elementary.trigonometric import sin, cos
+        if arg.is_Mul:
+            coeff = arg.coeff(S.Pi*S.ImaginaryUnit)
+            if coeff and coeff.is_number:
+                cosine, sine = cos(S.Pi*coeff), sin(S.Pi*coeff)
+                if not isinstance(cosine, cos) and not isinstance (sine, sin):
+                    return cosine + S.ImaginaryUnit*sine
+
 
 class log(Function):
     r"""


Test patch:
diff --git a/sympy/functions/elementary/tests/test_exponential.py b/sympy/functions/elementary/tests/test_exponential.py
index a2a2e04e6d..d677b7c2d7 100644
--- a/sympy/functions/elementary/tests/test_exponential.py
+++ b/sympy/functions/elementary/tests/test_exponential.py
@@ -107,12 +107,21 @@ def test_exp_conjugate():
 
 
 def test_exp_rewrite():
+    from sympy.concrete.summations import Sum
     assert exp(x).rewrite(sin) == sinh(x) + cosh(x)
     assert exp(x*I).rewrite(cos) == cos(x) + I*sin(x)
     assert exp(1).rewrite(cos) == sinh(1) + cosh(1)
     assert exp(1).rewrite(sin) == sinh(1) + cosh(1)
     assert exp(1).rewrite(sin) == sinh(1) + cosh(1)
     assert exp(x).rewrite(tanh) == (1 + tanh(x/2))/(1 - tanh(x/2))
+    assert exp(pi*I/4).rewrite(sqrt) == sqrt(2)/2 + sqrt(2)*I/2
+    assert exp(pi*I/3).rewrite(sqrt) == 1/2 + sqrt(3)*I/2
+
+    n = Symbol('n', integer=True)
+
+    assert Sum((exp(pi*I/2)/2)**n, (n, 0, oo)).rewrite(sqrt).doit() == 4/5 + 2*I/5
+    assert Sum((exp(pi*I/4)/2)**n, (n, 0, oo)).rewrite(sqrt).doit() == 1/(1 - sqrt(2)*(1 + I)/4)
+    assert Sum((exp(pi*I/3)/2)**n, (n, 0, oo)).rewrite(sqrt).doit() == 1/(3/4 - sqrt(3)*I/4)
 
 
 def test_exp_leading_term():