On Tue, Apr 24, 2012 at 5:07 PM, Kjetil brinchmann Halvorsen
<kjetil1...@gmail.com> wrote:
> I found the usefull summation function, which seems to work well
> (examples from todays version from git)
>
> In [30]: summation(1/k**2,(k,1,oo))
> Out[30]:
>  2
> π
> ──
> 6
>
> In [31]: summation( (-1)**k * binomial(n,k), (k,0,n))
> Out[31]: 0
>
> But:
>
> In [32]: summation( binomial(n,k), (k,0,n))
> Out[32]:
>   n
>  ____
>  ╲
>   ╲   ⎛n⎞
>    ╲  ⎜ ⎟
>    ╱  ⎝k⎠
>   ╱
>  ╱
>  ‾‾‾‾
> k = 0
>
> Which should be possible to do!
> (I think sage can do that one)
>
> Kjetil
>
> --
> "If you want a picture of the future - imagine a boot stamping on the human
> face - forever."
>
> George Orwell (1984)

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:

In [150]: summation( binomial(n,k), (k,0,oo))
Out[150]:
⎧    n
⎪   2       for (-n ≥ 0 ∧ -n < 1) ∨ -n < 0
⎪
⎪  ∞
⎪ ____
⎪ ╲
⎨  ╲   ⎛n⎞
⎪   ╲  ⎜ ⎟
⎪   ╱  ⎝k⎠            otherwise
⎪  ╱
⎪ ╱
⎪ ‾‾‾‾
⎩k = 0

And if you assume that n is positive (n = Symbol('n', integer=True,
positive=True)), then the piecewise will evaluate to just 2**n.

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.

Reply via email to