Numeric evaluation of exp(x^2) in a sum TypeError
Define simple function of one variable with sum:
sage: r, i = var('r i')
sage: h(r) = sum(exp(i), i, -r, r)
sage: n(h(1))
4.08616126963049
OK, now change the argument of exponent to i^2:
sage: h(r) = sum(exp(i^2), i, -r, r)
sage: n(h(1))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-128-85150c4c79b2> in <module>()
----> 1 n(h(Integer(1)))
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/misc/functional.pyc in numerical_approx(x, prec, digits)
1395 prec = int((digits+1) * LOG_TEN_TWO_PLUS_EPSILON) + 1
1396 try:
-> 1397 return x._numerical_approx(prec)
1398 except AttributeError:
1399 from sage.rings.complex_double import is_ComplexDoubleElement
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:22617)()
TypeError: cannot evaluate symbolic expression numerically
Why is that and what am I doing wrong?
Interestingly, calling n on the symbolic answer works: sage: n(sum(e^(i^2), i, -1, 1)) 6.43656365691809