Proving $\operatorname{Var}(X) = E[X^2] - (E[X])^2$ I want to understand something about the derivation of $\text{Var}(X) = E[X^2] - (E[X])^2$
Variance is defined as the expected squared difference between a random variable and the mean (expected value): $\text{Var}(X) = E[(X - \mu)^2]$
Then:
$\operatorname{Var}(X) = E[(X - \mu)^2]$
$\operatorname{Var}(X) = E[(X - E[X])^2]$
$\operatorname{Var}(X) = E[(X - E[X])(X - E[X])]$
$\operatorname{Var}(X) = E[X^2 - 2XE[X] + (E[X])^2]$
$\operatorname{Var}(X) = E[X^2] - 2E[XE[X]] + E[(E[X])^2]$
$\operatorname{Var}(X) = E[X^2] - 2E[E[X]E[X]] + E[(E[X])^2]$
$\operatorname{Var}(X) = E[X^2] - 2(E[X])^2 + (E[X])^2$
$\operatorname{Var}(X) = E[X^2] - (E[X])^2$
What I don't quite understand is the steps that get us from $E[XE[X]]$ to $E[E[X]E[X]]$ to $(E[X])^2$, also $E[(E[X])^2]$ to $(E[X])^2$.
While I'm sure these jumps are intuitive and obvious I would still like to understand how we can (more formally) make these jumps / consider them mathematically equivalent.
 A: $\newcommand{\E}{\operatorname{E}}$It should not have been written as
$$
\E[X\E[X]] = \E[\E[X]\E[X]].
$$
Instead, it should have said
$$
\E[X\E[X]] = \E[X] \E[X].
$$
The justification is this:
$$
\E[X\cdot5] = 5\E[X],
$$
and similarly for any other constant besides $5$.  And in this context, "constant" means "not random". So just treat $\E[X]$ the same way you treat $5$, because it's a constant.
A: We start from the fundamental definition:
$$Var(X)=E[(x-\mu)^2]$$
$$Var(X)=E[x^2-2\mu x+\mu^2]$$
$$Var(X)=E[x^2]-E[\mu(2x-\mu)]$$
Because mu is just a constant, we can take it out.
$$Var(X)=E[x^2]-\mu*E[2x-\mu]$$
$$Var(X)=E[x^2]-\mu*(E[2x]-E[\mu])$$
$$Var(X)=E[x^2]-u*(2u-u)$$
$$Var(X)=E[x^2]-u*u$$
After Everything, we derive the end result:
$$Var(X)=E[x^2]-E[x]^2$$
A: For those interested in a different type of proof:
Suppose we sampled some data $X = x_1, x_2, ..., x_n$ from some Gaussian distribution. Then our sample mean which I will denote as $E[X]$ is:
$
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~E[X] = \frac{1}{m}\sum_1^m x_i^2
$
Our sample variance is  // I'm assuming you are familiar with your variance equation :) 
$
~~~~\frac{1}{m}\sum_1^m (x_i-E[X])^2 
\\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= \frac{1}{m}\sum_1^m (x_i^2-2x_iE[X] + E[X]^2)
\\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= \frac{1}{m}\sum_1^m (x_i^2)- 2E[X]\frac{1}{m}\sum_1^m (x_i) + \frac{1}{m}\sum_1^m(E[X]^2)
\\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=E[X^2] - 2E[X]^2+E[X]^2
\\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=E[X^2]-E[X]^2
$
