TITLE: Integrate : $\int \frac{x^2}{(x\cos x -\sin x)(x\sin x +\cos x)}dx$
QUESTION [19 upvotes]: $$\int \frac{x^2}{(x\cos x -\sin x)(x\sin x +\cos x)}\ dx$$

My approach : 
Dividing the denominator by $\cos^2x$ we get $\dfrac{x^2\sec^2x }{(x -\tan x)(x\tan x +1)}$ then
$$\int \frac{x^2\sec^2x}{x^2\tan x -x\tan^2x+x-\tan x}\ dx=\int \frac{x^2(1+\tan^2x)}{x^2\tan x -x\tan^2x+x-\tan x}dx$$
But I am not getting any relation between numerator and denominator so that I will take any substitution and solve further please suggest whether it is correct and how to proceed in this. Thanks.

REPLY [3 votes]: \begin{align}
I=\int\frac{x^2dx}{(x\sin x+\cos x)(x\cos x-\sin x)}&=-\int\frac{x^2dx}{(1+x^2)(\frac{x}{\sqrt{1+x^2}}\sin x+\frac{1}{\sqrt{1+x^2}}\cos x)(\frac{1}{\sqrt{1+x^2}}\sin x-\frac{x}{\sqrt{1+x^2}}\cos x)}\\
&=-\int\frac{\left(1-\frac{1}{1+x^2}\right)dx}{\cos (x-\arctan x)\sin (x-\arctan x)}\\
&=-\int\frac{d(x-\arctan x)}{\cos (x-\arctan x)\sin (x-\arctan x)}\\
&=-\int\frac{d(2(x-\arctan x))}{\sin (2(x-\arctan x))}\\
&=-\ln|\tan (x-\arctan x)|+C\\
\end{align}