# Approximation and sum of integrals.

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.

• Why isn't it effective? The squaring removes any worry about the absolute value signs. Expand the square and you get an integral with an eighth degree polynomial. Do the integral and evaluate it. Now take the derivative with respect to $a,b,c$ and set to zero.... – Ross Millikan Jan 9 at 22:53
• So, I have :$\int_{0}^{2}|ax^2+bx+c-x^4|^2 dx+ \int_{-1}^{1}|ax^2+bx+c-x^4|^2 dx=\frac{34a^2}{5}+8ab+\frac{20ac}{3}-\frac{260a}{7}+\frac{10b^2}{3}+4bc-\frac{64b}{3}+4c^2-\frac{68c}{5}+\frac{514}{9}$ And it does not look nice. – pawelK Jan 9 at 23:06
• @pawelK why not nice? it is a quadratic in 3 variables, can you minimize this? – gt6989b Jan 9 at 23:19
• I didn't check the computations, but that is exactly what I was suggesting. Yes, it is not a cute solution but it will get there. – Ross Millikan Jan 9 at 23:26

## 2 Answers

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:

1. Compute an orthonormal basis of $$V$$.
2. Compute the inner products of $$X^4$$ with the elements of said basis.
3. Take the corresponding element in $$V$$.
• Ok, I have: $\int_{0}^{2}(ax^2+bx+c-x^4)1dx=0$ etc. But I we have two integrals and I will get different values $a,b,c$ for each integral. – pawelK Jan 13 at 22:04
• Will it be $\int_{0}^{2}(ax^2+bx+c-x^4)1dx+\int_{-1}^{1}(ax^2+bx+c-x^4)1dx=0$? – pawelK Jan 13 at 22:11
• Yes, and as well when you replace $1$ with $x$ and $x^2$. – Mindlack Jan 13 at 22:52

$$F(a,b,c) = \int_0^2 (ax^2+bx + c - x^4)^2\ dx + \int_{-1}^{1} (ax^2 + bx + c - x^4)^2 \ dx$$

Differentiating under the integral sign.

$$\frac {F(a,b,c)}{\partial a} = \int_0^2 2(ax^2+bx + c - x^4)x^2\ dx + \int_{-1}^{1} 2(ax^2 + bx + c - x^4)x^2 \ dx = 0$$

$$\frac {a}{5}x^5 + \frac {b}{4} x^4 +\frac {c}{3} x^2 + \frac {1}{7} x^7|_0^2|_{-1}^1 = 0\\ \frac {34}{5}a + \frac {16}{4} b +\frac {10}{3} c = \frac {130}{7}$$

Do the same for the other variables, and you will get a system of linear equations.