I am evaluating:
$$\int \frac {\mathrm d x} {(p + q \sin a x)^2}$$
which the book gives me as: $$\frac {q \cos a x} {a (p^2 - q^2) (p + q \sin a x) } + \frac p {p^2 - q^2} \int \frac {\mathrm d x} {p + q \sin a x}$$
This is Spiegel's "Mathematical Handbook of Formulas and Tables" (Schaum, 1968), item $14.361$.
I am using a Weierstrass substitution: $u = \tan \dfrac {a x} 2$ which yields $\mathrm d x = \dfrac 2 a \dfrac {\mathrm d u} {1 + u^2}$ and $\sin a x = \dfrac {2 u} {u^2 + 1}$.
After algebra, this yields me the primitive:
$$\frac 2 a \int \frac {(u^2 + 1) \mathrm d u} {(p u^2 + 2 q u + p)^2}$$
I split this up into two separate primitives:
$$\frac 2 a \int \frac {u^2 \mathrm d u} {(p u^2 + 2 q u + p)^2} + \frac 2 a \int \frac {\mathrm d u} {(p u^2 + 2 q u + p)^2}$$
both of which are obtained via standard (though unwieldy) results:
$$\frac 2 a \left({\frac {(4 q^2 - 2 p^2) u + 2 p q} {p (4 p^2 - 4 q^2) (p u^2 + 2 q u + p) } + \frac {2 p} {4 p^2 - 4 q^2} \int \frac {\mathrm d u} {p u^2 + 2 q u + p} }\right)$$
and:
$$\frac 2 a \left({\frac {2 p u + 2 q} {(4 p^2 - 4 q^2) (p u^2 + 2 q u + p) } + \frac {2 p} {4 p^2 - 4 q^2} \int \frac {\mathrm d u} {p u^2 + 2 q u + p} }\right)$$
After some straightforward cleaning up, I get:
$$\frac {2 q (q u + p) } {a p (p^2 - q^2) (p u^2 + 2 q u + p)} + \frac p {(p^2 - q^2) } \left({\frac 2 a \int \frac {\mathrm d u} {p u^2 + 2 q u + p} }\right)$$
The term on the right is in completely the correct format, returning me $\displaystyle \frac p {p^2 - q^2} \int \frac {\mathrm d x} {p + q \sin a x}$ after I put $u$ back.
But my left hand term has gone astray. In order to return $\dfrac {q \cos a x} {a (p^2 - q^2) (p + q \sin a x) }$, I really need to get it into the form:
$$\frac {q (1 - u^2)} {a (p^2 - q^2) (p u^2 + 2 q u + p)}$$
but instead I have: $$\frac {2 q (q u + p) } {a p (p^2 - q^2) (p u^2 + 2 q u + p)}$$
I have gone through my working carefully several times, but I can't put my finger on where I have gone astray -- it could be at any of the above steps.
Write the numerator as
$$q(1-u^2)=-\frac q p (pu^2+2qu+p) +\frac{2q}p( qu +p) $$
where the first term cancels the denominator, becoming a non-essential constant, and second term produces what you have.