Primitive of Reciprocal of p by Sine of a x plus q by Cosine of a x plus r

Theorem

 * $\ds \int \frac {\d x} {p \sin a x + q \cos a x + r} = \begin{cases}

\ds \frac 2 {a \sqrt {r^2 - p^2 - q^2} } \map \arctan {\frac {p + \paren {r - q} \tan \dfrac {a x} 2} {\sqrt {r^2 - p^2 - q^2} } } + C & : p^2 + q^2 < r^2 \\ \ds \frac 1 {a \sqrt {p^2 + q^2 - r^2} } \ln \size {\frac {p - \sqrt {p^2 + q^2 - r^2} + \paren {r - q} \tan \dfrac {a x} 2} {p + \sqrt {p^2 + q^2 - r^2} + \paren {r - q} \tan \dfrac {a x} 2} } + C & : p^2 + q^2 > r^2 \end{cases}$

Proof
Let $u = \tan \dfrac {a x} 2$.

Then we have:

Hence:

There are $2$ cases: $r^2 > p^2 + q^2$ and $r^2 < p^2 + q^2$.

First suppose $r^2 > p^2 + q^2$.

Then:
 * $r^2 - \paren {p^2 + q^2} > 0$

and so $(1)$ may be written as:

Next suppose $r^2 < p^2 + q^2$.

Then:
 * $r^2 - \paren {p^2 + q^2} < 0$

and so $(1)$ may be written as:

Also see

 * Primitive of $\dfrac 1 {p \sin a x + q \cos a x}$ for the case where $r = 0$


 * Primitive of $\dfrac 1 {p \sin a x + q \paren {1 + \cos a x} }$ for the case where $r = q$


 * Primitive of $\dfrac 1 {p \sin a x + q \cos a x + \sqrt {p^2 + q^2} }$ for the case where $r = \sqrt {p^2 + q^2}$


 * Primitive of $\dfrac 1 {p \sin a x + q \cos a x - \sqrt {p^2 + q^2} }$ for the case where $r = -\sqrt {p^2 + q^2}$