Least Squares Approximation in Linear Algebra

samf

New member
Joined
Oct 27, 2007
Messages
1
What I need to solve is a problem in the form "Find the least-squares approximation of f(x) by a polynomial of degree n", or in other words the answer must be a0+a1*x+...+an*x^n. It's easy enough to solve this with mma commands but I need to know the procedure.

The class notes say that you find each coefficient a sub k of the polynomial approximation by taking the inner product of x^k and the function to be fit and dividing it by the inner product of x^k by x^k: a sub k = <x^k,f(x)>/<x^k,x^k>, but the coefficients I get aren't correct. What step am I missing?

Thanks!
 
You didn't specify the nature of the inner product. I suspect you are looking for some kind of orthogonal polynomial solution. Perhaps looking for "Gram-Schmidt" or "Legendre polynomials" will help clarify your notes.
 
samf said:
What I need to solve is a problem in the form "Find the least-squares approximation of f(x) by a polynomial of degree n", or in other words the answer must be a0+a1*x+...+an*x^n. It's easy enough to solve this with mma commands but I need to know the procedure.

The class notes say that you find each coefficient a sub k of the polynomial approximation by taking the inner product of x^k and the function to be fit and dividing it by the inner product of x^k by x^k: a sub k = <x^k,f(x)>/<x^k,x^k>, but the coefficients I get aren't correct. What step am I missing?
First, you need to specify the interval you are working on. The n-th degree least-squares approximation of f(x) will be different over different intervals.

Next, you should check what the class notes actually say. The formula that you quote is only correct if the monomials x^k form an orthogonal set. In general, they do not. In fact, I don't believe there is any interval over which they are orthogonal to each other. So you need to replace them by another set of polynomials which do form an orthogonal set over the appropriate interval. As royhaas says, this may turn out to be some well-known family such as the Legendre polynomials (which are orthogonal over the interval [-1,1]).
 
Top