On Tue, Apr 24, 2012 at 5:36 PM, Tom Bachmann <e_mc...@web.de> wrote: > On 25.04.2012 00:20, Aaron Meurer wrote: >> >> On Tue, Apr 24, 2012 at 5:16 PM, Tom Bachmann<e_mc...@web.de> wrote: >>>> >>>> I agree. Can you open an issue for this in our issue tracker >>>> (http://code.google.com/p/sympy/issues/list)? >>>> >>>> We can do hypergeometric series, which is why the summation() function >>>> is so powerful in the git master, but I think it's not recognizing >>>> this one as such because it's a finite sum (Tom, please correct me if >>>> I'm wrong). If you use the fact that binomial(n, k) == 0 for k> n, >>>> and replace n with oo in the summation limits, you get: >>>> >>> >>> I was about to say precisely that. >> >> >> So any thoughts on how to fix it. I guess we should try to recognize >> if the summand is zero for all but finitely many values. And then do >> some manipulation on the indices. >> > > Hm. I'm not really sure. I think that this example work by evaluating an > infinite sum is a bit of a curiosity. I think for finite sums, in general, a > different algorithm is needed (we have gosper_sum, but that apparently does > not apply here). I'm afraid I'm not very knowledgeable on this subject.
Well, I guess we can start by just doing it for binomial coefficients. I think binomial(n, k) is defined to be 0 for k > n for just this reason. This technique also lets us compute summation(binomial(n, k)**2, (k, 0, n)) (with some minor issues, see http://code.google.com/p/sympy/issues/detail?id=3242). By the way, Wikipedia says that summation(binomial(n, j), (j, 0, k)) can be computed in terms of hypergeometric functions. I guess it's because it's just In [170]: summation(binomial(n, j), (j, 0, oo)) - summation(binomial(n, j), (j, k + 1, oo)) Out[170]: n ⎛ n ⎞ ┌─ ⎛1, k - n + 1 │ ⅈ⋅π⎞ 2 - ⎜ ⎟⋅ ├─ ⎜ │ ℯ ⎟ ⎝k + 1⎠ 2╵ 1 ⎝ k + 2 │ ⎠ Maybe this would be a more appropriate way to structure the algorithm (because then we don't even care if terms are 0 or not). Aaron Meurer > > >> By the way, I just noticed: >> >> In [156]: summation( binomial(n,k), (k,n - 1, oo)) >> Out[156]: >> ⅈ⋅π >> n - ℯ >> >> That exp_polar() should probably be evaluated in the result. >> > > Yeah I'll submit a pull request for that tomorrow. > >> Aaron Meurer >> > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sympy@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.