Variance as Expectation of Square minus Square of Expectation/Continuous

Theorem
Let $X$ be a continuous random variable.

Then the variance of $X$ can be expressed as:
 * $\operatorname{var} \left({X}\right) = \mathbb E \left[{X^2}\right] - \left({\mathbb E \left[{X}\right]}\right)^2$

That is, it is the expectation of the square of $X$ minus the square of the expectation of $X$.

Proof
Let $\mu = \mathbb E\left[{X}\right]$.

Let $X$ have probability density function $f_X$.

As $f_X$ is a probability density function, we have:


 * $\displaystyle \int_{-\infty}^\infty f_X \left({x}\right) \rd x = \operatorname{Pr} \left({-\infty < X < \infty}\right) = 1$

Then: