Question: 1. Consider the problem of approximating the function f(x) = 1/(1 + 25x^2) on theinterval [1,1] with the least squares approximation Cn(x) based on Chebyshev

1. Consider the problem of approximating the function f(x) = 1/(1 + 25x^2) on theinterval [1,1] with the least squares approximation Cn(x) based on Chebyshev polynomials.

a) Write a Matlab function polycheb that evaluates a Chebyshev polynomial Tn(x) of a given degreenat given points x[1,1]. Plot the Chebyshev polynomialsTn(x),n= 0,1,2,3,4 and 5. Hint: Use the triple recursion formula given in class.

b) Compute the coefficients in the least squares approximation, cj=(2/) f(x)Tj(x)/[1x^2]dx, j= 0,1,2,...,n bounded from -1 to 1. Hint: Use the gausscheb function to compute the integrals.

c) Write a function eval_C that evaluates the least squares approximation based on Chebyshev polynomials Tn(x) at a given vector x. Compute Cn(x) =(1/2) c0T0(x) +nj=1 cjTj(x), n= 2,4,6,8. Plot bothf(x) and Cn(x) in one plot and the error f(x)Cn(x) in another, for each n.This polynomials should provide progresively better approximation as ngrows.

d) Use the built in Matlab function polyfit with the n+ 1 nodes chosenequidistant in [1,1] to build an interpolating polynomial Pn(x) of degree n using n+ 1 equidistant nodes. Compute Pn(x), for n= 2,4,6,8. Plot both f(x) and Pn(x) in one plot and the error f(x)Pn(x) in another, for each n. Do these polynomials provide progresively better approximation as n grows?

e) Use the built in Matlab function polyfit to build an interpolating polynomial In(x) based on Chebyshev nodes given by xj = cos[(2j+ 1/2n+ 2)], j= 0,1,...,n. Compute In(x), for n= 2,4,6,8. Plot both f(x) and In(x) in one plot and the error f(x) In(x) in another, for each n. Do these polynomials provide progresively better approximation as n grows?

f) Finally, compare all three polynomials Pn(x), In(x), and Cn(x) in approximating f(x) when using for instance n= 8 and n= 16 for all of them. That is plot f(x),Pn(x), In(x), and Cn(x) (n= 8) in one plot and f(x),Pn(x), In(x), and Cn(x)(n= 16) in a new plot. Hint: for better visualisation, you may want to show the errorsas well, i.e., f(x)Pn(x), f(x)In(x)and f(x)Cn(x).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The question is incomplete The function ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!