Better way to evaluate $\int \frac{dx}{\left (a +b\cos x \right)^2}$ $$\int \frac{dx}{\left (a +b\cos x \right)^2}$$
$$u=\frac{b +a \cos x}{a +b\cos x }$$
$$du=\frac{\sin x\left(b^2 -a^2\right)}{ \left (a +b.\cos x \right)^2}$$
$$\frac{du}{\sin x\left(b^2 -a^2\right)}=\frac{dx}{\left (a +b\cos x \right)^2}$$
$$\cos x=\frac{au -b}{a - bu}  $$
$$\sin x=\sqrt{1-\left(\frac{au -b}{a - bu}\right)^2}$$
 It is becoming messy with this .I also tried it using half angle formula but didn't find it good.
 A: I think the tangent half-angle substitution should work. Here's what I have:
\begin{align*}
\int \frac{\mathrm{d}x}{(a+b\cos{x})^2} &= \int \frac{2\,\mathrm{d}t}{(1+t^2)(a+b\frac{1-t^2}{1+t^2})^2}, \qquad t = \tan{(x/2)} \\
&= 2 \int \frac{(1+t^2)dt}{a^2(1+t^2)^2+2ab(1-t^2)(1+t^2)+b^2(1-t^2)^2}\\
&= 2\int \frac{(1+t^2)\mathrm{d}t}{(a^2-2ab+b^2)t^4 + 2(a^2-b^2)t^2+a^2+2ab+b^2}\\
&=2\int \frac{(1+t^2)\mathrm{d}t}{((a-b)t^2 + (a+b))^2} \\
&=2\int \frac{(1+\frac{a+b}{a-b}\tan^2{\theta})\sqrt{\frac{a+b}{a-b}}\sec^2{\theta} \, \mathrm{d}\theta}{(a+b)^2\sec^4{\theta}} \qquad t=\sqrt{\frac{a+b}{a-b}}\tan{\theta} \\
&= 2\sqrt{\frac{a+b}{a-b}}\frac{1}{(a+b)^2}\int(\cos^2{\theta}+\frac{a+b}{a-b}\sin^2{\theta})\mathrm{d}\theta \\
&= \sqrt{\frac{a+b}{a-b}}\frac{1}{(a+b)^2}\left[\frac{2a}{a-b}\theta - \frac{2b}{a-b}\sin{\theta}\cos{\theta}\right]
\end{align*}
A: Hint:
Rationalize with $z=e^{ix}$ (and $dz=iz\,dx$),
$$\int \frac{dx}{\left (r+\cos x \right)^2}
=\int\frac{dz}{iz\left(r+\dfrac{z+z^{-1}}2\right)^2}
=\int\frac{4z\,dz}{i\left(z^2+2rz+1\right)^2}
=\int\frac{4(z+r-r)\,dz}{i\left((z+r)^2+1-r^2\right)^2}.
$$
This yields a term $\log({z^2+2rz+1})=\log(r+\cos x)$ and, depending on the sign of $1-r^2$, an $\arctan$ or $\text{artanh}$.
A: HINT
Put $$A=\frac{\ sin x}{a+b\cos x} $$now differentiate both sides and after simplification integrate it up to get the desired result.
