TITLE: Evaluate $\int x^2e^{\frac{x^2}2} \, dx$
QUESTION [5 upvotes]: $$\int x^2e^{\frac{x^2}2} \, dx$$

I do not need to evaluate $\int e^{\frac{x^2}{2}}$ in a numeric method.
If we take $u=x^2, u'=2x$  $v'=e^{\frac{x^2}{2}},v=\int e^{\frac{x^2}2}\,dx$
we get:
$$\int x^2e^{\frac{x^2}{2}} \, dx = x^2\int e^{\frac{x^2}{2}} \,dx-2\int \left( x \int e^{\frac{x^2}2} \,dx\right) dx\text{?}$$
How can the solution be $\displaystyle xe^{\frac{x^2}2}-\int e^{\frac{x^2}{2}}dx$?

REPLY [5 votes]: $$
\int x^2 e^{x^2/2} \,dx = \int x\left( xe^{x^2/2} \,dx \right) = \overbrace{\int x \,dv = xv - \int v\,dx}^\text{integration by parts} = \cdots\cdots
$$
You have $dv = xe^{x^2/2}\,dx$ and $v= e^{x^2/2}.$
This will not get you a closed form, but I take the question to mean: How do we use integration by parts to reach $\displaystyle xe^{x^2/2}-\int e^{x^2/2} \, dx \text{?}$
This is a bit subtler than elementary exercises in integration by parts usually are. The way I got the answer is by starting with the given answer and differentiating, and seeing how it fits into the usual pattern that you see when you check the answers to integration-by-parts exercises.