Repository: sympy/sympy

Issue:
Bug in solve maybe
With python 3.4.2, Sympy 1.0:

```
mike@quaking:~/solver/client/app$ pip3 list | grep -i sympy
sympy (1.0)
mike@quaking:~/solver/client/app$ python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
```

If I run the following script

```
import sympy
import math
x, y = sympy.symbols('x y')
e1 = x - y**3 + 4
e2 =  x + y + 4 + 4 * sympy.E
e3 =  x + y + 4 + 4 * math.e
print ("with sympy.E:", sympy.solve([e1, e2], x, y))
print ("with math.e :", sympy.solve([e1, e3], x, y))
```

then I get:

```
mike@quaking:~/solver/client/app$ python3 /tmp/s.py 
with sympy.E: []
with math.e : [(-12.8079458780453, -2.06518143579091), (-15.9057180317317 - 2.04908046988193*I, 1.03259071789545 + 2.04908046988193*I), (-15.9057180317317 + 2.04908046988193*I, 1.03259071789545 - 2.04908046988193*I)]
```

Granted sympy.E and math.e are not the same thing, its odd that in the former case sympy says there are no solutions, and in the second that there are three (which looks plausible since there is a cube term.

Regards
Mike


Discussion:

Patch:
diff --git a/sympy/polys/constructor.py b/sympy/polys/constructor.py
index 409e0c2b8f..635201e096 100644
--- a/sympy/polys/constructor.py
+++ b/sympy/polys/constructor.py
@@ -122,7 +122,7 @@ def _construct_composite(coeffs, opt):
         return None
 
     if opt.composite is None:
-        if any(gen.is_number for gen in gens):
+        if any(gen.is_number and gen.is_algebraic for gen in gens):
             return None # generators are number-like so lets better use EX
 
         all_symbols = set([])


Test patch:
diff --git a/sympy/polys/tests/test_constructor.py b/sympy/polys/tests/test_constructor.py
index 5238ec52af..eb9f76ff23 100644
--- a/sympy/polys/tests/test_constructor.py
+++ b/sympy/polys/tests/test_constructor.py
@@ -4,7 +4,7 @@
 from sympy.polys.domains import ZZ, QQ, RR, EX
 from sympy.polys.domains.realfield import RealField
 
-from sympy import S, sqrt, sin, Float
+from sympy import S, sqrt, sin, Float, E, GoldenRatio, pi, Catalan
 from sympy.abc import x, y
 
 def test_construct_domain():
@@ -121,3 +121,18 @@ def test_precision():
     result = construct_domain([f2])
     y = result[1][0]
     assert y-1 > 1e-50
+
+def test_issue_11538():
+    dom = ZZ[E]
+    assert construct_domain(E)[0] == ZZ[E]
+    dom = ZZ[x,E]
+    assert construct_domain(x**2 + 2*x + E) == \
+           (dom,dom.convert(x**2 + 2*x + E))
+    dom = ZZ[pi]
+    assert construct_domain(pi) == (dom,dom.convert(pi))
+    dom = ZZ[y,pi]
+    assert construct_domain(y**2 + pi) == \
+           (dom,dom.convert(y**2 + pi))
+    dom = EX
+    assert construct_domain(x + y + GoldenRatio) == \
+           (dom,dom.convert(x + y + GoldenRatio))
diff --git a/sympy/solvers/tests/test_solvers.py b/sympy/solvers/tests/test_solvers.py
index 69f52433c2..500af4c76d 100644
--- a/sympy/solvers/tests/test_solvers.py
+++ b/sympy/solvers/tests/test_solvers.py
@@ -4,7 +4,8 @@
     Wild, acos, asin, atan, atanh, cos, cosh, diff, erf, erfinv, erfc,
     erfcinv, exp, im, log, pi, re, sec, sin,
     sinh, solve, solve_linear, sqrt, sstr, symbols, sympify, tan, tanh,
-    root, simplify, atan2, arg, Mul, SparseMatrix, ask, Tuple, nsolve, oo)
+    root, simplify, atan2, arg, Mul, SparseMatrix, ask, Tuple, nsolve, oo,
+    E, cbrt)
 
 from sympy.core.compatibility import range
 from sympy.core.function import nfloat
@@ -1792,3 +1793,17 @@ def test_issue_2840_8155():
 
 def test_issue_9567():
     assert solve(1 + 1/(x - 1)) == [0]
+
+def test_issue_11538():
+    assert solve(x + E) == [-E]
+    assert solve(x**2 + E) == [-I*sqrt(E),I*sqrt(E)]
+    assert solve(x**3 + 2*E) == [
+        -cbrt(2 * E),
+        cbrt(2)*cbrt(E)/2 - cbrt(2)*sqrt(3)*I*cbrt(E)/2,
+        cbrt(2)*cbrt(E)/2 + cbrt(2)*sqrt(3)*I*cbrt(E)/2]
+    assert solve([x + 4,y + E],x,y) == {x:-4,y:-E}
+    assert solve([x**2 + 4,y + E],x,y) == [(-2*I,-E),(2*I,-E)]
+
+    e1 = x - y**3 + 4
+    e2 = x + y + 4 + 4 * E
+    assert len(solve([e1,e2],x,y)) == 3
diff --git a/sympy/solvers/tests/test_solveset.py b/sympy/solvers/tests/test_solveset.py
index bef464f63f..9b0ebfa580 100644
--- a/sympy/solvers/tests/test_solveset.py
+++ b/sympy/solvers/tests/test_solveset.py
@@ -697,7 +697,7 @@ def test_solveset_complex_exp():
 def test_solve_complex_log():
     assert solveset_complex(log(x), x) == FiniteSet(1)
     assert solveset_complex(1 - log(a + 4*x**2), x) == \
-        FiniteSet(-sqrt(-a/4 + E/4), sqrt(-a/4 + E/4))
+        FiniteSet(-sqrt(-a + E)/2, sqrt(-a + E)/2)
 
 
 def test_solve_complex_sqrt():