Solution (source code)

= Solution

Expanding around the <expected value> $\mu$,
$$
G(a)=\mathbb E[(X-\mu+\mu-a)^2]
=\mathbb E[(X-\mu)^2]+(\mu-a)^2,
$$
because $\mathbb E[X-\mu]=0$. Therefore
$$
\boxed{G(a)=\sigma^2+(\mu-a)^2\geq\sigma^2},
$$
with equality exactly when $a=\mu$.

For the absolute loss,
$$
H(a)=\int_{-\infty}^a(a-x)f(x)\,dx
+\int_a^\infty(x-a)f(x)\,dx.
$$
Leibniz differentiation gives, with $F(a)=\int_{-\infty}^af(x)\,dx$,
$$
H'(a)=F(a)-(1-F(a))=2F(a)-1.
$$
Thus $H$ decreases while $F(a)<1/2$ and increases while $F(a)>1/2$. It is minimized at any <median>, characterized in the continuous case by
$$
\boxed{\int_{-\infty}^af(x)\,dx=\frac12}.
$$