Integrate : $\int \frac{x^2}{(x\cos x -\sin x)(x\sin x +\cos x)}dx$ 
$$\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.
 A: $\bf{Another \; Solution::}$ Let $\displaystyle I = \int\frac{x^2}{(x\sin x+\cos x)\cdot (x\cos x-\sin x)}dx$
Now $\displaystyle I = \int\frac{2x^2}{(x^2\sin 2x+2x\cos^2 x-2x\sin^2 x-\sin 2x)}dx$
So $\displaystyle I = \int\frac{2x^2}{(x^2-1)\sin 2x+2x\cos 2x}dx$
Now $\displaystyle (x^2-1)\sin 2x+2x\cos 2x = \sqrt{(x^2-1)^2+(2x)^2}\cdot \left\{\left(\frac{x^2-1}{x^2+1}\right)\sin 2x+\left(\frac{2x}{x^2+1}\right)\cos 2x\right\}$
Now We can write $\displaystyle (x^2-1)\sin 2x+2x\cos 2x = (x^2+1)\cdot \sin (2x+\alpha)$
Where $\displaystyle \displaystyle \left(\frac{x^2-1}{x^2+1}\right) = \cos \alpha$
 and $\displaystyle \left(\frac{2x}{x^2+1}\right)=\sin \alpha$ 
and so  $\displaystyle\tan \alpha = \left(\frac{2x}{x^2-1}\right)\Rightarrow \alpha = \tan^{-1}\left(\frac{2x}{x^2-1}\right)$
So Integral $\displaystyle I = \int \csc(2x+\alpha)\cdot \left(\frac{2x^2}{x^2+1}\right)dx$
Now let $\displaystyle (2x+\alpha) = t\Rightarrow \left\{2x+\tan^{-1}\left(\frac{2x}{x^2-1}\right)\right\} = t\;,$Then $\displaystyle \left(\frac{2x^2}{x^2+1}\right)dx=dt$
So Integral $\displaystyle I = \int \csc tdt = \ln \left|\tan \frac{t}{2}\right|+\mathcal{C} = \ln \left|\tan \left(x+\frac{\alpha}{2}\right)\right|+\mathcal{C} $
A: $\bf{My\; Solution::\; }$Let $\displaystyle I = \int\frac{x^2}{(x\sin x+\cos x)\cdot (x\cos x-\sin x)}dx$
Let $x=\tan \theta\;,$ Then $dx = \sec^2 \theta d\theta.\;\; $ Then  $$I = \displaystyle \int \frac{\tan^2 \theta\cdot \sec^2 \theta }{(\tan \theta\cdot \sin(\tan \theta)+\cos(\tan \theta) )\times (\tan \theta\cdot \cos(\tan \theta)-\sin(\tan \theta) )}d\theta$$
So $$\displaystyle I = \int\frac{\tan^2 \theta\cdot \sec^2 \theta\cdot \cos^2 \theta  }{(\sin  \theta\cdot \sin(\tan \theta)+\cos(\tan \theta)\cdot \cos \theta )\times (\sin \theta\cdot \cos(\tan \theta)-\sin(\tan \theta)\cdot \cos \theta )}d\theta$$
So $$\displaystyle I = \int\frac{2\tan^2 \theta}{2\cos(\theta-\tan \theta)\cdot \sin(\theta-\tan \theta)}d\theta = \int\frac{2\tan^2 \theta}{\sin (2\theta-2\tan \theta)}d\theta$$
Now Let $\displaystyle (2\theta-2\tan \theta) = u\;\;,$ Then $(2-2\sec^2 \theta)d\theta = du\Rightarrow 2\tan^2\theta d\theta = -du$
So $$\displaystyle I = -\int\frac{1}{\sin u}du = -\int \csc u du = -\ln \tan \left(\frac{u}{2}\right)+\mathbb{C}=-\ln \tan \left(\theta -\tan \theta\right)+\mathbb{C}$$
So $$\displaystyle I = \ln\left|\frac{\cos (\theta-\tan \theta)}{\sin (\theta-\tan \theta)}\right|+\mathbb{C} = \ln\left|\frac{\cos \theta \cdot \cos (\tan \theta)+\sin \theta \cdot \sin(\tan \theta)}{\sin \theta \cdot \cos (\tan \theta)-\cos \theta \cdot \sin(\tan \theta)}\right|+\mathbb{C}$$
So $$\displaystyle I = \ln\left|\frac{\sin (\tan \theta)\cdot \tan \theta+\cos(\tan \theta)}{\cos (\tan \theta)\cdot \tan \theta-\sin (\tan \theta)}\right|+\mathbb{C} = \ln \left|\frac{x\sin x+\cos x}{x\cos x-\sin x}\right|+\mathbb{C}$$
So $$\int\frac{x^2}{(x\sin x+\cos x)\cdot (x\cos x-\sin x)}dx=\ln \left|\frac{x\sin x+\cos x}{x\cos x-\sin x}\right|+\mathbb{C}$$
A: \begin{align}
I &= \int\frac{x^2dx}{(x\sin x+\cos x)(x\cos x-\sin x)} \\ &= -\int\frac{x^2dx}{(1+x^2)\left(\frac{x}{\sqrt{1+x^2}}\sin x+\frac{1}{\sqrt{1+x^2}}\cos x\right)\left(\frac{1}{\sqrt{1+x^2}}\sin x-\frac{x}{\sqrt{1+x^2}}\cos x\right)}\\
&=-\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}
A: HINT :
Rewrite the integrand
$$
\frac{x^2}{(x\cos x -\sin x)(x\sin x +\cos x)}
$$
as
$$
\frac{x\cos x}{x\sin x +\cos x}+\frac{x\sin x}{x\cos x -\sin x}
$$
then
$$
\frac{\color{red}{\sin x}+x\cos x-\color{red}{\sin x}}{x\sin x +\cos x}+\frac{\color{blue}{\cos x}+x\sin x-\color{blue}{\cos x}}{x\cos x -\sin x}.
$$
Now let $u=x\sin x +\cos x$ and $v=x\cos x -\sin x$.
A: $\displaystyle u=x\sin x+\cos x,v=x\cos x-\sin x \Rightarrow  \displaystyle du=x\cos xdx,dv=-x\sin xdx$
$\begin{align}\displaystyle\int\frac{x^{2}dx}{(x\sin x+\cos x)(x\cos x-\sin x)}&=\int\left(\frac{x\cos x}{x\sin x+\cos x}-\frac{-x\sin x}{x\cos x-\sin x}\right)dx\\&=\displaystyle\int\frac{du}{u}-\int\frac{dv}{v}\\&=\ln\left| \frac{u}{v} \right|+c\end{align}$
$\displaystyle\int\frac{x^{2}dx}{(x\sin x+\cos x)(x\cos x-\sin x)}=\ln\left| \frac{x\sin x+\cos x}{x\cos x-\sin x} \right|+c $
