# Primitive of Reciprocal of p plus q by Cosine of a x/Proof 2

## Theorem

$\displaystyle \int \frac {\mathrm d x} {p + q \cos a x} = \begin{cases} \displaystyle \frac 2 {a \sqrt {p^2 - q^2} } \arctan \left({\sqrt {\frac {p - q} {p + q} } \tan \dfrac {a x} 2}\right) + C & : p^2 > q^2 \\ \displaystyle \frac 1 {a \sqrt {q^2 - p^2} } \ln \left\vert{\frac {\tan \dfrac {a x} 2 + \sqrt {\dfrac {q + p} {q - p} } } {\tan \dfrac {a x} 2 - \sqrt {\dfrac {q + p} {q - p} } } }\right\vert + C & : p^2 < q^2 \\ \end{cases}$

## Proof

 $\displaystyle \int \frac {\d x} {p + q \cos a x}$ $=$ $\displaystyle \int \frac {\paren {p - q \cos a x} \rd x} {\paren {p + q \cos a x} \paren {p - q \cos a x} }$ $\displaystyle$ $=$ $\displaystyle \int \frac {\paren {p - q \cos a x} \rd x} {p^2 - q^2 \cos^2 a x}$ $\displaystyle$ $=$ $\displaystyle \int \frac {\paren {p - q \cos a x} \rd x} {\paren {p^2 - q^2} + q^2 \sin^2 a x}$ Sum of Squares of Sine and Cosine

Let $p^2 > q^2$.

Thus, let $p^2 - q^2 = d^2$.

Then:

 $\displaystyle \int \frac {\d x} {p + q \cos a x}$ $=$ $\displaystyle \int \frac {\paren {p - q \cos a x} \rd x} {d^2 + q^2 \sin^2 a x}$ $\displaystyle$ $=$ $\displaystyle \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}$ Linear Combination of Integrals $\displaystyle$ $=$ $\displaystyle \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}$ Primitive of $\dfrac 1 {p^2 + q^2 \sin^2 a x}$ $\displaystyle$ $=$ $\displaystyle \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}$ $\displaystyle$ $=$ $\displaystyle \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}$ Derivative of $\sin a x$ $\displaystyle$ $=$ $\displaystyle \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}$ letting $u = \sin a x$ $\displaystyle$ $=$ $\displaystyle \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}$ $\displaystyle$ $=$ $\displaystyle \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$ Primitive of $\dfrac 1 {x^2 + a^2}$ $\displaystyle$ $=$ $\displaystyle \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$ substituting $u = \sin a x$ $\displaystyle$ $=$ $\displaystyle \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$ substituting $d = \sqrt{p^2 - q^2}$ 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. $\displaystyle$ $=$ $\displaystyle \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$ Difference of Arctangents $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \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$ Tangent Half-Angle Substitution for Sine and Double Angle Formula for Tangent $\displaystyle$ $=$ $\displaystyle \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$ letting $u = \tan \frac {a x} 2$ $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \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$ letting $m = p - q$ and $n = p + q$ $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \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$ $\displaystyle$ $=$ $\displaystyle \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {m n} u} {n - m u^2} } + C$ $\displaystyle$ $=$ $\displaystyle \frac 1 {a \sqrt {m n} } \map \arctan {\frac {2 \sqrt {\frac m n} u} {1 - \frac m n u^2} } + C$ $\displaystyle$ $=$ $\displaystyle \frac 2 {a \sqrt {m n} } \map \arctan {\sqrt {\frac m n} u} + C$ Sum of Arctangents $\displaystyle$ $=$ $\displaystyle \frac 2 {a \sqrt {p^2 - q^2} } \map \arctan {\sqrt {\frac {p - q} {p + q} } u} + C$ substituting $m = p - q$ and $n = p + q$ $\displaystyle$ $=$ $\displaystyle \frac 2 {a \sqrt {p^2 - q^2} } \map \arctan {\sqrt {\frac {p - q} {p + q} } \tan \frac {a x} 2 } + C$ substituting $u = \tan \frac {a x} 2$

$\Box$

Now let $p^2 < q^2$.

 $\displaystyle \int \frac {\d x} {p + q \cos a x}$ $=$ $\displaystyle \frac 2 {a \sqrt {p^2 - q^2} } \map \arctan {\sqrt {\frac {p - q} {p + q} } \tan \frac {a x} 2 }$ $\displaystyle$ $=$ $\displaystyle \frac 2 {a i \sqrt {q^2 - p^2} } \map \arctan {i \sqrt {\frac {q - p} {q + p} } \tan \frac {a x} 2 }$ where $i$ is the imaginary unit $\displaystyle$ $=$ $\displaystyle \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} }$ Arctangent of Imaginary Number $\displaystyle$ $=$ $\displaystyle \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} }$ $\displaystyle$ $=$ $\displaystyle \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} } } }$ $\displaystyle$ $=$ $\displaystyle \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} } } }$

$\blacksquare$