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$$


I was inspired by this post to conduct this method.

$$\int\frac{x^2}{(x\sin x+\cos x)^2}\mathrm{d}x $$

The Harmonic Addition Theorem comes in handy, so $x \sin x + \cos x = \sqrt{1+x^2} \cos(x-\alpha)$ where $\alpha = \arctan(x)$.

The origin integration becomes:

$$\int \frac{x^2}{1+x^2} \sec^2(x-\alpha) \mathrm{d}x $$

Notice that $\int \frac{x^2}{1+x^2} dx = x - \arctan x = x-\alpha $.

So let $t = x-\alpha$ then $dt = \frac{x^2}{1+x^2} dx$ and the integration simplifies as:

$$ \int \sec^2(t) dt = \tan(t) = \tan(x - \arctan x)$$.

In conclusion, $$\int\frac{x^2}{(x\sin x+\cos x)^2}\mathrm{d}x =\tan(x - \arctan x)+C$$


Differentiation of $$x\sin x+\cos x \space \text {is}\space x\cos x $$ \begin{align}\int\underbrace {\frac{x \cos x}{(x\sin x+\cos x)^2}}_{\text {II}}\cdot\underbrace {\frac {x}{(\cos x)}}_{\text {I}}{d}x\end{align} Now integrate by parts. $$I=\frac{-1}{(x\sin x+\cos x)}.\frac {x}{(\cos x)} +\int\frac{1}{(x\sin x+\cos x)}.\frac{\cos x.1 -x(-\sin x)}{\cos^2 x} $$ Now, I hope things are clear to you.


$$\int\frac{x^2}{(x\sin x+\cos x)^2}\mathrm{d}x = \int (x\sec x)\frac{x^2}{(x\sin x+\cos x)^2}\mathrm{d}x$$ Take $xsecx$ as first functions and apply integreation by parts. there you go boom!!