Let us consider the integral
$$\int \frac{x^2}{(x\sin x+\cos x)^2}\, dx$$
I have tried with the following way
$\displaystyle \int \frac{x^2}{(x\sin x+\cos x)^2}\, dx$
$\displaystyle \Rightarrow \int \frac{x^2\sec^2 x}{(x\tan x+1)^2}\, dx$.
How can I do the next step.
Let $$\displaystyle I = \int\frac{x^2}{(x\sin x+\cos x)^2}dx$$
We can write
$$\displaystyle (x\sin x+\cos x) = \sqrt{1+x^2}\left\{\frac{x}{\sqrt{1+x^2}}\cdot \sin x+\frac{1}{\sqrt{1+x^2}}\cdot \cos x\right\} = \sqrt{1+x^2}\cdot \cos \left(x-\phi \right)$$
So Here $$\displaystyle \cos x\ \phi = \frac{1}{\sqrt{1+x^2}}$$ and $\displaystyle \sin \phi = \frac{x}{\sqrt{1+x^2}}$ and $\tan \phi = x\Rightarrow \phi = \tan^{-1}(x)$
So Integral
$$\displaystyle I = \int\frac{x^2}{(1+x^2)\cdot \cos^2(x-\phi)}dx = \int \sec^2 (x-\phi)\cdot \frac{x^2}{1+x^2} dx = \int \sec^2 (x-\tan^{-1}(x))\cdot \frac{x^2}{(1+x^2)}dx$$
Now Let $$\left(x-\tan^{-1}x\right) = t\;,$$ Then $\displaystyle \left(1-\frac{1}{1+x^2}\right)dx = dt\Rightarrow \frac{x^2}{1+x^2}dx = dt$
So $$\displaystyle I = \int \sec^2 t dt = \tan t +\mathcal {C} = \tan \left(x-\tan^{-1} x\right)+\mathcal{C} = \left(\frac{\tan x-x}{1+x\cdot \tan x}\right)+\mathcal{C}$$
So $$\displaystyle I = \int\frac{x^2}{(x\sin x+\cos x)^2}dx = \left(\frac{\sin x- x\cos x}{\cos x+x\sin x}\right)+\mathcal{C}$$