Consider the sum of integrals: $$ \int_0^2 \left|f(x)-x^4\right|^2 dx+ \int_{-1}^1 \left|f(x)-x^4\right|^2 dx.$$ Find a polynomial of degree at most two, such that the sum above is the smallest.
Ok. I know that $f(x)=ax^2+bx+c$, but count it $$ \int_0^2 \left|ax^2+bx+c-x^4\right|^2 dx + \int_{-1}^1 \left|ax^2+bx+c-x^4\right|^2 dx $$ isn't effective.
A « maybe » easier solution is to notice that you are asked to minimize $\|f-X^4\|^2$, over the $f \in V$, where $V$ is a subspace of the ambient space $W=\mathbb{R}_4[X]$ and $\|\cdot\|$ is a Euclidean norm over $W$.
So there is an automatic procedure: