Example 4. Find $\int x^{2} \cos x d x$.
Solution. Setting

$$
u=x^{2}, d v=\cos x d x=d(\sin x)
$$

we get

$$
d u=2 x d x, v=\sin x
$$

Therefore,

$$
\int x^{2} \cos x d x=x^{2} \sin x-\int \sin x \cdot 2 x d x=x^{2} \sin x-2 \int x \sin x d x
$$

The obtained integral can again be found by integration by parts (Example 1). It can also be found without explicitly introducing $u$ and $v$. We have

$$
\begin{gathered}
\int x \sin x d x=\int x d(-\cos x)=x(-\cos x)-\int(-\cos x) d x= \\
=-x \cos x+\sin x+C_{1}
\end{gathered}
$$

Substituting this expression for the integral into formula (A), we find

$$
\begin{gathered}
\int x^{2} \cos x d x=x^{2} \sin x-2 \int x \sin x d x=x^{2} \sin x-2(-x \cos x+ \\
\left.+\sin x+C_{1}\right)=x^{2} \sin x+2(x \cos x-\sin x)+C
\end{gathered}
$$

where $C=-2 C_{1}$.