{{begin-eqn}} {{eqn | l = \int \frac {\d x} {p + q \cos a x}       | r = \int \frac {\paren {p - q \cos a x} \rd x} {\paren {p + q \cos a x} \paren {p - q \cos a x} }       | c =  }} {{eqn | r = \int \frac {\paren {p - q \cos a x} \rd x} {p^2 - q^2 \cos^2 a x}       | c =  }} {{eqn | r = \int \frac {\paren {p - q \cos a x} \rd x} {\paren {p^2 - q^2} + q^2 \sin^2 a x}       | c = Sum of Squares of Sine and Cosine }} {{end-eqn}} Let $p^2 > q^2$. Thus, let $p^2 - q^2 = d^2$. Then: {{begin-eqn}} {{eqn | l = \int \frac {\d x} {p + q \cos a x}       | r = \int \frac {\paren {p - q \cos a x} \rd x} {d^2 + q^2 \sin^2 a x}       | c =  }} {{eqn | r = \int \frac {p \rd x} {d^2 + q^2 \sin^2 a x} - \int \frac {q \cos a x \rd x} {d^2 + q^2 \sin^2 a x}       | c = Linear Combination of Integrals }} {{eqn | r = \frac p {a d \sqrt{d^2 + q^2} } \map \arctan {\frac {\sqrt {d^2 + q^2} \tan a x} d} - \int \frac {q \cos a x \rd x} {d^2 + q^2 \sin^2 a x}       | c = Primitive of $\dfrac 1 {p^2 + q^2 \sin^2 a x}$ }} {{eqn | r = \frac 1 {a d} \map \arctan {\frac {p \tan a x} d} - \int \frac {q \cos a x \rd x} {d^2 + q^2 \sin^2 a x}       | c =  }} {{eqn | r = \frac 1 {a d} \map \arctan {\frac {p \tan a x} d} - \frac 1 a \int \frac {q \paren {\sin a x}' \rd x} {d^2 + q^2 \sin^2 a x}       | c = Derivative of $\sin a x$ }} {{eqn | r = \frac 1 {a d} \map \arctan {\frac {p \tan a x} d} - \frac 1 a \int \frac {q \rd u} {d^2 + q^2 u^2}       | c = letting $u = \sin a x$ }} {{eqn | r = \frac 1 {a d} \map \arctan {\frac {p \tan a x} d} - \frac 1 {a q} \int \frac {\d u} {\frac {d^2} {q^2} + u^2}       | c =  }} {{eqn | r = \frac 1 {a d} \map \arctan {\frac {p \tan a x} d} - \frac 1 {a q} \frac q d \map \arctan {\frac {q u} d} + C       | c = Primitive of $\dfrac 1 {x^2 + a^2}$ }} {{eqn | r = \frac 1 {a d} \map \arctan {\frac {p \tan a x} d} - \frac 1 {a d} \map \arctan {\frac {q \sin a x} d} + C       | c = substituting $u = \sin a x$ }} {{eqn | r = \frac 1 {a \sqrt {p^2 - q^2} } \paren {\map \arctan {\frac {p \tan a x} {\sqrt {p^2-q^2} } } - \map \arctan {\frac {q \sin a x} {\sqrt {p^2 - q^2} } } } + C       | c = substituting $d = \sqrt{p^2 - q^2}$ }} {{eqn-intertext|While this would usually be considered as an acceptable form to leave such an expression, there is some way to go to obtain the result requested.}} {{eqn | r = \frac 1 {a \sqrt{p^2 - q^2} } \map \arctan {\frac {\frac {p \tan a x} {\sqrt {p^2 - q^2} } - \frac {q \sin a x} {\sqrt {p^2 - q^2} } } {1 + \frac {p \tan a x} {\sqrt {p^2 - q^2} } \frac {q \sin a x} {\sqrt {p^2 - q^2} } } } + C       | c = Difference of Arctangents }} {{eqn | r = \frac 1 {a \sqrt {p^2 - q^2} } \map \arctan {\frac {\sqrt {p^2 - q^2} \paren {p \tan a x - q \sin a x} } {p^2 - q^2 + p q \tan a x \sin a x} } + C       | c =  }} {{eqn | r = \frac 1 {a \sqrt {p^2 - q^2} } \map \arctan {\frac {\sqrt {p^2 - q^2} \paren {p \paren {\frac {2 \tan \frac {a x} 2} {1 - \paren {\tan \frac {a x} 2}^2 } } - q \paren {\frac {2 \tan \frac {a x} 2} {1 + \paren {\tan \frac {a x} 2}^2 } } } } {p^2 - q^2 + p q \paren {\frac {2 \tan \frac {a x} 2} {1 - \paren {\tan \frac {a x} 2}^2 } } \paren {\frac {2 \tan \frac {a x} 2} {1 + \paren {\tan \frac {a x} 2}^2 } } } } + C       | c = Tangent Half-Angle Substitution for Sine and Double Angle Formula for Tangent }} {{eqn | r = \frac 1 {a \sqrt {p^2 - q^2} } \map \arctan {\frac {\sqrt {p^2 - q^2} \paren {p \paren {\frac {2 u} {1 - u^2 } } - q \paren {\frac {2 u} {1 + u^2 } } } } {p^2 - q^2 + p q \paren {\frac {2 u} {1 - u^2 } } \paren {\frac {2 u} {1 + u^2} } } } + C       | c = letting $u = \tan \frac {a x} 2$ }} {{eqn | r = \frac 1 {a \sqrt {p^2 - q^2} } \map \arctan {\frac {\sqrt {p^2 - q^2} \paren {2 p u \paren {1 + u^2} - 2 q u \paren {1 - u^2} } } {\paren {p^2 - q^2} \paren {1 - u^2} \paren {1 + u^2} + 4 p q u^2} } + C       | c =  }} {{eqn | r = \frac 1 {a \sqrt {p^2 - q^2} } \map \arctan {\frac {\sqrt {p^2 - q^2} \paren {2 p u + 2 p u^3 - 2 q u + 2 q u^3} } {\paren {p^2 - q^2} \paren {1 - u^4} + 4 p q u^2} } + C       | c =  }} {{eqn | r = \frac 1 {a \sqrt {p^2 - q^2} } \map \arctan {\frac {2 \sqrt {p^2 - q^2} \paren {\paren {p - q} u + \paren {p + q} u^3 } } {\paren {p^2 - q^2} \paren {1 - u^4} + 4 p q u^2} } + C       | c =  }} {{eqn | r = \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {m n} \paren {m u + n u^3} } {m n \paren {1 - u^4} + \paren {n^2 - m^2} u^2} } + C       | c = letting $m = p - q$ and $n = p + q$ }} {{eqn | r = \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {m n} u \paren {m + n u^2} } {m n - m n u^4 + n^2 u^2 - m^2 u^2} } + C       | c = }} {{eqn | r = \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {m n} u \paren {m + n u^2} } {m n - m^2 u^2 + n^2 u^2 - m n u^4} } + C       | c = }} {{eqn | r = \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {m n} u \paren {m + n u^2} } {m \paren {n - m u^2} + n u^2 \paren {n - m u^2} } } + C       | c = }} {{eqn | r = \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {m n} u \paren {m + n u^2} } {\paren {m + n u^2} \paren {n - m u^2} } } + C       | c = }} {{eqn | r = \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {m n} u} {n - m u^2} } + C       | c = }} {{eqn | r = \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {\frac m n} u} {1 - \frac m n u^2} } + C       | c = }} {{eqn | r = \frac 2 {a \sqrt {m n} } \map \arctan {\sqrt {\frac m n} u} + C       | c = Sum of Arctangents }} {{eqn | r = \frac 2 {a \sqrt {p^2 - q^2} } \map \arctan {\sqrt {\frac {p - q} {p + q} } u} + C       | c = substituting $m = p - q$ and $n = p + q$ }} {{eqn | r = \frac 2 {a \sqrt {p^2 - q^2} } \map \arctan {\sqrt {\frac {p - q} {p + q} } \tan \frac {a x} 2 } + C       | c = substituting $u = \tan \frac {a x} 2$ }} {{end-eqn}} {{qed|lemma}} {{questionable|The derivation up till here has been done on the assumption that $p^2 > q^2$. Hence it is a failure of logic to take the expression above and extend it to $p^2 < q^2$ without having first established in the above that it is valid so to do.}} Now let $p^2 < q^2$. {{begin-eqn}} {{eqn | l = \int \frac {\d x} {p + q \cos a x}       | r = \frac 2 {a \sqrt {p^2 - q^2} } \map \arctan {\sqrt {\frac {p - q} {p + q} } \tan \frac {a x} 2 }       | c =  }} {{eqn | r = \frac 2 {a i \sqrt {q^2 - p^2} } \map \arctan {i \sqrt {\frac {q - p} {q + p} } \tan \frac {a x} 2 }       | c = where $i$ is the imaginary unit }} {{eqn | r = \frac 2 {a i \sqrt {q^2 - p^2} } \frac i 2 \ln \size {\frac {1 + \sqrt {\frac {q - p} {q + p} } \tan \frac {a x} 2} {1 - \sqrt {\frac {q - p} {q + p} } \tan \frac {a x} 2} }       | c = Arctangent of Imaginary Number }} {{eqn | r = \frac 2 {a i \sqrt {q^2 - p^2} } \frac i 2 \ln \size {\frac {\sqrt {\frac {q + p} {q - p} } + \tan \frac {a x} 2} {\sqrt {\frac {q + p} {q - p} } - \tan \frac {a x} 2} }       | c =  }} {{eqn | r = \frac 2 {a i \sqrt {q^2 - p^2} } \frac i 2 \ln \size {\frac {\tan \frac {a x} 2 + \sqrt {\frac {q + p} {q - p} } } {\tan \frac {a x} 2 - \sqrt {\frac {q + p} {q - p} } } }       | c =  }} {{eqn | r = \frac 1 {a \sqrt {q^2 - p^2} } \ln \size {\frac {\tan \frac {a x} 2 + \sqrt {\frac {q + p} {q - p} } } {\tan \frac {a x} 2 - \sqrt {\frac {q + p} {q - p} } } }       | c =  }} {{end-eqn}} {{qed}}