Assume, $f(x) = \left( {{x^2} + 1} \right)\cos x$.
Upon differentiating with respect to $x$ and applying quotient rule we get,
${f^\prime }(x) = \left( {{x^2} + 1} \right)\frac{d}{{dx}}(\cos x) + \cos x\frac{d}{{dx}}\left( {{x^2} + 1} \right)$
$f'(x) = \left( {{x^2} + 1} \right)( – \sin x) + \cos x(2x)$
Therefore, $f'(x) = – {x^2}\sin x – \sin x + 2x\cos x$.