<s>[INST] Interesting integral $\int_{0}^{\frac{\pi}{4}} \frac{x^{2}}{(x \sin x+\cos x)^{2}} d x$? Noting that
$\displaystyle d(x \sin x+\cos x)=x \cos xdx,\tag*{} $
we have
$\displaystyle \int_{0}^{\frac{\pi}{4}} \frac{x^{2}}{(x \sin x+\cos x)^{2}} d x=-\int_{0}^{\frac{\pi}{4}} \frac{x}{\cos x} d\left(\frac{1}{x \sin x+\cos x}\right)\tag*{} $
Integration by parts gives
$\displaystyle \begin{aligned}I &=-\left[\frac{x}{\cos x(x \sin x+\cos x)}\right]_{0}^{\frac{\pi}{4}}+\int_{0}^{\frac{\pi}{4}} \frac{\cos x+x \sin x}{\cos ^{2} x} \cdot \frac{1}{x \sin x+\cos x} d x \\&=-\frac{\frac{\pi}{4}}{\frac{1}{\sqrt{2}}\left(\frac{\pi}{4} \cdot \frac{1}{\sqrt{2}}+\frac{1}{\sqrt{2}}\right)}+\int_{0}^{\frac{\pi}{4}} \sec ^{2} x d x \\&=-\frac{2 \pi}{\pi+4}+[\tan x]_{0}^{\frac{\pi}{4}} \\&=\frac{4-\pi}{4+\pi}\end{aligned}\tag*{} $
Is there any other method?
 [/INST] \begin{align}
&\int_{0}^{\frac{\pi}{4}} \frac{x^{2}}{(x \sin x+\cos x)^{2}} d x\\
=& \int_{0}^{\frac{\pi}{4}} \frac{x^{2}\sec^2x}{(1+x \tan x)^{2}} d x
= \int_{0}^{\frac{\pi}{4}}
\frac{1}{(1+x \tan x)^{2}}+ \frac{x^{2}\sec^2x -1}{(1+x \tan x)^{2}} \ d x\\
=& \ \left( \frac1{x+\cot x} - \frac{x}{1+x\tan x}\right)_0^{\frac\pi4}= \frac{4-\pi}{4+\pi}
\end{align}
</s>