Primitive of Reciprocal of p by Sine of a x plus q by Cosine of a x plus Root of p squared plus q squared

Theorem

 * $\ds \int \frac {\d x} {p \sin a x + q \cos a x + \sqrt {p^2 + q^2} } = \frac {-1} {a \sqrt {p^2 + q^2} } \map \tan {\frac \pi 4 - \frac {a x + \arctan \frac q p} 2} + C$

Proof
Let $z = a x$.

Then $\d x = \dfrac {\d z} a$ and so:

$(1): \quad \ds \int \frac {\d x} {p \sin a x + q \cos a x + \sqrt {p^2 + q^2} } = \dfrac 1 a \int \frac {\d z} {p \sin z + q \cos z + \sqrt {p^2 + q^2} }$

Then: