<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] The integral can be written as
$$
\int \frac{\sin x (b-a\cos x)}{(a^2+b^2-2ab \cos x)^{\Large\frac{3}{2}}}\,dx=\int \frac{a\cos x-b}{\sqrt{(a^2+b^2-2ab \cos x)^3}}\,d(\cos x).
$$
Let $y=\cos x$, then the integral becomes
$$
\int \frac{ay-b}{\sqrt{(a^2+b^2-2ab y)^3}}\,dy=\int \frac{ay}{\sqrt{(a^2+b^2-2ab y)^3}}\,dy-\int \frac{b}{\sqrt{(a^2+b^2-2ab y)^3}}\,dy.
$$
The right integral in RHS can easily be solved using substitution $u=a^2+b^2-2ab y$ and $du=-2ab\ dy$.
For the left integral in RHS, let $y=\dfrac{(a^2+b^2)}{2ab}\sin^2\theta$ and $dy=\dfrac{(a^2+b^2)}{ab}\sin\theta\cos\theta\ d\theta$, then
\begin{align}
\int \frac{ay}{\sqrt{(a^2+b^2-2ab y)^3}}\,dy&=\frac{\sqrt{a^2+b^2}}{2ab^2}\int \frac{\sin^3\theta}{\cos^2\theta}\,d\theta\\
&=\frac{\sqrt{a^2+b^2}}{2ab^2}\int \frac{\sin\theta(1-\cos^2\theta)}{\cos^2\theta}\,d\theta\\
&=\frac{\sqrt{a^2+b^2}}{2ab^2}\left[\int \frac{\sin\theta}{\cos^2\theta}\,d\theta-\int\sin\theta\ d\theta\right]\\
&=-\frac{\sqrt{a^2+b^2}}{2ab^2}\left[\int \frac{1}{\cos^2\theta}d(\cos\theta)+\int\sin\theta\ d\theta\right].
\end{align}
From here, the last integral should be easy to evaluate. I leave it to you Kappa for the rest.
</s>