<s>[INST] What's the answer to $\int \frac{\cos^2x \sin x}{\sin x - \cos x} dx$? I tried solving the integral $$\int \frac{\cos^2x \sin x}{\sin x - \cos x}\, dx$$ the following ways:


*

*Expressing each function in the form of $\tan \left(\frac{x}{2}\right)$, $\cos \left(\frac{x}{2}\right)\,$ and $\,\sin \left(\frac{x}{2}\right)\,$ independently, but that didn't go well for me.

*Multiplying and dividing by $\cos^2x$ or $\sin^2x$.

*Expressing $\cos^2x$ as $1-\sin^2x$ and splitting the integral, and I was stuck with $\int \left(\frac{\sin^3x}{\sin x - \cos x}\right)\, dx$ which I rewrote as  $\int \frac{\csc^2x}{\csc^4x (1-\cot x) } dx,\,$ and tried a whole range of substitutions only to fail.

*I tried to substitute   $\frac{1}{ \sin x - \cos x}$,  $\frac{\sin x}{ \sin x - \cos x}$, $\frac{\cos x \sin x}{ \sin x - \cos x}$ and  $\frac{\cos^2x \sin x}{\sin x - \cos x},$ independently, none of which seemed to work  out.

*I expressed the denominator as $\sin\left(\frac{\pi}{4}-x\right)$  and tried multiplying and dividing by $\sin\left(\frac{\pi}{4}+x\right)$, and carried out some substitutions. Then, I repeated the same with $\cos\left(\frac{\pi}{4}+x\right)$. Neither of them worked.
 [/INST] For integrands that are a rational function of sine and cosine, as a guide to what trigonometric substitution one may try the Bioche Rules can be used. 
Here notice the differential form
$$w(x) = f(\sin x, \cos x) \, dx = \frac{\cos^2 x \sin x}{\sin x - \cos x} \, dx$$
is invariant under the substitution $x \mapsto \pi + x$, that is, $w(\pi + x) = w(x)$. This suggests a substitution of $t = \tan x$ can be used. As $dt = \sec^2 x \, dx$ we rewrite the integrand as the product between a rational function consisting of $\tan x$ terms and a $\sec^2 x$ terms. Doing so we have
\begin{align}
I &= \int \frac{\cos^2 x \sin x}{\sin x - \cos x} \, dx\\
&= \int \frac{\cos^2 x \sin x}{\sin x - \cos x} \cdot \frac{\sec^2 x}{\sec^2 x} \, dx\\
&= \int \frac{\tan x}{(\tan x - 1)(1 + \tan^2 x)^2} \cdot \sec^2 x \, dx.
\end{align}
Now let $t = \tan x$. Doing so yields
\begin{align}
I &= \int \frac{t}{(t - 1)(1 + t^2)^2} \, dt\\
&= \int \left [\frac{1}{4(t - 1)} - \frac{t + 1}{4(t^2 + 1)} + \frac{1 - t}{2(1 + t^2)^2} \right ] \, dt\\
&= \frac{1}{4} \ln |t - 1| - \frac{1}{8} \ln |1 + t^2| + \frac{t}{4(1 + t^2)} + C\\
&= \frac{1}{4}\ln |\tan x - 1| + \frac{1}{4} \ln |\cos x| + \frac{1}{4} (1 + \tan x) \cos^2 x + C.
\end{align}
or after playing around with a few trignometric identities
$$\int \frac{\cos^2 x \sin x}{\sin x - \cos x} \, dx = \frac{1}{4} \ln |\sin x - \cos x| + \frac{1}{8} (\cos 2x + \sin 2x) + C.$$ 
</s>