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

Theorem

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

\displaystyle \frac 2 {a \sqrt {r^2 - p^2 - q^2} } \arctan \left({\frac {p + \left({r - q}\right) \tan \dfrac {a x} 2} {\sqrt {r^2 - p^2 - q^2} } }\right) + C & : p^2 + q^2 < r^2 \\ \displaystyle \frac 1 {a \sqrt {p^2 + q^2 - r^2} } \ln \left\vert{\frac {p - \sqrt {p^2 + q^2 - r^2} + \left({r - q}\right) \tan \dfrac {a x} 2} {p + \sqrt {p^2 + q^2 - r^2} + \left({r - q}\right) \tan \dfrac {a x} 2} }\right\vert + C & : p^2 + q^2 > r^2 \end{cases}$

Proof
Let $z = a x + \arctan \dfrac {-p} q$.

Then:

Let $d = \sqrt {p^2 + q^2}$.

Then:

Then:

Then:

Also see

 * Primitive of $\dfrac 1 {p \sin a x + q \cos a x}$