<s>[INST] Compute $\int \frac {dx} {(a + b \cos x)^2} $ for $a > b.$ Let $a>b$ be real numbers. As the title suggests, I would like to compute $$\int \frac 1 {(a + b \cos x)^2} \, dx.$$
My attempt consisted of converting the cosine to half-angle tangents, substituting the half-angle tangent for $t$, and simplifying to $$\int \frac{2(1+t^2)}{[(a+b)+(a-b)t^2]^2} \, dt.$$
From here, I multiplied and divided the integrand by $(a-b)$, added an $(a+b)-2b$ to the numerator, and simplified it to $$\frac{4b}{a-b}\int {\left(\frac 1 {[(a+b)+(a-b)t^2]^2} + \frac{2t}{a-b} \right)} \, dt.$$
Now, just looking at the integral left, I substituted $t$ for $\sqrt{\frac{a+b}{a-b}} \tan\theta$, did some simplifying, converted the resulting $\cos^2\!\theta$ in the numerator to $1+\cos 2 \theta$, and wrapped up the integral, finishing up with $$\frac{2\tan \frac{x}{2}}{a-b}-\frac{2b}{(a^2-b^2)^{\frac{3}{2}}}{\left(\arctan \sqrt{\frac{a+b}{a-b}}\tan \frac{x}{2}+ \frac{\sqrt{ \frac{a+b}{a-b}}\tan 
 \frac{x}{2}}{1+{ \frac{a-b}{a+b}\tan^2 \frac{x}{2}}} \right)}$$
This is apparently wrong. Can someone help me with why?
 [/INST] Here it is another way to approach it for the sake of curiosity.
Let us make the substitution:
$$\sinh(x) = t\sqrt{\frac{a-b}{a+b}} \Rightarrow \mathrm{d}t = \sqrt{\frac{a+b}{a-b}}\cosh(x)\mathrm{d}x$$
Then the denominator of the given expression can be written as
\begin{align*}
((a+b) + (a-b)t^{2})^{2} & = (a+b)^{2}\left[1 + \left(t\sqrt{\frac{a-b}{a+b}}\right)^{2}\right]^{2}\\\\
& = (a+b)^{2}(1 + \sinh^{2}(x))^{2}\\\\
& = (a+b)^{2}\cosh^{4}(x)
\end{align*}
Besides that, we do also have that
\begin{align*}
2(1 + t^{2}) & = 2\left[1 + \left(\frac{a+b}{a-b}\right)\sinh^{2}(x)\right]\\\\
& = 2\left[1 - \frac{a+b}{a-b} + \left(\frac{a+b}{a-b}\right)(1 + \sinh^{2}(x))\right]\\\\
& = 2\left[-\frac{2b}{a-b} + \left(\frac{a+b}{a-b}\right)\cosh^{2}(x)\right]
\end{align*}
Gathering both results, the proposed integral can be expressed as
\begin{align*}
I & = \sqrt{\frac{a+b}{a-b}}\left[-\int\left(\frac{4b}{(a^{2}-b^{2})(a+b)\cosh^{3}(x)}\right)\mathrm{d}x + \int\left(\frac{2}{(a^{2}-b^{2})\cosh(x)}\right)\mathrm{d}x\right]
\end{align*}
Can you take it from here?
</s>