Primitive of $\int { \frac { x^{ 2 } }{ (x\sin x+\cos x)^{ 2 } } dx } $ How do I evaluate the integral of $$\int { \frac { x^{ 2 } }{ (x\sin  x+\cos  x)^{ 2 } } dx } $$ in a simple way?
The way I could do the question, was by multiplying and dividing the fraction by $\cos x$ - and it was my professor who gave that clue. 
Is there an alternate way to solve this? And, if I were facing this question for the first time in an exam, how could I tackle it?
 A: Here's an alternative approach:
If you see an integral which is made of a fraction with a squared term in the denominator and you have serious hopes that the integral is elementary then you might think of the quotient rule.
Note that this tells you that
$\int \frac{u'v-uv'}{v^2} dx=\frac{u}{v}+C$.
So in this case you clearly have $v(x)=x\sin x+\cos x$ and you want to solve the following (differential) equation for $u$:
$$x^2=(x\sin x+\cos x)u'-ux\cos x$$
Now using standard undetermined coefficients, it's reasonable to attempt a solution of the form $u(x)=(Ax+B)\sin x+(Cx+D)\cos x$.
Plugging this into the DE and comparing coefficients you obtain $B=0, C=-1$ and $A=D$. So the easiest solution is $u(x)=\sin x-x\cos x$ and so you obtain
$$\int \frac{x^2}{(x\sin x+\cos x)^2}=\frac{\sin x-x\cos x}{x\sin x+\cos x}+C$$
A: Let $$\displaystyle I = \int \frac{x^2}{(x\sin x+\cos x)^2}dx$$
Put $x=\tan \phi\;,$ Then $dx = \sec^2 \phi d\phi$
So Integral $$\displaystyle I = \int\frac{\tan^2 \phi \cdot \sec^2 \phi}{\left[\tan \phi\cdot \sin (\tan \phi)+\cos(\tan \phi)\vphantom{\frac11}\right]^2}d\phi $$
So $$\displaystyle I = \int\frac{\tan ^2\phi \cdot \sec^2 \phi\cdot \cos^2 \phi}{\left[\sin \phi\cdot \sin (\tan \phi)+\cos \phi\cos(\tan \phi)\vphantom{\frac11}\right]^2}d\phi$$
So we got $$\displaystyle I = \int\frac{\tan^2 \phi }{\left[\cos\left(\tan \phi-\phi\right)\vphantom{\frac11}\right]^2}d\phi$$
Now Put $(\tan\phi-\phi) = t\;,$ Then $(\sec^2 \phi-1)d\phi = dt\Rightarrow \tan^2 \phi d\phi = dt$
So Integral $$\displaystyle I = \int\frac{1}{\cos^2 t}dt = \int\sec^2t dt = \tan t+\mathcal{C}=\tan(\tan \phi-\phi)+\mathcal{C}$$
So Integral $$\displaystyle I = \tan (x-\tan^{-1}x)+\mathcal{C} = \frac{\tan x-x}{1+\tan x\cdot x}+\mathcal{C} = \left[\frac{\sin x-x\cdot \cos x}{\cos x+x\cdot \sin x}\vphantom{\frac11}\right]+\mathcal{C}$$
A: You could use that $(x\sin x+\cos x)^{\prime}=x\cos x$ to try integrating by parts with 
$\displaystyle u=x\sec x, \;\;dv=\frac{x\cos x}{(x\sin x+\cos x)^2}dx$  and 
$\displaystyle du=\sec x(x\tan x+1)dx, \;\;v=-\frac{1}{x\sin x+\cos x}$ to get
$\displaystyle\int\frac{x^2}{(x\sin x+\cos x)^2}dx=-\frac{x\sec x}{x\sin x+\cos x}+\int\frac{\sec x(x\tan x+1)}{x\sin x+\cos x}dx$
$\displaystyle=-\frac{x\sec x}{x\sin x+\cos x}+\int\sec^2 x dx=-\frac{x\sec x}{x\sin x+\cos x}+\tan x+C$
