What is $\;\int xe^{-x^2} \,dx\;?$ What is $$\int xe^{-x^2} dx\quad?$$
I used substitution to rewrite it as $$\int -\dfrac{1}{2}e^u\, du$$ but this is too hard for me to evaluate. When I used wolfram alpha for $\int e^{-x^2} dx$ I got a weird answer involving a so called error function and pi and such (I'm guessing it has something to do with Euler's identity, but I'm fairly certain this is above my textbook's level).
 A: Let $u = -x^2$. It follows that $du = -2xdx$. So then
$$\int xe^{-x^2}dx = -\frac{1}{2}\int -2xe^{-x^2}dx = -\frac{1}{2}\int e^udu = -\frac{1}{2}e^u + C = -\frac{1}{2}e^{-x^2} + C.$$
A: The problem is to find
$$\int xe^{-x^2}\,dx.$$
So we are trying to find the functions $F(x)$ such that
$$F'(x)=xe^{-x^2}.$$
We can easily verify, by differentiating, that $F(x)=-\frac{1}{2}{e^{-x^2}}$ "works," and therefore the general $F(x)$ such that $F'(x)=xe^{-x^2}$ is given by $F(x)=-\frac{1}{2}e^{-x^2}+C$. 
The problem of finding a function $G(x)$ such that $G'(x)=e^{-x^2}$ is entirely different, even though the two functions $xe^{-x^2}$ and $e^{-x^2}$ are closely related. It turns out that there is no elementary function whose derivative is $e^{-x^2}$. Roughly speaking, an elementary function is a function built up from the familiar functions by using addition, subtraction, multiplication, division, and composition (substitution). 
So $xe^{-x^2}$ and $e^{-x^2}$ are elementary functions. The first has an elementary indefinite integral. The second doesn't. The second function is very important for many applications. There is a function whose derivative is $e^{-x^2}$, and that function is useful. It just happens not to be an elementary function. 
Because the function $e^{-x^2}$ is so important, an antiderivative of a closely related function has been given a name, the error function, often written as $\operatorname{erf}(x)$. That is what Alpha was talking about. If you ever study probability or statistics, you will become deeply familiar with the error function. 
Back to our problem! We are trying to integrate $xe^{-x^2}$. We already did that earlier, by a "guess and check" method. But that is not entirely satisfactory, so we now use a standard method, substitution. 
As in your post, let $u=-x^2$. Then $du=-2x\,dx$, so $x\,dx=-\frac{1}{2}\,du$. Substitute. We get
$$\int xe^{-x^2}\,dx=\int -\frac{1}{2} e^u\,du=-\frac{1}{2}e^u+C=-\frac{1}{2}e^{-x^2}+C.$$
Finding $\int e^u\,du$ was easy. We know that the derivative of $e^t$ with respect to $t$ is $e^t$, so $\int e^t\,dt=e^t+C$. 
Try the following closely related problems.
$1.$ Find $\int  e^{5x+17}\,dx$.
$2.$ Find $\int (\cos x)e^{\sin x}\,dx$. 
A: Your substitution was spot on. You put $$u = -x^2 \implies du = -2x\;dx \implies x\,dx = -\frac 12\, du$$
And having substituted, you obtained $$\int -\dfrac{1}{2}e^u\, du$$
Great work. But I think you gave up too early!: $$-\frac 12\int e^u \, du = -\frac 12 e^u + C,\tag{1}$$ and recall, $u = f(x), \;du = f'(x)\,dx$, so $(1)$ is equivalent to $$-\frac 12 \int e^{f(x)}\,f'(x)\,dx = -\frac 12 e^{f(x)} + C$$

So we can integrate as follows, and then back-substitute: 
 $$\int -\dfrac{1}{2}e^u\, du = -\frac 12 \int e^u \,du = -\frac 12 e^u + C = -\frac 12 e^{-x^2} + C\tag{2}$$
Now, to remove all doubts, simply differentiate the result given by $(2)$: $$\frac{d}{dx}\left(-\frac 12 e^{-x^2} + C\right) = -\frac 12(-2x)e^{-x^2} = xe^{-x^2}$$
which is what you set out to integrate: $\color{blue}{\bf x}e^{-x^2} \neq e^{-x^2}$
