Solution (source code)

= Solution

Part (a) shows that $f-p_n^*$ is orthogonal to $p_n^*\in\mathcal P_n$. Since
$$
f=(f-p_n^*)+p_n^*,
$$
the <Pythagorean theorem in an inner-product space> immediately gives
$$
\boxed{\lVert f\rVert^2
=\lVert f-p_n^*\rVert^2+\lVert p_n^*\rVert^2}.
$$
This is the norm decomposition associated with <orthogonal projection onto a finite-dimensional subspace>.