TITLE: $\sum_{k=0}^n (-1)^k \binom{n}{k}^2$ and $\sum_{k=0}^n k \binom{n}{k}^2$
QUESTION [6 upvotes]: I can calculate $\sum_{i=0}^k \binom{n}{i}\binom{m}{k-i}$ using $(1+x)^{n+m} = (1+x)^n(1+x)^m$.
I would like to calculate the two sums $\sum_{k=0}^n (-1)^k \binom{n}{k}^2$  and $\sum_{k=0}^n k \binom{n}{k}^2$  with the same method.
I don't see what polynomial I have to consider.
For the first one, if i consider $(1-x)^n(1+x)^n=\sum_{k=0}^n \sum_{i=0}^{k}(-1)^i \binom{n}{i} \binom{n}{k-i} x^k$ and the sum we want doesn't appear.
EDIT : indeed, I only have to look at the coefficient of $x^n$, which is $\binom{n}{i}\binom{n}{n-i} = \binom{n}{i}^2$.

REPLY [2 votes]: Using the Lemma from this answer, we get
$$
\begin{align}
\sum_{k=0}^nk\binom{n}{k}^2
&=\sum_{k=0}^n\binom{k}{1}\binom{n}{k}^2\\
&=\binom{n}{1}\binom{2n-1}{n}\\
&=\bbox[5px,border:2px solid #C00000]{n\binom{2n-1}{n}}\\
&\text{or}\\
&=\binom{2n-1}{1}\binom{2n-2}{n-1}\\
&=\bbox[5px,border:2px solid #C00000]{(2n-1)\binom{2n-2}{n-1}}\tag{1}
\end{align}
$$

To get the alternating sum, consider the product
$$
\begin{align}
(1+x)^n(1-x)^n
&=\left(\sum_{i=0}^n\binom{n}{i}x^i\right)\left(\sum_{j=0}^n\binom{n}{j}(-1)^jx^j\right)\\
&=\sum_{k=0}^{2n}\sum_{j=0}^k(-1)^jx^k\binom{n}{j}\binom{n}{k-j}\tag{2}
\end{align}
$$
Note that the coefficient of $x^n$ in $(2)$ is
$$
\sum_{j=0}^n(-1)^j\binom{n}{j}\binom{n}{n-j}=\sum_{j=0}^n(-1)^j\binom{n}{j}^2\tag{3}
$$
Another way to write the left hand side of $(2)$ is $(1-x^2)^n$. If $n$ is odd, there is no $x^n$ term in $(1-x^2)^n$ since it is an even function. If $n$ is even, the coefficient of $x^n$ is $(-1)^{n/2}\binom{n}{n/2}$. Therefore,
$$
\bbox[5px,border:2px solid #C00000]{
\sum_{j=0}^n(-1)^j\binom{n}{j}^2=\left\{\begin{array}{}
\displaystyle0&\text{if $n$ is odd}\\
\displaystyle(-1)^{n/2}\binom{n}{n/2}&\text{if $n$ is even}
\end{array}\right.}\tag{4}
$$