Solution
= Solution
Assume a finite second <moment>, so the following <expectations> are finite. Expand the square and use <linearity of expectation>:
$$
\begin{aligned}
\operatorname{var}(X)
&=\mathbb E[X^2-2\mu X+\mu^2]\\
&=\mathbb E[X^2]-2\mu\mathbb E[X]+\mu^2
=\mathbb E[X^2]-\mu^2.
\end{aligned}
$$
Thus
$$
\boxed{\operatorname{var}(X)=\mathbb E[X^2]-(\mathbb E[X])^2.}
$$
The same equality holds in the extended sense when the <mean> is finite and the second <moment> is infinite.