<s>[INST] How to integrate $f(x) = \frac{1}{a + b \cos x + c \sin x }$ over $x \in (0,\pi/2)$ 
Conjecture 1
    $$ \begin{align*} I_{T}=\int_0^{2\pi} \frac{\mathrm{d}x}{a + b \cos x + c
 \sin x} & = \frac{2\pi}{\rho} \tag{1} \\ I_{T/4} = \int_0^{\pi/2} \frac{\mathrm{d}x}{a +
 b \cos x + c \sin x} & =  \frac{2}{\rho} \arctan \left(\frac{\rho}{a+b+c}\right)\tag{2}
 \end{align*} $$
  Where $\rho^2 = a^2-b^2 -c^2$.



*

*Is this result correct, and does it cover all cases? 

*Does the result above cover all cases - what if the denominator becomes a perfect square? 

*When does the integral converge?



I am mainly posting this so that i can close all the duplicates in
   the future. Integrals related to these seems to pop up regularly. 
 [/INST] First we need a lemma or two.

Lemma 1:
  $ \hspace{3.75cm} \displaystyle
  \int \frac{\,\mathrm{d}x}{1+x^2} = \arctan x+\mathcal{C}
$

Proof: Use the substitution $x \mapsto \tan u$. Then we have 
$$
  \mathrm{d}x
= \left( \frac{\sin u}{\cos u} \right)'\mathrm{d}u
= \frac{(\sin u)' \cdot \cos u - \sin u \cdot (\cos u)'}{\cos^2u}\mathrm{d}u
= (1+\tan^2u)\,\mathrm{d}u
$$
Which means that $\mathrm{d}u = \cfrac{\mathrm{d}x}{1+(\tan u)^2} = \cfrac{\mathrm{d}x}{1+x^2}$. Hence
$$
\int \frac{\,\mathrm{d}x}{1+x^2}
= \int \mathrm{d}u
= u + \mathcal{C}
= \arctan x + \mathcal{C}
$$
Since $u \mapsto \tan x$, this means $x = \arctan u$. $\square$ 

Lemma 2:
   Assume that $t \in [0,\infty]$ and $\lambda \in \mathbb{R}\backslash\{0\}$. Then 
  $$
  \int_0^t \frac{\mathrm{d}x}{\lambda^2+x^2} = \frac 1\lambda \arctan \frac t \lambda
$$

Proof: Using Lemma 1 this can be done quickly. Use $x \mapsto \lambda v$. Then $\mathrm{d}x = \lambda \mathrm{d}v$, and so
$$
\int_0^t \frac{\mathrm{d}x}{\lambda^2+x^2}
= \int_0^{t/\lambda} \frac{\lambda \mathrm{d}v}{\lambda^2(1+v^2)}
= \frac{1}{\lambda} \int_0^{t/\lambda} \frac{\mathrm{d}v}{1+v^2}
= \frac 1\lambda \arctan \frac{t}{\lambda}
$$

Corollary 1:
   Assume that $\lambda \in \mathbb{R}\backslash\{0\}$. We have 
  $$
  \int_0^1 \frac{\,\mathrm{d}x}{\lambda^2+x^2} = \frac 1\lambda \arctan \frac 1\lambda \ \ \text{and}  \ \ \int_{-\infty}^\infty  \frac{\mathrm{d}x}{\lambda^2+x^2} = \frac{\pi}{\lambda}
$$

Proof: The first equation follows directly from setting $t=1$ in Lemma 1. For the next equation note that $\int_{-t}^t \frac{\mathrm{d}x}{1+x
 2} = 2 \int_0^t \frac{\mathrm{d}x}{1+x^2}$. Now the rest follows directly since $\arctan t \to \pi/2$ as $t \to \infty$. Proving $\int_{-t}^0 \frac{\mathrm{d}x}{1+x^2} = \int_{-t}^0 \frac{\mathrm{d}x}{1+x^2}$ I will leave as an excercise for the reader. $\square$.
Now for the last part of the proof, we need the following proposition.

Proposition 1 (Weierstrass substitution):
  Assume $a,b \in[-\pi,\pi]$. Then we have
  $$
   \int_a^b          R(\sin x,\cos x,\tan x)\,\mathrm{d}x
 = \int_\varphi^\psi R \left( \frac{2t}{1+t^2} , \frac{1 - t^2}{1+t^2},\frac{2t}{1-t^2}\right) \frac{2 \mathrm{d}t}{1+t^2}
$$
  where $\varphi = \tan(a/2)$ and $\psi = \tan(b/2)$.

The proof for this is omitted but can be proven by using $x \mapsto \tan u/2$. It is not hard but requires some work. For a lengthier discussion see Wikipedia.
Now we can finally start our proof. 
Using the above proposition one has
$$
\int \frac{\mathrm{d}x}{a + b \cos x + c \sin x}
= \int \frac{1}{a + b \frac{1-t^2}{1+t^2} + c \frac{2t}{1+t^2}} \frac{\mathrm{d}t}{1+t^2}
= \int \frac{2\,\mathrm{d}t}{(a-b)t^2+2ct+a+b}
$$
Now we can complete the square. This gives
$$
\int \frac{\mathrm{d}x}{a + b \cos x + c \sin x}
= \frac{1}{a-b} \int \frac{\mathrm{d}t}{\left(t+\frac{c}{a-b}\right)^2+\frac{a+b}{a-b}-\frac{c^2}{(a-b)^2}}
$$
Alas not much more can be done before inserting the limits. The simplest case is the $I_T$ case. Here we have
$$
\begin{align*}
I_T & = \int_0^{2\pi} \frac{\mathrm{d}x}{a + b \cos x + c \sin x} \\
& = \frac{1}{a-b} \int_{-\infty}^\infty \frac{\mathrm{d}t}{\left(t+\frac{c}{a-b}\right)^2+\frac{a+b}{a-b}-\frac{c^2}{(a-b)^2}} \\
& = \frac{2}{a-b}\int_{-\infty}^\infty \frac{\mathrm{d}y}{y^2+\frac{a^2-b^2-c^2}{a-b}}
\end{align*}
$$
where we used the obvious substitution $y \mapsto t + c/(a-b)$. Using Corollary 1 we have
$$
I_T = \frac{2}{a-b} \pi \Big/\left( \frac{a^2-b^2-c^2}{a-b} \right)
    = \frac{2\pi}{\lambda}
$$
where $\lambda^2 = a^2-b^2-c^2$ was used in the last equation.
</s>