Solution (source code)

= Solution

Split the best <polynomial> into its <even> and <odd> parts, $p_n=p_e+p_o$. Both parts belong to $\Pi_n$. Since $u$ is <odd>, $u-p_o$ is odd and $p_e$ is even. Their product is odd, so its integral on the symmetric interval vanishes. The <orthogonality> gives
$$
\|u-p_n\|^2=\|(u-p_o)-p_e\|^2=\|u-p_o\|^2+\|p_e\|^2.
$$
The candidate $p_o$ cannot have a strictly smaller error than a minimizer. Consequently $\|p_e\|^2=0$, and continuity gives $p_e=0$. Thus $\boxed{p_n(-x)=-p_n(x)}$. For $n=0$ this means $p_0=0$, which is indeed an odd function. More generally this is <parity preservation by polynomial least-squares projection>.