Status: Accepted
Owner: ----
Labels: Type-Defect Priority-High

New issue 3174 by [email protected]: sum evalf is broken
http://code.google.com/p/sympy/issues/detail?id=3174

It is my impression that evalf really needs an overhaul, especially when it comes to handling evaluation of things that need substitution. Here is a case in point:


    >>> Sum(x, (x, 1, y)).n(1,subs={y:0})
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "sympy\core\evalf.py", line 1181, in evalf
        result = evalf(self, prec+4, options)
      File "sympy\core\evalf.py", line 1089, in evalf
        r = rf(x, prec, options)
      File "sympy\core\evalf.py", line 1010, in evalf_sum
        re, im, re_acc, im_acc = evalf(s, prec2, options)
      File "sympy\core\evalf.py", line 1089, in evalf
        r = rf(x, prec, options)
      File "sympy\core\evalf.py", line 412, in evalf_add
        terms = [evalf(arg, prec + 10, options) for arg in v.args]
      File "sympy\core\evalf.py", line 1089, in evalf
        r = rf(x, prec, options)
      File "sympy\core\evalf.py", line 873, in evalf_integral
        result = do_integral(expr, workprec, options)
      File "sympy\core\evalf.py", line 798, in do_integral
        xhigh = as_mpmath(xhigh, prec+15, options)
      File "sympy\core\evalf.py", line 785, in as_mpmath
        return mpf(re)
      File "sympy\mpmath\ctx_mp_python.py", line 77, in __new__
v._mpf_ = mpf_pos(cls.mpf_convert_arg(val, prec, rounding), prec, rounding)
      File "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

There are two approaches to evaluation in evalf_sum: 1) a fast hypergeometric summation (for limit between int and oo) (this Sum fails that criteria); 2) a euler_maclaurin summation (but that fails unless the upper limit is specified).

The problem is that even if you raise an error if the limit is not literal, there is no fallback to try the subs which have been provided and the Sum will just come back unevaluated. This is also the sort of problem with trig evaluation with complex subs as detailed in comment 6 of issue 2057 ( http://code.google.com/p/sympy/issues/detail?id=2057#c6 ).

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to