We consider the space of continuous functions in $[-1,1]$ that has the usual inner product $(f,g)=\int_{-1}^1 f(x) g(x) dx$.
I want to characterize the optimal approximation of a function $f \in C[-1,1]$ from the space of polynomials of degree $\leq 2$.
Could you give me a hint how we could do this?
Consider the basis $\{1, x, x^2\}$ for the space $\mathbb{R}[x]_{\le 2}$ and apply Gram-Schmidt to obtain an orthonormal basis $\{p_1, p_2, p_3\}$ for $\mathbb{R}[x]_{\le 2}$.
Use this to compute the orthogonal projection $P$ onto $\mathbb{R}[x]_{\le 2}$ :
$$Pf = \sum_{i=1}^3 (f, p_i)p_i, \quad\forall f \in C[-1,1]$$
Then $Pf$ is precisely the distance minimizer from $\mathbb{R}[x]_{\le 2}$ to $f$.