Repository: sympy/sympy

Issue:
nsimplify(Integral(x, (x, 0.0, 1.0))) gives TypeError: cannot create mpf from None
See https://github.com/sympy/sympy/issues/2884#issuecomment-38794481

```pytb
nsimplify(Integral(x, (x, 0.0, 1.0)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/simplify/simplify.py", line 3861, in nsimplify
    exprval = expr.evalf(prec, chop=True)
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/core/evalf.py", line 1284, in evalf
    result = evalf(self, prec + 4, options)
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/core/evalf.py", line 1184, in evalf
    r = rf(x, prec, options)
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/core/evalf.py", line 959, in evalf_integral
    result = do_integral(expr, workprec, options)
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/core/evalf.py", line 875, in do_integral
    xlow = as_mpmath(xlow, prec + 15, options)
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/core/evalf.py", line 862, in as_mpmath
    return mpf(re)
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/mpmath/ctx_mp_python.py", line 77, in __new__
    v._mpf_ = mpf_pos(cls.mpf_convert_arg(val, prec, rounding), prec, rounding)
  File "/mn/anatu/cma-u3/tmac/usr/lib/python2.6/site-packages/sympy/mpmath/ctx_mp_python.py", line 96, in mpf_convert_arg
    raise TypeError("cannot create mpf from " + repr(x))
TypeError: cannot create mpf from None
```


Discussion:

Patch:
diff --git a/sympy/core/evalf.py b/sympy/core/evalf.py
index d628fc20a7..8d9f470307 100644
--- a/sympy/core/evalf.py
+++ b/sympy/core/evalf.py
@@ -853,7 +853,7 @@ def evalf_bernoulli(expr, prec, options):
 
 def as_mpmath(x, prec, options):
     x = sympify(x)
-    if isinstance(x, C.Zero):
+    if isinstance(x, C.Zero) or x == 0:
         return mpf(0)
     if isinstance(x, C.Infinity):
         return mpf('inf')


Test patch:
diff --git a/sympy/core/tests/test_evalf.py b/sympy/core/tests/test_evalf.py
index 2d54ba1c4f..e93316af8b 100644
--- a/sympy/core/tests/test_evalf.py
+++ b/sympy/core/tests/test_evalf.py
@@ -3,7 +3,7 @@
                    integrate, log, Mul, N, oo, pi, Pow, product, Product,
                    Rational, S, Sum, sin, sqrt, sstr, sympify, Symbol)
 from sympy.core.evalf import (complex_accuracy, PrecisionExhausted,
-    scaled_zero, get_integer_part)
+    scaled_zero, get_integer_part, as_mpmath)
 from sympy.core.compatibility import long
 from mpmath import inf, ninf
 from sympy.abc import n, x, y
@@ -226,6 +226,9 @@ def test_evalf_bugs():
     assert (5+E**(oo)).n() == S.Infinity
     assert (5-E**(oo)).n() == S.NegativeInfinity
 
+    #issue 7416
+    assert as_mpmath(0.0, 10, {'chop': True}) == 0
+
 
 def test_evalf_integer_parts():
     a = floor(log(8)/log(2) - exp(-1000), evaluate=False)