Theorem: Primitive of Reciprocal of square of p plus q by Sine of a x

:$\ds \int \frac {\d x} {\paren {p + q \sin a x}^2} = \frac {q \cos a x} {a \paren {p^2 - q^2} \paren {p + q \sin a x} } + \frac p {p^2 - q^2} \int \frac {\d x} {p + q \sin a x}$

Proof:
First a pair of lemmata:
=== Lemma ===
{{:Primitive of Reciprocal of square of p plus q by Sine of a x/Lemma}}{{qed|lemma}}
=== Weierstrass Substitution ===
{{:Primitive of Reciprocal of square of p plus q by Sine of a x/Weierstrass Substitution|Weierstrass Substitution}}{{qed|lemma}}
{{begin-eqn}}
{{eqn | l = \int \frac {\d x} {\paren {p + q \sin a x}^2}
      | r = \frac 2 a \int \frac {\paren {u^2 + 1} \rd u} {\paren {p u^2 + 2 q u + p}^2}
      | c = Weierstrass Substitution: $u = \tan \dfrac {a x} 2$
}}
{{eqn | r = \frac 2 a \int \frac {u^2 \rd u} {\paren {p u^2 + 2 q u + p}^2} + \frac 2 a \int \frac {\d u} {\paren {p u^2 + 2 q u + p}^2}
      | c = Linear Combination of Primitives
}}
{{eqn | r = \frac 2 a \paren {\frac {\paren {4 q^2 - 2 p^2} u + 2 p q} {p \paren {4 p^2 - 4 q^2} \paren {p u^2 + 2 q u + p} } + \frac {2 p} {4 p^2 - 4 q^2} \int \frac {\d u} {p u^2 + 2 q u + p} } + C
      | c = Primitive of $\dfrac {x^2} {\paren {a x^2 + b x + c}^2}$
}}
{{eqn | o = 
      | ro= +
      | r = \frac 2 a \paren {\frac {2 p u + 2 q} {\paren {4 p^2 - 4 q^2} \paren {p u^2 + 2 q u + p} } + \frac {2 p} {4 p^2 - 4 q^2} \int \frac {\d u} {p u^2 + 2 q u + p} } + C
      | c = Primitive of $\dfrac 1 {\paren {a x^2 + b x + c}^2}$
}}
{{eqn | r = \frac {\paren {2 q^2 - p^2} u + p q} {a p \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac p {a \paren {p^2 - q^2} } \int \frac {\d u} {p u^2 + 2 q u + p} + C
      | c = simplifying ...
}}
{{eqn | o = 
      | ro= +
      | r = \frac {p^2 u + p q} {a p \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac p {a \paren {p^2 - q^2} } \int \frac {\d u} {p u^2 + 2 q u + p} + C
      | c = ... and creating common denominators
}}
{{eqn | r = \frac {\paren {2 q^2 - p^2} u + p q + p^2 u + p q} {a p \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac {2 p} {a \paren {p^2 - q^2} } \int \frac {\d u} {p u^2 + 2 q u + p} + C
      | c = summing
}}
{{eqn | r = \frac {2 q \paren {q u + p} } {a p \paren {p^2 - q^2} } \dfrac 1 {p u^2 + 2 q u + p} + \frac p {\paren {p^2 - q^2} } \paren {\frac 2 a \int \frac {\d u} {p u^2 + 2 q u + p} } + C
      | c = simplifying, and strategic rearrangement
}}
{{eqn | r = \frac {2 q \paren {q u + p} } {a p \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = Primitive of $\dfrac 1 {p + q \sin a x}$: Weierstrass Substitution
}}
{{end-eqn}}
Then we note that:
{{begin-eqn}}
{{eqn | l = \dfrac {2 q \paren {q u + p} } p - \dfrac {q \paren {p u^2 + 2 q u + p} } p
      | r = \dfrac {2 q^2 u + 2 p q - p q u^2 - 2 q^2 u - p q} p
      | c = 
}}
{{eqn | r = \dfrac {p q - p q u^2} p
      | c = 
}}
{{eqn | r = q \paren {1 - u^2}
      | c = 
}}
{{end-eqn}}
Hence:
{{begin-eqn}}
{{eqn | l = \int \frac {\d x} {\paren {p + q \sin a x}^2}
      | r = \frac {2 q \paren {q u + p} } {a p \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = from above
}}
{{eqn | r = \frac {q \paren {1 - u^2} + \frac {q \paren {p u^2 + 2 q u + p} } p} {a \paren {p^2 - q^2}  \paren {p u^2 + 2 q u + p} } + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = 
}}
{{eqn | r = \frac {q \paren {1 - u^2} } {a \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac {q \paren {p u^2 + 2 q u + p} } {a p \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = 
}}
{{eqn | r = \frac {q \paren {1 - u^2} } {a \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} } + \frac q {a p \paren {p^2 - q^2} } + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = 
}}
{{eqn | r = \frac {q \paren {1 - u^2} } {a \paren {p^2 - q^2} \paren {p u^2 + 2 q u + p} }  + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = subsuming $\dfrac q {a p \paren {p^2 - q^2} }$ into the constant
}}
{{eqn | r = \frac {q \paren {1 - u^2} } {a \paren {p^2 - q^2} \paren {1 + u^2} \paren {p + q \sin a x} }  + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = Lemma
}}
{{eqn | r = \frac {q \cos a x} {a \paren {p^2 - q^2} \paren {p + q \sin a x} }  + \frac p {\paren {p^2 - q^2} } \int \frac {\d x} {p + q \sin a x} + C
      | c = Tangent Half-Angle Substitution for Cosine
}}
{{end-eqn}}
{{qed}}