<s>[INST] Why is $ \int \frac{\sin x (b-a\cos x)}{(b^2+a^2-2ab \cos x)^{3/2}}\,dx = \frac{a-b\cos x}{b^2 \sqrt{a^2-2ab\cos x + b^2}}$? Why is $$ \int \frac{\sin x (b-a\cos x)}{(b^2+a^2-2ab \cos x)^{3/2}}\,dx = \frac{a-b\cos x}{b^2 \sqrt{a^2-2ab\cos x + b^2}}\text{ ?}$$
Constant of integration omitted.
 [/INST] Since I spent so much time trying to work this out, I'm going to type the answer even though there are already two perfectly good answers. Hah!
Anyway, here's how to do it. Let $$u = b - a \cos x$$ and let 
$$y^2 = a^2 - b^2 + 2ub = a^2 + b^2 - 2ab \cos x.$$
Notice that then making the change of variables to $y$, we have that
$$
\begin{align*}
2ydy = 2ab\sin x dx \Rightarrow \sin x dx =\dfrac{y \,dy}{ab}, &\quad b-a \cos x = u = \dfrac{y^2-a^2 + b^2}{2b}\\
\dfrac{1}{(a^2 - 2ab \cos x + b^2)^{3/2}} &= \dfrac{1}{y^3}
\end{align*}
$$
and therefore the integral is
$$
\begin{align*}
I &= \int \frac{\sin x (b-a\cos x)}{(b^2+a^2-2ab \cos x)^{3/2}} \,dx \\
&= \int\left( \dfrac{y \,dy}{ab}\right)\left( \dfrac{y^2-a^2 + b^2}{2b} \right)\left(\dfrac{1}{y^3}\right) \\
&= \dfrac{1}{2a b^2} \int \dfrac{y^2 - a^2 - b^2}{y^2} \, dy\\
&= \dfrac{1}{2ab^2} \left(\dfrac{y^2+a^2-b^2}{y}\right)+ \mbox{constant}\\
&= \dfrac{1}{2ab^2} \left(\dfrac{a^2 + b^2 - 2ab \cos x +a^2-b^2}{\sqrt{a^2 + b^2 - 2ab\cos x}}\right) + \mbox{constant}\\
&= \dfrac{a - b \cos x}{b^2 \sqrt{b^2+a^2-2ab \cos x}} + \mbox{constant}
\end{align*}
$$
as desired. Woohoo!
</s>