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.

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*}
