TITLE: Finding the intregral $\int_{0}^{2\pi} (\cos x)^{2n}\,\mathrm dx$ by contour integration
QUESTION [5 upvotes]: How do I find $$\int_{0}^{2\pi} (\cos x)^{2n}\,\mathrm dx$$ using contour integration ? Should I turn it into an integral around the unit circle? Or should I integrate some other function with real part $(\cos x)^{2n}$. Not sure where to start, please help.

REPLY [6 votes]: [Too long for a comment]
After the change of variables $z=e^{ix}$, you will have something like 
\begin{align}
I=2^{-2n}\oint_C\left(z+\frac1z\right)^{2n}\frac{dz}{iz}&=2^{-2n}\sum_{k=0}^{2n}\oint_C{2n \choose k} \cdot z^k\cdot z^{-(2n-k)}\,\frac{dz}{iz}=\\
&=\frac{2^{-2n}}{i}\sum_{k=0}^{2n}{2n \choose k}\oint_Cz^{2(k-n)-1}dz=\\
&=2\pi\cdot 2^{-2n}\sum_{k=0}^{2n}{2n \choose k}\mathrm{res}_{z=0} z^{2(k-n)-1},
\end{align}
where $C$ denotes the unit circle oriented counterclockwise and $\displaystyle{n \choose k}=\frac{n!}{k!(n-k)!}$ is the binomial coefficient. Now the residue is non-zero only for $2k-2n-1=-1$, i.e. for $k=n$, in which case it is equal to $1$. Therefore out of the sum of $2n+1$ terms only one term (with $k=n$) will remain and the answer will be
$$I=2\pi\cdot 2^{-2n}\cdot {2n \choose n}=\frac{(2n)!\,\pi}{2^{2n-1}(n!)^2}.$$