# Computing a sum

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 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: 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] 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] Is there a way to make this a bit more automatic?

• 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 '14 at 17:32
• @m_goldberg You are right. I added also the code, so that it's easier to copy/paste. – user10957 May 25 '14 at 17:39
• Sum[(-1)^k (n - k)^2 Binomial[2 n, k], {k, 0, n}, Assumptions -> {k, n} \[Element] Integers && n > 1]//FullSimplify gives 0 – ciao May 26 '14 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 ;-) – user10957 May 26 '14 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. – ciao May 26 '14 at 6:15