% Runge phenomenon function interp_runge numnodes = 3 x = linspace(-1,1,numnodes); 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)'); hold off; end function y = runge(x) y = 1./(1+12*x.^2); end