I need help with this problem:
Use the integration in the complex plane to calculate the integral $$\int_0^{2\pi}\cos^n\theta\,d\theta$$ I thought to make $z= e^{i\theta}$ and rewrite the integral like this $$\oint_{C_1}\left (\dfrac{e^{i\theta}+e^{-i\theta}}{2}\right )^n\dfrac{dz}{iz}=\dfrac{1}{i2^n}\oint_{C_1}\dfrac{(z+z^{-1})^n}{z}dz$$ Then with the integral in this form $$\oint_{C_1}\dfrac{(z+z^{-1})^n}{(z-0)}dz$$ apply the cauchy integral formula, but isn't possible because the function $(z+z^{-1})^n$ is not defined in $0$.
What can I do?
Since the function has a singularity at $z=0$ we just have to find the residue at $z=0$:
$$I = \frac{1}{i}\oint_{C_1}\dfrac{(\frac{z^2+1}{2z})^n}{z}dz = \frac{1}{i} \oint_{C_1}\dfrac{(z^2+1)^n}{2^nz^{n+1}}dz = 2\pi \operatorname{Res}(f,0)$$
where
$$f(z) = \dfrac{(z^2+1)^n}{2^nz^{n+1}}$$
Expand with the binomial theorem $(z^2+1)^n$:
$$(z^2+1) = \sum_{j=0}^{n}\binom{n}{j} z^{2j}$$
Hence
$$ I= \frac{1}{i}\oint_{C_1}\sum_{j=0}^{n}\binom{n}{j} \dfrac{z^{2j}}{2^nz^{n+1}}dz = \frac{1}{i}\oint_{C_1}\sum_{j=0}^{n}\binom{n}{j}\frac{1}{2^n}z^{2j-n-1} dz $$
The residue is the coefficient of $\displaystyle z^{-1}=z^{2j-n-1}$
Hence $$ 2j-n-1=-1 \Longrightarrow j = \frac{n}{2}$$
If $n=2m+1, \; m\in \mathbb{N} $ then since $j$ is an integer, the residue is zero and $I=0$
if $n=2m, \; m\in \mathbb{N} $ then $j= m$ and the residue is
$$\operatorname{Res}(f,0)= \binom{n}{m}\frac{1}{2^{m}}$$
Hence $$ \int_0^{2\pi}\cos^n\theta\,d\theta = \begin{cases} 0 &\textrm{ if } n=2m+1\;\; m\in \mathbb{N} \\ \displaystyle \frac{\pi}{2^{m-1}} \binom{n}{m} &\textrm{ if } n=2m \;\; m\in\mathbb{N} \end{cases}$$