Repository: sympy/sympy

Issue:
evalf and subs on polynomial give wrong result when cast to float
I'm trying to use `evalf` to evaluate polynomials as `float64` numbers without intermediate loss of precision.
I came across this unexpected behavior, which seems related to #7867 and #6974. I'm using sympy 1.1.1 from the anaconda distribution:

```
x, y = sympy.symbols("x y")
e = 5*x*y/2 - y*(35*(x**3)/2 - 15*x/2)

subst = {x:0.0, y:0.0}

e1 = e.subs(subst).evalf()
print e1, float(e1)

e2 = e.evalf(subs=subst)
print e2, float(e2)
```
with the following results:

```
0 0.0
0.e+0 2.0
```
So `float(e2)` evaluates to 2.0 instead of 0.0 and silently produces a wrong result.
This was very surprising to me; am I missing something about `evalf` and `subs` semantics and precision management?

Discussion:

Patch:
diff --git a/sympy/core/evalf.py b/sympy/core/evalf.py
index 33c01e7d60..fa54a0e79a 100644
--- a/sympy/core/evalf.py
+++ b/sympy/core/evalf.py
@@ -441,7 +441,7 @@ def add_terms(terms, prec, target_prec):
     XXX explain why this is needed and why one can't just loop using mpf_add
     """
 
-    terms = [t for t in terms if not iszero(t)]
+    terms = [t for t in terms if not iszero(t[0])]
     if not terms:
         return None, None
     elif len(terms) == 1:


Test patch:
diff --git a/sympy/core/tests/test_evalf.py b/sympy/core/tests/test_evalf.py
index 1945945705..cabdc659ad 100644
--- a/sympy/core/tests/test_evalf.py
+++ b/sympy/core/tests/test_evalf.py
@@ -527,3 +527,11 @@ def test_issue_13098():
     assert ceiling(log(S('9.'+'9'*20), 10)) == 1
     assert floor(log(20 - S('9.'+'9'*20), 10)) == 1
     assert ceiling(log(20 - S('9.'+'9'*20), 10)) == 2
+
+
+def test_issue_14601():
+    e = 5*x*y/2 - y*(35*(x**3)/2 - 15*x/2)
+    subst = {x:0.0, y:0.0}
+    e2 = e.evalf(subs=subst)
+    assert float(e2) == 0.0
+    assert float((x + x*(x**2 + x)).evalf(subs={x: 0.0})) == 0.0