Polynomial approximation: Chebyshev and Legendre

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 3K views
ch3cooh
Messages
4
Reaction score
0
Chebyshev polynomials and Legendre polynomials are both orthogonal polynomials for determining the least square approximation of a function. Aren't they supposed to give the same result for a given function?
I tried mathematica but the I didn't get the same answer :( Is this precision problem or something else?
Code:
In[79]:= Collect[
  Sum[Integrate[LegendreP[i, x]*Sin[2 x], {x, -1, 1}]/
    Integrate[LegendreP[i, x]^2, {x, -1, 1}]*LegendreP[i, x], {i, 0,
    3}], x] // N

Out[79]= 1.94378 x - 1.06264 x^3

In[80]:= Collect[
  Sum[Integrate[
     1/Sqrt[1 - x^2] ChebyshevT[i, x]*Sin[2 x], {x, -1, 1}]/
    Integrate[1/Sqrt[1 - x^2] ChebyshevT[i, x]^2, {x, -1, 1}]*
    ChebyshevT[i, x], {i, 0, 3}], x] // N

Out[80]= 1.92711 x - 1.03155 x^3
 
Physics news on Phys.org
ch3cooh said:
Chebyshev polynomials and Legendre polynomials are both orthogonal polynomials for determining the least square approximation of a function. Aren't they supposed to give the same result for a given function?

I haven't looked at that stuff in years, but I think the answer is "no". They have different weight functions which give different inner products and consequently different norms in which to measure the least squares fit.
 
I think "least squares fit" makes it clear what norm is used to measure the fit. For a "nice" function (one that can be expressed as an infinite power series) , if you express it as an infinite series of Chebyshev polynomials you get an exact fit. You also get an exact fit if you express it as an infinite series of some other family of othrogonal polynomials. So perhaps the question has to do with approximating the function as a finite series.

I find the Mathematica code in the original post puzzling. It looks like its computing a ratio between a function and the approximating function.