Note that \(\displaystyle x \sin{x} + \cos{x} = \sqrt{x^2+1} \cos( x- \tan^{-1}(x) )\)

We have

\(\displaystyle = \int \frac{x^2}{ (x^2+1) \cos^2( x - \tan^{-1}(x) )}~dx \)

Sub. \(\displaystyle x - \tan^{-1}(x) = t \)

\(\displaystyle (1 - \frac{1}{x^2+1} )dx = dt \)

\(\displaystyle \frac{x^2}{x^2+1}~dx = dt \)

The integral becomes

\(\displaystyle \int \sec^2(t)~dt = \tan(t) + C \)

\(\displaystyle = \tan[ x - \tan^{-1}(x) ] + C \) or

\(\displaystyle = \frac{ \tan(x) - x }{ 1 + x\tan(x) } + C \)