<s>[INST] $\int_0^{2\pi}\frac{1}{a\cos \theta+b\sin\theta+d}d\theta$ where $a,b,d\in\mathbb{R}$ and $a^2+b^2$\int_0^{2\pi}\frac{1}{a\cos \theta+b\sin\theta+d}d\theta$ where $a,b,d\in\mathbb{R}$ and $a^2+b^2<d^2$
Here, I solve it by Residue Theory. By substituting $d\theta=dz/iz,\cos \theta=(1/2)(z+1/z),\sin\theta=(1/2i)(z-1/z),$ I get
$$\frac{2}{i}\int_{C^+_1(0)}\frac{1}{(a-ib)z^2+2dz+(a+ib)}dz$$
So there are two singularities which are
$$z=\frac{-d\pm\surd{d^2-a^2-b^2}}{a-ib}$$
In order to use the Cauchy's Residue Theorem, I have to identify the singularities that lie inside the unit circle. But, if I take $d=3,a=2,b=2$
$$|\frac{-d-\surd{d^2-a^2-b^2}}{a-ib}|=\frac{4}{2\surd2}>1$$
While if I take $d=-3,a=2,b=2$
$$|\frac{-d-\surd{d^2-a^2-b^2}}{a-ib}|=\frac{2}{2\surd2}<1$$
So I can't sure that this term will be in the unit circle or not. Or should I assume that $d>0$?
 [/INST] $I
=\int\frac{1}{a\cos \theta+b\sin\theta+d}d\theta
$
Letting
$\tan(\theta/2)
=t
$,
$d\theta
=\frac{2dt}{1+t^2}
$,
$\sin \theta
=\frac{2t}{1+t^2}
$,
and
$\cos \theta
=\frac{1-t^2}{1+t^2}
$.
Therefore
$\begin{array}\\
I
&=\int\frac{1}{a\cos \theta+b\sin\theta+d}d\theta\\
&=\int\frac{1}{a\frac{1-t^2}{1+t^2}+b\frac{2t}{1+t^2}+d}\frac{2dt}{1+t^2}\\
&=2\int\frac{1}{a(1-t^2)+b(2t)+d(1+t^2)}dt\\
&=2\int\frac{1}{a+d+2bt+(d-a)t^2}dt\\
&=2\left( -\frac{\tan^{-1}\left(\frac{(t (a-d)-b)}{\sqrt{-a^2-b^2+d^2}}\right)}{\sqrt{-a^2-b^2+d^2}}\right)
\qquad\text{(according to Wolfram)}\\
\end{array}
$
</s>