Sum of Squares of Binomial Coefficients Using Residue Theorem 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?
 A: Using the reduction formula
$$\int_0^\pi\cos^{2n}\phi\,d\phi
  =\frac{2n-1}{2n}\int_0^\pi\cos^{2n-2}\phi\,d\phi\ ,$$
your sum is
$$\eqalign{S
  &=\frac1{2\pi}\int_0^{2\pi} (1+e^{i\theta})^n(1+e^{-i\theta})^n\,d\theta\cr
  &=\frac1{2\pi}\int_0^{2\pi}(2+2\cos\theta)^n\,d\theta\cr
  &=\frac1{2\pi}\int_0^{2\pi} 2^{2n}\cos^{2n}\frac\theta2\,d\theta\cr
  &=\frac1\pi\int_0^\pi2^{2n}\cos^{2n}\phi\,d\phi\cr
  &=\frac1\pi 2^{2n}\frac{2n-1}{2n}\frac{2n-3}{2n-2}\cdots\frac12\pi\cr
  &=\frac{(2n)!}{(n!)^2}\cr
  &=\binom{2n}n\ .\cr}$$
A: 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*}

A: What a cute problem! Hint: using Cauchy formula, $\int_c g(z)/ (z-a)^{n+1}= \frac{2\pi i}{n!} g^{(n)}(a)$ where $g(z)=(1+z)^{2n}$ it reduces to finding the $n$th derivative of $g$ at 0.
