<s>[INST] Integrating $\int_0^{2\pi} \frac1{a\cos(t)+b\sin(t)+c}dt$ with $\sqrt{a^2+b^2}=1Let $a,b,c\in\mathbb{R}$ such that $\sqrt{a^2+b^2}=1<c$.
Find $I:=\int_{0}^{2\pi} \frac{1}{a\cos(t)+b\sin(t)+c}dt$.
So, I set $z=e^{it}$ and then $dz=ie^{it}dt$ and so $\frac{dz}{iz}=dt$. Therefore,
$\begin{align*} I & =\frac{1}{i}\int_{|z|=1} \frac{dz/z}{a\cdot\frac{z+z^{-1}}{2}+b\cdot\frac{z-z^{-1}}{2i}+c} \newline &=\frac{2}{i}\int_{|z|=1} \frac{dz}{a\cdot(z^2+1)-ib\cdot(z^2-1)+2cz} \newline &=\frac{2}{i}\int_{|z|=1} \frac{dz}{(a-ib)z^2+2cz+a+ib}\newline &= \frac{2}{i}\int_{|z|=1} \frac{dz}{(z-z_+)(z-z_-)}\end{align*}$
Where $z_{\pm}=\frac{-2c\ \pm\ \sqrt{4c^2-4(a+ib)(a-ib)}}{2(a-ib)}=\frac{-c\ \pm\ \sqrt{c^2-(a^2+b^2)}}{(a-ib)}=\frac{-c\ \pm\ \sqrt{c^2-1}}{(a-ib)}$.
Therefore, if we define $f(z)=\frac{1}{z-z_-}$, we get that $f$ is analytic in $\{z:|z|\leq 1\}$ since 
$$|z_-|=\Bigg|\frac{-c-\sqrt{c^2-1}}{a-ib}\Bigg|=\bigg|c+\sqrt{c^2-1}\bigg|>|c|>1$$
Finally from Cauchy's Integral Formula:
$$I=\frac{2}{i}\cdot 2\pi i\cdot f(z_+)=4\pi \frac{1}{z_+-z_-}=\frac{2\pi(a-ib)}{\sqrt{c^2-1}}$$
Which is not always real... So my question is what is the problem.
Moreover, sometimes it is correct, e.g. $a=1,b=0,c=2$ gives the correct answer $\frac{2\pi}{\sqrt{3}}$.
 [/INST] Note, we have
\begin{align}
\frac{a}{\sqrt{a^2+b^2}}\cos(t)+\frac{b}{\sqrt{a^2+b^2}}\sin(t) = \cos(t-\delta) 
\end{align}
where
\begin{align}
\delta=\cos^{-1}\frac{a}{\sqrt{a^2+b^2}}.
\end{align}
Hence it follows
\begin{align}
\int^{2\pi}_0 \frac{dt}{c+a\cos(t)+b\sin(t)} = \int^{2\pi}_0 \frac{dt}{c+\cos(t-\delta)} =\int^{2\pi-\delta}_{-\delta}\frac{dt}{c+\cos(t)}.
\end{align}
However, since $(c+\cos(t))^{-1}$ is $2\pi$ period, then the integral is equivalent to 
\begin{align}
\int^{2\pi}_0 \frac{dt}{c+\cos(t)} =\frac{2\pi}{\sqrt{c^2-1}}
\end{align}
where the evaluation is done with contour integral. 
</s>