# Least Squares with Legendre Polynomials

• Dec 8th 2011, 09:35 PM
monomoco
Least Squares with Legendre Polynomials
Find the second degree least squares approximation to f(x)=e^x on [-1, 1] using the Legendre polynomials.

Using P(x)=a_0*c_0 + a_1*c_1 + a_2*c_2 where the c's are the Legendre polys and the a's are found using the formula a_j =
int from -1 to 1 of c_j (x) f(x) dx / int from -1 to 1 of (c_j (x))^2 dx

because the weight function = 1

I have come up with -14.2556 +8.1548x+4.629x^2 which is very wrong. Could someone please walk me through this?
• Dec 9th 2011, 12:36 AM
JJacquelin
Re: Least Squares with Legendre Polynomials
Hello !

I have come up with :
a*P0(x) + b*P1(x) + c*P2(x) where a=1.175201 ; b=1.103638 ; c=0.357814
P0(x), P1(x), P2(x) are Legendre polynomials.
This result is the same as :
A + B*x + C*x² where A=0.996294 ; B= 1.103638 ; C=0.536722
Classical polynomial regression leads exactly to the same result.
In order to find where is the mistake in your calculus, you should show the details of what you did.