So it is estabilished that for definite integrals, the following holds: $$\int_a^b f(g(x))g'(x)dx = \int_{g(a)}^{g(b)} f(u)du$$ given $ u=g(x)$. However, when calculating the expectation of a standard normal distribution I have noticed that the bounds BOTH get mapped to $-\infty$, given $u={-1 \over 2}x^2$: $$ 0=\int_{-\infty}^{\infty} xe^{-{1\over2} x^2} =\int_{-g(\infty)}^{g(\infty)} -e^{u} du = \int_{-\infty}^{-\infty} -e^{u} du = -|e^u|_{-\infty}^{-\infty} = -|0-0| =0$$
I feel like the fact that this result is correct is a pure coincidence. For me it doesn't really make sense to integrate over an "infinitely negative point", especially if the range of values of $u$ is $(-\infty, 0]$, so I would expect the whole range to be covered by the integral, while only $-\infty$ is covered.
Can someone provide an answer if this is generally correct or not, if not, is it even possible to change the integration bounds when I have an improper integral, or should I just use an indefinite integral and convert back to the original variable?
Notice that you can part the domain at $x=0$, so
$$\begin{align}\int_{-\infty}^\infty x\mathrm e^{-x^2/2}\,\mathrm d x &= \int_{-\infty}^0 x\mathrm e^{-x^2/2}\,\mathrm d x+ \int^{\infty}_0 x\mathrm e^{-x^2/2}\,\mathrm d x\\&~~\vdots\\ &= (1-0)+(0-1)\end{align}$$