Example 1. Find $\int\left(x^{2}-x+1\right) \cos 2 x d x$.
Solution. Here $P(x)=x^{2}-x+1$ is a polynomial of the second degree, which we take as $u$ and integrate by parts twice. The continuity of the solution will be ensured by the following presentation:

$$
\begin{gathered}
\int\left(x^{2}-x+1\right) \cos 2 x d x=\left\{\begin{array}{cc}
x^{2}-x+1=u, d u=(2 x-1) d x \\
\cos 2 x d x=d v, v=\int \cos 2 x d x=\frac{1}{2} \sin 2 x
\end{array}\right\}= \\
=\frac{x^{2}-x+1}{2} \sin 2 x-\frac{1}{2} \int(2 x-1) \sin 2 x d x= \\
=\left\{\begin{array}{rc}
2 x-1=u, & d u=2 d x \\
\sin 2 x d x=d v, & v=-\frac{\cos 2 x}{2}
\end{array}\right\}=
\end{gathered}
$$

$$
\begin{aligned}
& =\frac{x^{2}-x+1}{2} \sin 2 x-\frac{1}{2}\left(-\frac{2 x-1}{2} \cos 2 x+\int \cos 2 x d x\right)= \\
& =\frac{x^{2}-x+1}{2} \sin 2 x+\frac{2 x-1}{4} \cos 2 x-\frac{\sin 2 x}{4}+C= \\
& =\frac{2 x^{2}-2 x+1}{4} \sin 2 x+\frac{2 x-1}{4} \cos 2 x+C
\end{aligned}
$$

Integration by parts can be used to take integrals of inverse functions.