Homework 2 MA/CS 375, Fall 2002 Due October 3 This homework will count as part of your individual grade so you must work independently. The programs/scripts and report must be done only by the student doing the project. All the problems are from the text. [i.] Use 4, 8, 16 and 32 equispaced points to compute polynomial interpolants to the following functions: (a) e^{-x^2}, -2 <= x <= 2. (b) 1/(1+x^2), -5 <= x <= 5. (c) x^.5, 0 <= x <= 4. Plot the function together with the four interpolants on one graph. Compute the maximum error on one hundred equispaced points. (Do NOT interpolate on these.) Comment on the convergence. [ii.] Repeat [i.] using Chebyshev points: x(i) = .5*(b+a) +.5*(b-a)*cos(pi*(i-1)/m) , i = 1:m+1. [iii.] Repeat [i] using least squares approximations computed by polyfit. Here always use 50 equispaced points but vary the degree: p=3,7,15,31. ( POLYFIT Fit polynomial to data. POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of degree N that fits the data, P(X(I))~=Y(I), in a least-squares sense. [P,S] = POLYFIT(X,Y,N) returns the polynomial coefficients P and a structure S for use with POLYVAL to obtain error estimates on predictions. If the errors in the data, Y, are independent normal with constant variance, POLYVAL will produce error bounds which contain at least 50% of the predictions. The structure S contains the Cholesky factor of the Vandermonde matrix (R), the degrees of freedom (df), and the norm of the residuals (normr) as fields. See also POLY, POLYVAL, ROOTS.) [iv.] 2.4.4 [v.] Use CSinterp and CSeval to interpolate the following functions using 4, 8, 16 and 32 equispaced points on 0 <= x <= 1. Again plot the function with its interpolants and find the maximum error on 100 points, commenting on convergence. (a) e^(sin ( 2 pi x)) (b) e^(sin (16 pi x)) (c) x