[Math] Least square fit using Legendre polynomials

approximation-theoryorthogonal-polynomials

I would like to apply Legendre polynomials to least square approximation. Therefore I would like the function:

$$L_n (x)=\sum_{k=0}^n a_k P_k (x)$$

to fit $f(x)$ defined over $[-1,1]$ in a least square sense.

We should minimize:

$$I(a_0, …, a_n)= \int_{-1}^1 [f(x) – L_n (x)]^2 \; dx\tag1$$

and so we must set

$$\frac{\partial I}{\partial a_r} = 0,\qquad r=0,1, \ldots,n\tag2$$

Using equations $(1)$ and $(2)$

$$\int_{-1}^1 P_r(x) \left[f(x) – \sum_{k=0}^n a_k P_k (x)\right]dx = 0,\qquad r=0,1, \ldots,n$$

should be an equivalent term.

My question now is: why is that true?

I would be glad if someone could illustrate the last step with more details.
Thanks, Rainier.

Best Answer

You have

$$ \frac{\partial}{\partial a_r}\int_{-1}^1 [f(x) - L_n (x)]^2dx=0\\ \int_{-1}^1 \frac{\partial}{\partial a_r}[f(x) - L_n (x)]^2dx=0\\ \int_{-1}^1 2[f(x) - L_n (x)]\frac{\partial}{\partial a_r}[f(x) - L_n (x)]dx=0\\ \int_{-1}^1 2[f(x) - L_n (x)][0 - \frac{\partial}{\partial a_r}L_n (x)]dx=0\\ -\int_{-1}^1 2[f(x) - L_n (x)]\frac{\partial}{\partial a_r}\sum a_kP_k(x)dx=0\\ -\int_{-1}^1 2[f(x) - L_n (x)]P_r(x)dx=0 $$

Related Question