Example 5. Calculate the integral $\int_{0}^{2}\left(x^{2}+x-1\right) e^{x / 2} d x$.
Solution. Integrate by parts twice.

$$
\begin{gathered}
\int_{0}^{2}\left(x^{2}+x-1\right) e^{x / 2} d x=\left\{\begin{array}{cc}
x^{2}+x-1=u, & d u=(2 x+1) d x \\
e^{x / 2} d x=d v, & v=2 e^{x / 2}
\end{array}\right\}= \\
=\left.2\left(x^{2}+x-1\right) e^{x / 2}\right|_{0} ^{2}-2 \int_{0}^{2}(2 x+1) e^{x / 2} d x=
\end{gathered}
$$

$$
=\left\{\begin{aligned}
2 x+1=u, & d u=2 d x \\
e^{x / 2} d x=d v, & v=2 e^{x / 2}
\end{aligned}\right\}=
$$

$$
\begin{aligned}
& =2 \cdot 5 \cdot e-2(-1)-2\left[\left.2(2 x+1) e^{x / 2}\right|_{0} ^{2}-4 \int_{0}^{2} e^{x / 2} d x\right]= \\
& =10 e+2-2\left(2 \cdot 5 e-2-\left.8 e^{x / 2}\right|_{0} ^{2}\right)=6 e-10
\end{aligned}
$$

Answer. $2(3 e-5)$