This question has been set in the Christmas work for the chemists at oxford uni and the hint that was given in the problem sheet was "does $\mathbb E(x)$ depend on $x$?".
There is a derivation on Wikipedia: $$\mathbb E((x-\mathbb E(x))^2)$$ Expand the brackets (I get this bit) $$\mathbb E(x^2-2x\mathbb E(x)+\mathbb E(x)^2)$$ Use the fact the expectation value of the sum of the terms is the same as the sum of the expectation values of the terms: $$\mathbb E(x^2)-2\mathbb E(x\mathbb E(x))+\mathbb E(\mathbb E(x)^2)$$ This step isn't written explicitly in the derivation on Wikipedia but it must be the case. Now the step that I don't understand: $$\mathbb E(x^2)-2\mathbb E(x)\mathbb E(x)+\mathbb E(\mathbb E(x)^2)$$ Why does the term in the middle not change to $2\mathbb E(x)\mathbb E(\mathbb E(x))$?
Then collect the terms:$$\mathbb E(x^2)-\mathbb E(x)^2$$
Also, this doesn't seem to utilise the hint given by my lecturer. Is there a better way of doing it?
Expected value of a constant is a constant:
$$\begin{align} E(a) &= \int_{-\infty}^{\infty}af(x)dx \\ &= a\int_{-\infty}^{\infty}f(x)dx \\ &= a \end{align}$$ since $\int_{-\infty}^{\infty}f(x)dx = 1$ the total probability. Hence, $$\begin{align} E\left((x-E(x))^2\right) &= E\left(x^2 -2xE(x) + E(x)^2\right) \\ &= E(x^2) -2E(x)E(x) +E(x)^2 \\ &= E(x^2) - E(x)^2 \end{align}$$