Evaluating $\int _0^{2\pi} (a\,\cos\,x+b\,\sin x)^m\,dx$ using the residue theorem I'm trying to evaulate the following integral, using complex functions:
$$\int_0^{2\pi} (a\,\cos x+b\,\sin x)^m\,dx , \; m\in \Bbb Z$$
The hint I was given is to use a curve of the form $\{ |z|=1\}$ and the function: $$R\biggl(\frac{1}{2}\Bigl(z+ \frac{1}{z}\Bigr),\frac{1}{2i}\Bigl(z-\frac{1}{z}\Bigr)\biggr)$$
(here $R(x,y)$ denotes a rational function of $x,y$).
I tried to subtitute $z=\cos(t)+i\,\sin(t)$, and to use the residue theorem, but I had a hard time calculating the residue. Any ideas how to continue?
Edit:
My calculations: after plugging $z=\cos(t)+i\,\sin(t)$, I got:
$$\frac{1}{i}\int_{|z|=1}\bigg(\frac{a}{2}\bigg(z+\frac{1}{z}\bigg)+\frac{b}{2i}\bigg(z-\frac{1}{z}\bigg)\bigg)^m\frac{dz}{z} =\dots=\int_{|z|=1}\frac{(z^2(a-ib)+a+ib)^m}{2^m \cdot iz^{m+1}}dz$$
I got a pole of order $m+1$, and I got stuck calculating the residue.
 A: Assuming $m\geq 0$, otherwise the integral is divergent (verify this!). Set $z=e^{ix}$ so that $dz = iz\,dx$, hence your integral is (after some fine massaging):
\begin{align}
\int_{|z|=1}\frac{(\alpha z^2+\beta)^m}{iz^{m+1}}\,dz
\end{align}
Where $\alpha=\frac{a}{2}-i\frac{b}{2}$ and $\beta=\overline{\alpha}$. Use Binomial theorem to get:
\begin{align}
\int_{|z|=1}\frac{(\alpha z^2+\beta)^m}{iz^{m+1}}\,dz=\int_{|z|=1}\frac{1}{iz^{m+1}}\sum_{k=0}^m\binom{m}{k}\alpha^kz^{2k}\beta^{m-k}\,dz
\end{align}
You can easily see that the only residue is at zero. That thing does have a power equal to $-1$ only when $2k-m-1=-1$. Only possible when $m$ is even and the that is when $k=m/2$. You can conclude that when $m$ is odd the integral is zero. So assume $m$ is even. We get by the residue theorem:
\begin{align}
\int^{2\pi}_0 \left(a\cos(x)+b\sin(x)\right)^m \,dx=\int_{|z|=1}\frac{(\alpha z^2+\beta)^m}{iz^{m+1}}\,dz=2\pi  \binom{m}{m/2}\alpha^{m/2}\beta^{m/2}
\end{align}
The only thing that is left is to translate this back. Just put $\alpha$ and $\beta$ in terms of $a$ and $b$. And notice that the integral is real because $\alpha\beta=|\alpha|^2$.

Edit To see why the integral is divergent if $m\in\mathbb{Z}^-$. Assume furthermore that at least $a$ or $b$ is nonzero, otherwise how you define $0^m$?. First set $n=-m$. Let us consider only one part of the integral namely:
\begin{align}
J=\int^{\pi}_0 \left( a\cos(x)+b\sin(x)\right)^m\,dx
\end{align}
Substitute $x=2\arctan(t)$ to get rid of the sines and cosines then you can verify that we get:
\begin{align}
J&=\int^\infty_0 \left( a\frac{1-t^2}{1+t^2}+b\frac{2t}{1+t^2}\right)^m\frac{2\,dt}{1+t^2}\\
&=\int^\infty_0 \left( \frac{a-at^2+2bt}{1+t^2}\right)^m\frac{2\,dt}{1+t^2}\\
&\stackrel{n=-m}{=}\int^\infty_0 \frac{2(1+t^2)^{n-1}}{(a-at^2+2bt)^n}\,dt
\end{align}
Now it is easy to see that the integral is divergent. It suffices to show that $a-at^2+2bt=0$ for some $t\in[0,\infty)$. 
A: Let
$$I=\int_0^{2\pi} (a\,\cos x+b\,\sin x)^m\,dx$$ then by defining $cos\theta_0={{a}\over{\sqrt{a^2+b^2}}}$ and $sin\theta_0={{b}\over{\sqrt{a^2+b^2}}}$ we have:
$$I=(\sqrt{a^2+b^2})^m\int_{0}^{2\pi}\cos^m(x-\theta_0)dx=(\sqrt{a^2+b^2})^m\int_{0}^{2\pi}\cos^mxdx$$
with substituting $z=e^{i\theta}$ and $dz=izd\theta$ we get:
$$I=({\sqrt{a^2+b^2}\over 2})^m\int_C{1\over {iz}}(z+{1\over z})^mdz=({\sqrt{a^2+b^2}\over 2})^m{1\over {i}}\int_C{{(z^2+1)^m}\over z^{m+1}}dz=$$
where $C$ is unit circle. First let m to be nonnegative. Then the residue of $\Large {{(z^2+1)^m}\over z^{m+1}}$ in $z=0$ is factor of $1\over z$ in Laurent expansion which is $\binom{m}{m\over 2}$ when $m$ is even and $0$ when it's odd. Therefore the integral becomes $\Large2\pi({\sqrt{a^2+b^2}\over 2})^m\binom{m}{m\over 2}$ at this case.
Now let $m<0$. We deduce that there are two non single poles on unit circle and therefore complex integration theory can't be applied easily and directly. At this case you need to choose an alternative way.
