Solution (source code)

= Solution

The <norm> induced by the specified <inner product> is the <L2 norm>
$$
\boxed{\|u\|=\sqrt{(u,u)}=\left(\int_{-1}^1u(x)^2\,dx\right)^{1/2}.}
$$
A <polynomial> $p_n\in\Pi_n$ is a best <polynomial least-squares approximation> when
$$
\boxed{\|u-p_n\|=\min_{q\in\Pi_n}\|u-q\|.}
$$
Minimizing this <norm> is equivalent to minimizing its square, the integrated squared error. Continuity ensures that a function with zero squared <norm> is identically zero: a nonzero value would give a neighbourhood on which the square has a positive integral.