I have seen a proof of the variance of a standard normal distribution, but am getting an incorrect answer am and not sure why. Here is my reasoning.
$$\mathbb{V}[X] = \mathbb{E}[X^2] - \mathbb{E}[X]^2 = \mathbb{E}[X^2]$$
$$ \mathbb{E}[X^2] = \frac{1}{\sqrt(2\pi)}\int_{-\inf}^{+inf} x^2 e^{-\frac{x^2}{2}} dx$$
Then do integration by parts and let $u=x^2$ and $dv = e^{-\frac{x^2}{2}}$ (In the proof I have seen, you choose $u=x$ and $dv = x e^{-\frac{x}{2}}$ and this makes sense to me and works out... )
Then
$$ \frac{du}{dx} = 2x$$
and $$ v = \sqrt(2 \pi)$$
as this is just the integral over the standard normal. Then the integral becomes
$$ \mathbb{E}[X^2] =\frac{1}{\sqrt(2\pi)} \int_{-\inf}^{+inf} x^2 e^{-\frac{x^2}{2}} dx = \frac{1}{\sqrt(2\pi)} \left( x^2|_{-inf}^{inf} \sqrt(2 \pi) \ - \sqrt(2 \pi)\int_{-\inf}^{+inf} 2x dx\right ) = \left( x^2 - x^2\right)|_{-inf}^{inf} = 0$$
but this is oviously incorrect. Im sure I have just a stupid error but can't seem to find it.
Better way to solve that integral if you are familiar with gamma integrals. Are you? $\dfrac{1}{\sqrt{2 \pi}}\int_{-\infty}^{\infty}x^2e^{\frac{-x^2}{2}}dx=\dfrac{2}{\sqrt{2 \pi}}\int_{0}^{\infty}x^2e^{\frac{-x^2}{2}}dx \because(\text{Even function})=\frac{2}{\sqrt{2 \pi}} \cdot \frac{\frac{\sqrt{\pi}}{2}}{\frac{1}{\sqrt{2}}}=1$