# MATLAB Problems: 1) For f (x) = e^(-|x|) on [-3, 3], you are to compare evenly-s

MATLAB Problems:
1) For f (x) = e^(-|x|) on [-3, 3], you are to compare evenly-spaced interpolation with Chebyshev interpolation. In this exercise, you do not have to use any loops.
b) Modify your script from part (a) to make a new script file to do the following: Compute the n Chebyshev nodes, and call newtdd.m and nest.m the same way you did in part (a) to get an interpolating polynomial on x-values evenly spaced by 0.01 between -3 and 3.
Plot the new interpolating polynomial, and also plot the vector of the absolute errors between the interpolating polynomial and the exact function on these 0.01-spaced x-values for n = 10 and n = 30, where n is the number of nodes.
Use MATLAB to compute an estimate of the maximum of the absolute error in the interpolating polynomial for n = 30. c) Can you compute a theoretical error bound for parts (a) and (b) with the bounds discussed in class? Explain. On a related note, near what part of a function do you think large interpolation errors can occur, besides the endpoints?
(result from class that an upper bound on the absolute error in the unique interpolating polynomial on 2 nodes, x1 and x2, for any function f(x) is
((M2)/8) h^2, where h = x2 – x1 > 0, and M2 = max (x1< x < x2 ) |f ”(x)|.) %Program 3.1 Newton Divided Difference Interpolation Method %Computes coefficients of interpolating polynomial %Input: x and y are vectors containing the x and y coordinates %    of the n data points %Output: coefficients c of interpolating polynomial in nested form %Use with nest.m to evaluate interpolating polynomial function c=newtdd(x,y,n) for j=1:n v(j,1)=y(j);    % Fill in y column of Newton triangle end for i=2:n       % For column i, for j=1:n+1-i    % fill in column from top to bottom v(j,i)=(v(j+1,i-1)-v(j,i-1))/(x(j+i-1)-x(j)); end end for i=1:n c(i)=v(1,i);    % Read along top of triangle end          % for output coefficients %Program 0.1 Nested multiplication %Evaluates polynomial from nested form using Horner’s method %Input: degree d of polynomial, %    array of d+1 coefficients (constant term first), %    x-coordinate x at which to evaluate, and %    array of d base points b, if needed %Output: value y of polynomial at x function y=nest(d,c,x,b) if nargin<4, b=zeros(d,1); end  y=c(d+1); for i=d:-1:1 y = y.*(x-b(i))+c(i); end