<s>[INST] How to integrate $ \int \frac{x^2}{(x \sin(x)+\cos(x))^2} \mathrm{d}x$ 
Evaluate
$$\displaystyle \int \frac{x^2}{(x \sin(x)+\cos(x))^2} \mathrm{d}x$$

Can someone just tell me the necessary manipulations? Hints will be enough.
Can it be done by integration by parts?
 [/INST] $\bf{My\; Solution::}$Given $$\displaystyle \int \frac{x^2}{\left(x \cdot \sin x+\cos x \right)^2}\mathrm{d}x$$
Now we can write $$\displaystyle x\cdot \sin x+1\cdot \cos x  = \sqrt{1+x^2}\cdot \left(\sin x\cdot \frac{x}{\sqrt{1+x^2}}+\cos x\cdot \frac{1}{\sqrt{1+x^2}}\right)$$
$$\displaystyle =\sqrt{1+x^2}\cdot \cos \left(x-\phi\right).$$
Where $\displaystyle \sin \phi = \frac{x}{\sqrt{1+x^2}}$ and $\displaystyle \cos \phi = \frac{1}{\sqrt{1+x^2}}$ and $\displaystyle \tan \phi = x\Rightarrow \phi = \tan^{-1}(x).$
So our Integral now becomes $$\displaystyle  = \int\frac{x^2}{1+x^2}\cdot \sec^2 (x-\phi)\mathrm{d}x$$.
Now Let $$(x-\tan^{-1}(x))=t\;,$$ Then $$\displaystyle \frac{x^2}{1+x^2}\mathrm{d}x = \mathrm{d}\phi.$$
So Integral Convert into $$\displaystyle \int \sec^2 t \ \mathrm{d}t  = \tan t +\mathcal{C} = \tan \left(x-\tan^{-1}(x)\right)+\mathcal{C}$$.
$$\displaystyle = \frac{\tan x-x}{1+x\cdot \tan x}+\mathcal{C}=\frac{\sin x-x \cdot \cos x}{\cos x+x\cdot \sin x}+\mathcal{C}$$
So $$\displaystyle \int \frac{x^2}{(x\sin x+\cos x)^2}\mathrm{d}x = \frac{\sin x-x \cdot \cos x}{\cos x+x\cdot \sin x}+\mathcal{C}$$
</s>