Evaluate integral

How do I evaluate the following integral, the answer according to Wolfram Alpha is $2$, but I keep on getting $0$ after using integration by parts.$$\frac12\int_{-\infty}^\infty x^2e^{-|x|}\ dx$$

• Split the integral for the region $-\infty<x<0\$ and $\ 0<x<\infty$. – Tunk-Fey Jun 10 '14 at 11:13
• It equals $\int_{0}^{\infty}x^{2}e^{-x}dx=\Gamma\left(3\right)=2$ because of symmetry. – drhab Jun 10 '14 at 11:14
• @Tunk-Fey That's probably not the asker's issue, since he/she is getting 0 as a result. – Ataraxia Jun 10 '14 at 11:15

$$\frac12\int_{-\infty}^\infty x^2e^{-|x|}dx = \frac12\int_{-\infty}^0x^2e^{x}dx +\frac12\int_{0}^\infty x^2e^{-x}dx \\ = \int_{0}^\infty x^2e^{-x}dx = [x^2(-e^{-x})]_{0}^\infty + 2\int_{0}^\infty xe^{-x} dx \\ =0+ 2[x(-e^{-x})]_{0}^\infty + 2\int_{0}^\infty e^{-x}dx = 0+0+2[(-e^{-x})]_{0}^\infty =2$$
Hint: By parity, $$\frac12\int_{-\infty}^\infty x^2e^{-\vert x \rvert}dx = \int_{0}^\infty x^2e^{- x }dx$$ Then, use integration by parts, now that there is no absolute values to cause trouble.
It cannot be zero, as your function (which happens to be the second raw moment of a Laplace distribution, incidentally) is always positive (except at $0$).
Hint : $$\int_{-\infty}^\infty x^2e^{-|x|}\ dx=\int_{-\infty}^0 x^2e^{x}\ dx+\int_{0}^\infty x^2e^{-x}\ dx=2\int_{0}^\infty x^2e^{-x}\ dx.$$