TITLE: Evaluate a sum with binomial coefficients: $\sum_{k=0}^{n} (-1)^k k \binom{n}{k}^2$
QUESTION [6 upvotes]: $$\text{Find} \ \ \sum_{k=0}^{n} (-1)^k k \binom{n}{k}^2$$
I expanded the binomial coefficients within the sum and got $$\binom{n}{0}^2 + \binom{n}{1}^2 + \binom{n}{2}^2 + \dots + \binom{n}{n}^2$$
What does this equal to? I think this can help me evaluate the original sum.

REPLY [3 votes]: This can also be done using a basic complex variables technique.
Start as in @robjohn's answer. Suppose we seek to evaluate
$$\sum_{k=0}^n (-1)^k k {n\choose k}^2
= \sum_{k=1}^n {n\choose k} (-1)^k k {n\choose k}
\\= \sum_{k=1}^n {n\choose k} (-1)^k k \frac{n}{k} {n-1\choose k-1}
= n \sum_{k=1}^n {n\choose k} (-1)^k  {n-1\choose k-1}.$$
Introduce the integral representation
$${n-1\choose k-1}
= \frac{1}{2\pi i} 
\int_{|z|=\epsilon} \frac{1}{z^k} (1+z)^{n-1} \; dz.$$
This gives the following integral for the sum
$$\frac{n}{2\pi i} 
\int_{|z|=\epsilon} 
\sum_{k=1}^n {n\choose k} (-1)^k \frac{1}{z^k} (1+z)^{n-1} \; dz
\\= \frac{n}{2\pi i} 
\int_{|z|=\epsilon} (1+z)^{n-1} 
\sum_{k=1}^n {n\choose k} (-1)^k \frac{1}{z^k} \; dz
\\= \frac{n}{2\pi i} 
\int_{|z|=\epsilon} (1+z)^{n-1} 
\left(-1 + \left(1-\frac{1}{z}\right)^n \right) \; dz$$
We may drop  the $-1$ because it participates in a product that is
entire.  This leaves
$$\frac{n}{2\pi i} 
\int_{|z|=\epsilon} (1+z)^{n-1} \frac{(z-1)^n}{z^n} \; dz
\\ = \frac{(-1)^n n}{2\pi i} 
\int_{|z|=\epsilon} (1-z) (1+z)^{n-1} \frac{(1-z)^{n-1}}{z^n} \; dz
\\ = \frac{(-1)^n n}{2\pi i} 
\int_{|z|=\epsilon} (1-z) \frac{(1-z^2)^{n-1}}{z^n} \; dz.$$
It follows that the value of the sum is given by
$$(-1)^n n [z^{n-1}] (1-z) (1-z^2)^{n-1}.$$
For $n$ even  the $z$ from $1-z$ participates and for  $n$ odd the one
participates.

We have for $n$ even the result
$$(-1)^n n \times (-1) (-1)^{(n-2)/2} {n-1\choose (n-2)/2}
= n \times (-1)^{n/2} {n-1\choose n/2-1}
\\= n \times (-1)^{n/2} {n-1\choose n/2}$$
and for $n$ odd
$$(-1)^n n \times (-1)^{(n-1)/2} {n-1\choose (n-1)/2}
= n \times (-1)^{(n+1)/2} {n-1\choose (n-1)/2}.$$
Joining these two terms we obtain
$$n \times (-1)^{\lceil n/2 \rceil} {n-1\choose \lfloor n/2 \rfloor}.$$
A trace as to when this method appeared on MSE and by whom starts at this
MSE link.