TITLE: Sum of Squares of Binomial Coefficients Using Residue Theorem
QUESTION [5 upvotes]: I ran across this interesting question recently that I have an idea for, but am unable to complete. Basically, we use the residue formula to find $$ \sum\limits_{k=0}^n {n\choose k}^2$$
We define $f$ as\begin{align*}
f(z)&= \frac{1}{z}(1+z)^n(1+\frac{1}{z})^n\\ &= \frac{1}{z}\left({n\choose 0} + {n\choose 1}z + \cdots + {n\choose n} z^n \right)\left({n\choose 0} + {n\choose 1}\frac{1}{z} + \cdots + {n\choose n} \frac{1}{z}^n \right)\\
\end{align*}
We see that the $\frac{1}{z}$ term will have the coefficient $\sum\limits_{k=0}^n {n\choose k}^2$. This would imply that $$res_{z=0} f(z) = \sum\limits_{k=0}^n{n\choose k}^2$$
Here's where things start falling apart for me. I choose to integrate $f$ over the unit disc $D$, which contains the pole $z=0$ and according to the residue theorem, I should get that $$ \int\limits_D f(z)dz = 2\pi i \sum\limits_{k=0}^n{n\choose k}^2$$
But calculating the integral, I get that \begin{align*} 
\int\limits_D f(z)dz &= \int\limits_0^{2\pi} \frac{ie^{i\theta}}{e^{i\theta}}(1+e^{i\theta})^n(1+e^{-i\theta})^nd\theta\\
&= i \int\limits_0^{2\pi} (1+e^{i\theta})^n (1+e^{-i\theta})^nd\theta
\end{align*}
However, Wolfram Alpha has that this integral goes to $0$ but we don't have that $\sum\limits_{k=0}^n {n\choose k}^2 = 0$. Would someone mind pointing out where I messed up in my proof or perhaps point me in a better direction?

REPLY [6 votes]: Note, that applying the residue theorem is extracting the coefficient of $z^{-1}$ of the Laurent-series expansion.

Using the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ in a series we obtain
  \begin{align*}
\color{blue}{\mathrm{res}_{z=0}f(z)}&=[z^{-1}]\frac{1}{z}(1+z)^n\left(1+\frac{1}{z}\right)^n\\
&=[z^{-1}]\frac{1}{z^{n+1}}(1+z)^{2n}\\
&=[z^n](1+z)^{2n}\\
&\,\,\color{blue}{=\binom{2n}{n}}
\end{align*}