Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3248 by [email protected]: summation() function --- internal error is provoked.
http://code.google.com/p/sympy/issues/detail?id=3248

sympy from git, as of 25.04.2012:

And here is one example that leads to an internal error:

In [50]: summation( (-1)**k * binomial(2*n,k)**2, (k,0,oo))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/home/kjetil/py/sympy/sympy/sympy/<ipython-input-50-ba135c6f6f06> in <module>()
----> 1 summation( (-1)**k * binomial(2*n,k)**2, (k,0,oo))

/home/kjetil/py/sympy/sympy/sympy/sympy/concrete/summations.pyc in summation(f, *symbols, **kwargs)
    307
    308     """
--> 309     return Sum(f, *symbols, **kwargs).doit(deep=False)
    310
    311 def telescopic_direct(L, R, n, limits):

/home/kjetil/py/sympy/sympy/sympy/sympy/concrete/summations.pyc in doit(self, **hints)
    139                 a, b = b, a
    140
--> 141             f = eval_sum(f, (i, a, b))
    142             if f is None:
    143                 return self

/home/kjetil/py/sympy/sympy/sympy/sympy/concrete/summations.pyc in eval_sum(f, limits)
    389     # this can save time when b-a is big.

    390     # We should try to transform to partial fractions

--> 391     value = eval_sum_symbolic(f.expand(), (i, a, b))
    392     if value is not None:
    393         return value

/home/kjetil/py/sympy/sympy/sympy/sympy/concrete/summations.pyc in eval_sum_symbolic(f, limits)
    475             return r
    476
--> 477     return eval_sum_hyper(f, (i, a, b))
    478
    479 def _eval_sum_hyper(f, i, a):

/home/kjetil/py/sympy/sympy/sympy/sympy/concrete/summations.pyc in eval_sum_hyper(f, (i, a, b))
    558
    559     # Now b == oo, a != -oo

--> 560     res = _eval_sum_hyper(f, i, a)
    561     if res is not None:
    562         return Piecewise(res, (Sum(f, (i, a, b)), True))

/home/kjetil/py/sympy/sympy/sympy/sympy/concrete/summations.pyc in _eval_sum_hyper(f, i, a)
    523     h = hyper(ap, bq, x)
    524
--> 525     return f.subs(i, 0)*hyperexpand(h), h.convergence_statement
    526
    527 def eval_sum_hyper(f, (i, a, b)):

/home/kjetil/py/sympy/sympy/sympy/sympy/simplify/hyperexpand.pyc in hyperexpand(f, allow_hyper, rewrite)
   2445         if not r.has(nan, zoo, oo, -oo):
   2446             return r
-> 2447     return f.replace(hyper, do_replace).replace(meijerg, do_meijer)
   2448
   2449 from sympy.polys.polytools import Poly

/home/kjetil/py/sympy/sympy/sympy/sympy/core/basic.pyc in replace(self, query, value, map)
   1315                     return None
   1316
-> 1317         result = rec_replace(self)
   1318
   1319         if result is None:

/home/kjetil/py/sympy/sympy/sympy/sympy/core/basic.pyc in rec_replace(expr)
   1306
   1307                 if result:
-> 1308                     value = _value(expr, result)
   1309
   1310                     if map:

/home/kjetil/py/sympy/sympy/sympy/sympy/core/basic.pyc in <lambda>(expr, result)
   1263                 _value = lambda expr, result: value(*expr.args)
   1264             elif callable(value):
-> 1265                 _value = lambda expr, result: value(*expr.args)
   1266             else:
1267 raise TypeError("given a type, replace() expects another type or a callable")

/home/kjetil/py/sympy/sympy/sympy/sympy/simplify/hyperexpand.pyc in do_replace(ap, bq, z)
   2434
   2435     def do_replace(ap, bq, z):
-> 2436         r = _hyperexpand(IndexPair(ap, bq), z, rewrite=rewrite)
   2437         if r is None:
   2438             return hyper(ap, bq, z)

/home/kjetil/py/sympy/sympy/sympy/sympy/simplify/hyperexpand.pyc in _hyperexpand(ip, z, ops0, z0, premult, prem, rewrite) 1996 if unpolarify(z) in [1, -1] and (len(nip.ap), len(nip.bq)) == (2, 1):
   1997         f = build_hypergeometric_formula(nip)
-> 1998 r = carryout_plan(f, ops).replace(hyper, hyperexpand_special)
   1999         if not r.has(hyper):
   2000             return r + p

/home/kjetil/py/sympy/sympy/sympy/sympy/core/basic.pyc in replace(self, query, value, map)
   1315                     return None
   1316
-> 1317         result = rec_replace(self)
   1318
   1319         if result is None:

/home/kjetil/py/sympy/sympy/sympy/sympy/core/basic.pyc in rec_replace(expr)
   1306
   1307                 if result:
-> 1308                     value = _value(expr, result)
   1309
   1310                     if map:

/home/kjetil/py/sympy/sympy/sympy/sympy/core/basic.pyc in <lambda>(expr, result)
   1263                 _value = lambda expr, result: value(*expr.args)
   1264             elif callable(value):
-> 1265                 _value = lambda expr, result: value(*expr.args)
   1266             else:
1267 raise TypeError("given a type, replace() expects another type or a callable")

/home/kjetil/py/sympy/sympy/sympy/sympy/simplify/hyperexpand.pyc in hyperexpand_special(ap, bq, z)
   1911             if b.is_integer and b < 0:
   1912                 return 2*cos(pi*b/2)*gamma(-b)*gamma(b - a + 1) \
-> 1913                        /gamma(-b/2)/gamma(b/2 - a + 1)
   1914             else:
   1915                 return gamma(b/2 + 1)*gamma(b - a + 1) \

NameError: global name 'pi' is not defined

--
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