Ask Your Question

sage_user's profile - activity

2021-10-27 15:10:58 +0200 received badge  Famous Question (source)
2016-02-15 11:14:01 +0200 received badge  Notable Question (source)
2015-06-04 17:51:01 +0200 received badge  Popular Question (source)
2014-01-20 10:10:51 +0200 received badge  Student (source)
2014-01-19 06:33:02 +0200 commented question Numeric evaluation of exp(x^2) in a sum TypeError

Interestingly, calling n on the symbolic answer works: sage: n(sum(e^(i^2), i, -1, 1)) 6.43656365691809

2014-01-19 06:29:40 +0200 asked a question 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?