Evaluating integral by parts Evaluate the following integral.
$$ \int^{1}_{-1} (e^x+x)^2 \ dx $$
Do i expand it like this $ \int^{1}_{-1} e^{2x} + 2xe^x+x^2 \ dx $
or make it like this $ \int^{1}_{-1} (e^x+x) (e^x+x) \ dx $
and what can i do next ?
 A: Only the middle term in the expansion needs to be done by parts:
\begin{align}
\int x\Big(e^x \, dx\Big) = \int x\,dv & = xv - \int v\,dx \\[12pt]
& = xe^x - \int e^x\,dx \\[12pt]
& = xe^x - e^x+C
\end{align}
A: You can expand it and integrate. I will show how I would do this step by step.
$$\int(e^x+x)^2 \ dx$$
$$=\int e^{2x}+2xe^x+x^2 \ dx$$
$$=\int e^{2x} \ dx + \int 2xe^x \ dx + \int x^2 \ dx$$
Lets work on each integral one by one. Lets start with $\displaystyle \int e^{2x} \ dx$. We will use u-substitution for this one.
$$\int e^{2x} \ dx$$
$$u = 2x$$
$$du = 2 \ dx$$
$$\int e^{2x} \ dx$$
$$=\int \frac{e^u}{2} \ du$$
$$=\frac{1}{2}\int e^u \ du$$
$$=\frac{1}{2}e^u + C$$
$$=\frac{e^u}{2} + C$$
$$=\frac{e^{2x}}{2} + C$$
Now lets work on $\displaystyle \int 2xe^x \ dx$. This will use integration by parts.
$$\int 2xe^x \ dx$$
$$u = 2x$$
$$dv = e^x$$
$$v = e^x$$
$$du = 2$$
$$\int 2xe^x \ dx$$
$$=2xe^x - \int 2e^x \ dx$$
$$=2xe^x - 2\int e^x \ dx$$
$$=2xe^x - 2e^x + C$$
Now the final integral, $\displaystyle \int x^2 \ dx$, is easy. Just use power rule.
$$\int x^2 \ dx = \frac{x^3}{3} + C$$
So:
$$\int (e^x + x)^2 \ dx = \frac{e^{2x}}{2} + 2xe^x - 2e^x + \frac{x^3}{3} + C$$
You should know what to do from here. Good luck!
