Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to make Mathematica compute this sum:

Sum[(-1)^k (n - k)^2 Binomial[2 n, k], {k, 0, n}]

As is, I get an awful formula:

Sum[(-1)^k (n - k)^2 Binomial[2 n, k], {k, 0, n}] // FullSimplify

enter image description here

Using Maxima, I get the (almost correct) result 0, with nusum((-1)^k*(n-k)^2*binomial(2*n,k),k,0,n);. But for n=1, the result is 1, so Maxima is a bit too aggressive here:

enter image description here

So I try to add assumptions to Mathematica:

Sum[(-1)^k (n - k)^2 Binomial[2 n, k], {k, 0, n}, 
  Assumptions -> Element[n, Integers] && n > 1] // FullSimplify
Refine[%, Element[n, Integers] && n > 1]

enter image description here

It's much better, but there is an obvious simplification, and I don't know how to make Mathematica "see" it. An hypergeometric series with a negative integer parameter is a polynomial, and here it's especially simple. FunctionExpand does not work either.

However, we have really a Hypergeometric2F1, and if I write it explicitly, the simplification is possible:

-2 n Hypergeometric2F1[2, 1 - 2 n, 1, 1]
Refine[%, Element[n, Integers] && n > 1]

enter image description here

Is there a way to make this a bit more automatic?

share|improve this question
    
Please do not post images of code, but post code as text with markdown formatting. Those who would like to help you can't experiment with your code if they can't copy it and paste it into Mathematica. Your chances of getting help are greatly reduced when people have to retype the code in a question to work with it. –  m_goldberg May 25 at 17:32
    
@m_goldberg You are right. I added also the code, so that it's easier to copy/paste. –  Jean-Claude Arbaut May 25 at 17:39
1  
Sum[(-1)^k (n - k)^2 Binomial[2 n, k], {k, 0, n}, Assumptions -> {k, n} \[Element] Integers && n > 1]//FullSimplify gives 0 –  rasher May 26 at 2:08
    
@rasher Tanks! I thought this one was automatic! (I mean, that k is assumed to be an integer, since it's the sum index) But I realize now that there is an optional "step" parameter, and the sum index may be non-integer. It's still not very clear to me wy HypergeometricPFQ is not simplified while Hypergeometric2F1 is ;-) –  Jean-Claude Arbaut May 26 at 6:07
    
@Jean-ClaudeArbaut: Yes, it can be a bit tricky at times: Mathematica tries do keep things as general as possible, so a good rule-of-thumb is if you know an assumption holds, go ahead and tell it rather than assume MM will "know" it. –  rasher May 26 at 6:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.