%Script file to repeat Runge example, but we will remove the %oscillations at the ends by using the Chebyshev points. %(p 163 of our text) n=15; %Number of base points t=1:2:2*n-1; xf=cos(t*pi/(2*n)); %get n equally spaced points between +/-1 xx=linspace(-1,1,200); %Data to plot f=inline('1./(1+12*x.^2)'); yf=f(xf); %These will be the y-data for the polynomial yy=f(xx); % y-data to plot for the function f (not the polynomial approx) coefs=newtdd(xf,yf); cy=nest(n-1,coefs,xx,xf); plot(xf,yf,'k*',xx,yy,'b-',xx,cy,'r-'); legend('Data','Actual Function','Chebyshev Poly');