Evaluating this integral $ \small\int \frac {x^2 dx} {(x\sin x+\cos x)^2} $ The question: 

Compute$$
\int \frac {x^2 \, \operatorname{d}\!x} {(x\sin x+\cos x)^2}
$$

Tried integration by parts. That didn't work.
How do I proceed?

$$\text{Observe that, }\frac{d(x\sin x+\cos x)}{dx}=x\cos x$$
$$ \int \frac {x^2 \, \operatorname{d}\!x} {(x\sin x+\cos x)^2} =\int \frac x{\cos x}\cdot \frac{x\cos x}{(x\sin x+\cos x)^2}dx$$
So, if $z=x\sin x+\cos x, dz=x\cos xdx$
So, $\int \frac{x\cos x}{(x\sin x+\sin x)^2}dx=\int \frac{dz}{z^2}=-\frac1z=-\frac1{x\sin x+\cos x}$
So, $$I=\frac x{\cos x}\int \frac{x\cos x}{(x\sin x+\cos x)^2}dx-\int \left(\frac{d(\frac x{\cos x})}{dx}\int \frac{x\cos x}{(x\sin x+\cos x)^2}dx\right)dx$$
$$=-\frac x{\cos x(x\sin x+\cos x)}+\int \left(\frac{x\sin x+\cos x}{\cos^2x}\right)\left(\frac1{x\sin x+\cos x} \right)dx$$
$$=-\frac x{\cos x(x\sin x+\cos x)}+\int\sec^2xdx$$
$$=-\frac x{\cos x(x\sin x+\cos x)}+\tan x+C$$ where $C$ is an arbitrary constant of indefinite integral  
$$\text{Another form will be  } \frac{\sin x-x\cos x}{x\sin x+\cos x}+C$$
