Compute the indefinite integral $\displaystyle{\int\frac{x^2}{\tan{x}-x}dx, x \in (0, \frac{\pi}{2})}$.
I have tried substituting $\tan{x} = t$ or write $\tan{x} = \displaystyle{\frac{\sin{x}}{\cos{x}}}$ and then try to solve it from there, but I didn't manage to do it. Also, $\displaystyle{\left(\frac{\sin{x}}{x}\right)' = \frac{\sin{x} - x\cos{x}}{x^2}}$, but in the integral I have the inverse of this...
$$\int\frac{x^2}{\tan{x}-x}dx=\int\left(\frac{x^2}{\tan{x}-x}+x-x\right)dx=\int\frac{x\sin{x}}{\sin{x}-x\cos{x}}dx-\frac{x^2}{2}=$$ $$=\int\frac{d(\sin{x}-x\cos{x})}{\sin{x}-x\cos{x}}-\frac{x^2}{2}=\ln|\sin{x}-x\cos{x}|-\frac{x^2}{2}+C$$