%Script file to show the Runge phenomenon (p 158-159 of our text) n=15; %Number of base points xf=linspace(-1,1,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','Poly Approx');