Number 361 in my List of Fiendish Integrals:

Prove that:

$\displaystyle \int \frac {\mathrm d x} {\left({p + q \sin a x}\right)^2} = \frac {q \cos a x} {a \left({p^2 - q^2}\right) \left({p + q \sin a x}\right)} + \frac p {p^2 - q^2} \int \frac {\mathrm d x} {p + q \sin a x}$

I tried the Weierstrass substitution $\displaystyle u = \tan \frac {a x} 2$ but that got very complicated:

$\displaystyle \frac {2 q \left({q u + p}\right)} {a p \left({p^2 - q^2}\right) \left({p u^2 + 2 q u + p}\right)} + \frac {2 p} {a \left({p^2 - q^2}\right)} \int \frac {\mathrm d u} {p u^2 + 2 q u + p}$

... and I can't get Integration by Parts to work. I fleetingly looked at manipulating it into the form:

$\displaystyle \frac 1 p \int \frac {\left({p + q \sin a x - q \sin a x}\right) \ \mathrm d x} {\left({p + q \sin a x}\right)^2}$

... but that doesn't look hopeful either.

It's probably all about the substitution, as usual, but I haven't found one that works.

Any takers?