Computing the integral $\int_{-\pi}^{\pi}\frac{1}{2-\cos(t)-\sin(t)}\;dt$ 
*

*Let $a, b \in \mathbb{C}$, such that $\lvert a \lvert < 1 < \lvert b \lvert$, and $\gamma(t)=e^{it}$, $t\in [0,2\pi]$. Show that $\int_\gamma \frac{1}{(z-a)(z-b)}dz=\frac{2\pi i}{a-b}$


*Using 1), compute the integral $\int_{-\pi}^{\pi}\frac{1}{2-\cos(t)-\sin(t)}dt$.
I could prove 1), but I don't see how I could approach 2). I thought about using the identities $ \sin(t)=\frac{e^{it}-e^{-it}}{2i}$ and $\cos(t)=\frac{e^{it}+e^{-it}}{2}$, but I couldn't find a way and I don't see how to use 1) for this.
 A: If$$\require{cancel}f(z)=\frac1z\frac1{2-\frac{z+1/z}2-\frac{z-1/z}{2i}},$$then you have$$f(z)=-\frac{1+i}{(z-a)(z-b)},$$with$$a=(1+i)\left(1+\frac1{\sqrt2}\right)\quad\text{and}\quad b=(1+i)\left(1-\frac1{\sqrt2}\right).$$And\begin{align}\oint_{|z|=1}f(z)\,\mathrm dz&=\int_{-\pi}^\pi\frac1{\cancel{e^{i\theta}}}\frac{1+i}{2-\frac{e^{i\theta}+e^{-i\theta}}2-\frac{e^{i\theta}-e^{-i\theta}}{2i}}i\cancel{e^{i\theta}}\,\mathrm d\theta\\&=i\int_{-\pi}^\pi\frac{1+i}{2-\cos(\theta)-\sin(\theta)}\,\mathrm d\theta.\end{align}Therefore,\begin{align}\int_{-\pi}^\pi\frac1{2-\cos(\theta)-\sin(\theta)}\,\mathrm d\theta&=\frac1{i(1+i)}\oint_{|z|=1}f(z)\,\mathrm dz\\&=-\frac1i\oint_{|z|=1}\frac{\mathrm dz}{(z-a)(z-b)}.\end{align}
A: Yes, this is a general procedure for evaluating these types of integrals. Use those identities to convert $\sin$ and $\cos$ into exponentials. Then make the substitution $z = e^{it}$ in the integral to turn it into an integral of a rational function of $z$ over $S^1$. This integral can then be evaluated using Cauchy's integral formula (i.e. method of residues).
