% Runge with Chebychev nodes function interp_runge_cheby n = 7 i = 1:n; theta = (2*i-1)*pi/2/n; x = cos(theta); y = runge(x); plot(x,y,'k*'); hold on; n = numel(x); c = newtdd(x,y,n); xx = linspace(x(1),x(n),400); plot(xx,runge(xx),'b'); yy = nest(n-1,c,xx,x); plot(xx,yy,'r'); title('Runge function (blue) and poly interpolant (red) with Cheby nodes'); hold off; end function y = runge(x) y = 1./(1+12*x.^2); end