# Expectation question

Since $E(X-\mu)^2=Var(X)$, expanding both sides we get $E(X^2-2X\mu+\mu^2)=E(X^2)-[E(2X\mu)-E(\mu^2)]=E(X^2)-[E(X)]^2$.

How is $E(2X\mu)-E(\mu^2)=[E(X)]^2$? What is $E(\mu)$ and $E(\mu^2)$?

Observe that $E2X\mu = 2 \mu E X = 2 \mu^2$, so that $E2 X \mu - E\mu^2 = 2\mu^2 - \mu^2 = \mu^2$
Here $\mathbb E(\mu)$ must be looked at as the expectation of the random variable $\Omega\to\mathbb R$ prescribed by: $$\omega\mapsto\mu$$
If we write $$\mathbb E(\mu)=\mu$$ then actually $\mu$ on LHS denotes a (constant) function and $\mu$ on RHS denotes an element of $\mathbb R$