Quartic Approximation of f(x) using Chebyshev & Legendre Polynomials

squenshl
Messages
468
Reaction score
4

Homework Statement


Let f(x) = cos(pi*x), 0 < x < 1. Find a quartic approximation to f(x):
By solving the continuous least squares problem using Chebyshev polynomials.
By solving the continuous least squares problem using Legendre polynomials.

Homework Equations


The Attempt at a Solution


For Chebyshev polynomials the interval is [-1,1] but my interval is [0,1]. How do I convert [0,1] to [-1,1] (or the other way around) and where do I go from there.
 
Physics news on Phys.org
One thought is to do a change of variables. Change the variable in sin(2 pi x) so its some variable v that goes from -1 to 1. Write the Chebyshev polynomials with the variable v.

Are the Chebyshev polynomials orthogonal "unit vectors"? If so then you just take the inner product of sin(...) on each to get the coefficient. That would be the integral of the product of sin(...) with the polynomial from -1 to 1.

When you get the answer, you revert everything so it is in terms of x instead of u.

I haven't done the problem. This is just my guess.
 
Got it. Just used a simple change of variables.
Got f(x) = 19.4073x3 - 29.1109x2 + 8.48488x + 0.609377 using Chebyshev polynimials and got f(x) = 4.498x3 - 6.747x2 + 0.267x + 0.991 using Legendre polynomials.
 
it was quartic.. so shud be till power of 4, isn't?
 
The 4th coefficient is 0
 
squenshl said:
Got it. Just used a simple change of variables.
Got f(x) = 19.4073x3 - 29.1109x2 + 8.48488x + 0.609377 using Chebyshev polynimials and got f(x) = 4.498x3 - 6.747x2 + 0.267x + 0.991 using Legendre polynomials.

I don't think you have the correct answer, first we need to change T(x), second your summation perhaps incorrect.
 
Which one is not correct?
 
squenshl said:
Which one is not correct?

Both of them, the coefficients appear too large and the polynomials should be up to x^4.
 
Last edited:
I got c0 = -0.269628, c1 = -0.654197, c2 = -0.198127, c3 = 0.167396 and c4 = -0.0184982 for the Chebyshev polynomials
 
  • #10
For the Chebyshev polynomials I get -1.88921 x^4+8.0662 x^3-10.0579 x^2+3.1049 x+0.063017 and when I plot the f(x) using Legendre polynomials it looks almost the same as cos (pi*x) on [0,1] (using wolframalpha.com).
 
  • #11
primens123 said:
I don't think you have the correct answer, first we need to change T(x), second your summation perhaps incorrect.

Is the T(x)=cos(nx)
or T(x)=2nx-1?
 
  • #12
I am pretty sure I am correct.
 
  • #13
squenshl said:
I got c0 = -0.269628, c1 = -0.654197, c2 = -0.198127, c3 = 0.167396 and c4 = -0.0184982 for the Chebyshev polynomials

squenshl - I get a different result for the Chebyshev coefficients. After letting u = 2*x -1 (so -1 &lt;= u &lt;= 1), I get:

c_0 = 0
c_1 = -2 \cdot J_1(\pi/2) = -1.133648178...
c_2 = 0
c_3 = 2 \cdot J_3(\pi/2) = 0.138071777...
c_4 = 0

Here, J_k(\pi/2) are the Bessel Functions of first kind, order k, evaluated at \pi/2.

The resulting Chebyshev approximation polynomial (for a fourth order approx) would be:

f(T(u)) = c_1 \cdot T_1(u) + c_3 \cdot T_3(u)

The coefficients for the polynomial in u would then be:
b_1 = c_1-3 \cdot c_3 = -1.547863508...
b_3 = 4 \cdot c_3 = 0.552287106...

and the coefficients for the polynomial in x would then be:
a_0 = -(b_3 + b_1) = 0.995576401...
a_1 = 6 \cdot b_3 + 2 \cdot b_1 = 0.217995623...
a_2 = -12 \cdot b_3 = -6.627445276...
a_3 = 8 \cdot b_3 = 4.418296851...
a_4 = 0

To have a fourth term in the polynomial of x, we would require another term (T5) in the Chebyshev expansion, which would also introduc a quintic x term.

I can provide more on this later.
 
  • #14
Thanks a lot.
Could you please check my Legendre polynomial question if it is correct?
 
  • #15
squenshl said:
Thanks a lot.
Could you please check my Legendre polynomial question if it is correct?

Your polynomial coefficients from the Legendre analysis are in agreement with mine.
 
  • #16
As for the Chebyshev polynomials question, I have never studied Bessel functions before so I just did same method as for the Legendre polynomials.
 
  • #17
squenshl said:
As for the Chebyshev polynomials question, I have never studied Bessel functions before so I just did same method as for the Legendre polynomials.

Well, what was that method? You should have some integrals to evaluate. You don't need to know about Bessel functions if you numerically evaluated the integrals.
 
Back
Top