Help understanding this integration result I am learning Complex Integration and i have come across this result i need some helo understanding.
The book, in a solution, states that
$$=\frac{1}{2\pi a^2}\int_0^{2\pi}e^{-(n-1)i\theta}[1+\frac {e^{2i\theta}}{a^2}+\frac {e^{4i\theta}}{a^4}+\cdot \cdot \cdot]d\theta$$
$$=0 \text { if n is even}$$
and if $n$ is odd
$$=\frac{1}{2\pi a^2}\int_0^{2\pi}e^{-(n-1)i\theta} \frac {e^{(n-1)i\theta}}{a^{n-1}}d\theta$$
I do not understand these two results. I know that $$\int_0^{2\pi}e^{mi\theta}d\theta=0\forall m\ne0$$
 A: When $n$ is even, $n = 2m$, then we have
$$e^{-(n-1)i\theta}\cdot e^{2ki\theta} = e^{(2k-2m+1)i\theta},$$
and $2k-2m+1\neq 0$, so the integral over every term of the sum vanishes. For odd $n$, $n-1$ is even, and there is one term in the sum where the exponential terms multiply to the constant $1$, and the integral over that term does not vanish.
A: Another approach: the series only converges if $|a|\gt1$.
Let $z=e^{i\theta}$,
$$
\begin{align}
\frac1{2\pi a^2}\int_0^{2\pi}\frac{e^{-(n-1)i\theta}}{1-\frac1{a^2}e^{2i\theta}}\,\mathrm{d}\theta
&=\frac1{2\pi i}\int_0^{2\pi}\frac{e^{-ni\theta}}{a^2-e^{2i\theta}}\,\mathrm{d}e^{i\theta}\\
&=\frac1{2\pi i}\int_\gamma\frac{z^{-n}}{a^2-z^2}\,\mathrm{d}z\\
\end{align}
$$
where $\gamma$ is a counterclockwise unit circle. Since $|a|\gt1$, the only singularity inside the unit circle is at $z=0$ and
$$
\begin{align}
\operatorname*{Res}_{z=0}\left(\frac{z^{-n}}{a^2-z^2}\right)
&=\frac1{2a^2}\operatorname*{Res}_{z=0}\left(\frac{z^{-n}}{1-\frac za}+\frac{z^{-n}}{1+\frac za}\right)\\
&=\frac1{2a^2}\left(\frac1{a^{n-1}}+\frac{(-1)^{n-1}}{a^{n-1}}\right)\\
&=\frac1{a^{n+1}}\frac{1-(-1)^n}2
\end{align}
$$
Therefore,
$$
\frac1{2\pi a^2}\int_0^{2\pi}\frac{e^{-(n-1)i\theta}}{1-\frac1{a^2}e^{2i\theta}}\,\mathrm{d}\theta=\frac1{a^{n+1}}\frac{1-(-1)^n}2
$$
which agrees with the answer given.
