How to calculate $\int{\frac {x^2}{ ( x\cos x -\sin x ) ^2}}\,{\rm d}x$?

When I want to calculate $$\int{\frac {x^2}{ ( x\cos x -\sin x ) ^2}}\,{\rm d}x$$ I have tested with software and get $${\frac {x\sin \left( x \right) +\cos \left( x \right) }{x\cos \left( x \right) -\sin \left( x \right) }}$$

But I can not come to this conclusion, neither using integration by parts, nor using trigonometric identities, nor multiplying by their conjugate, Even by rational trigonometric substitution. I do not know what else to try. Could you give me any suggestions?


Solution 1:

We can rewrite $$\begin{align}\int \frac{x^2}{(\sin x - x\cos x)^2} \, \mathrm{d}x &= \int \frac{x\sin x(x\sin x + \cos x)}{(\sin x - x\cos x)^2} \, \mathrm{d}x - \int \frac{x\cos x}{\sin x - x\cos x} \, \mathrm{d}x \\ & = -\frac{x\sin x + \cos x}{\sin x - x\cos x} \color{green}{+} \int \frac{x\cos x}{\sin x- x\cos x} \, \mathrm{d}x \color{red}{-} \int \frac{x\cos x}{\sin x - x\cos x} \, \mathrm{d}x \\ & = -\frac{x\sin x + \cos x}{\sin x - x\cos x}\end{align}$$

via IBP with $u = x\sin x + \cos x \implies u' = x\cos x$ and $$\mathrm{d}v = \frac{x\sin x}{(\sin x - x\cos x)^2} \implies v = -\frac{1}{\sin x -x\cos x}$$ via straightforward $f = \sin x - x\cos x \implies f' = x\sin x$ sub.