function runge_cheb % Fig. 4.12 with Chebyshev points or the interpolation n=input('Insert the order of the interpolation n = '); hold off x=[-1:0.02:1]; i=[1:1:n]; y=1./(1 + 25 * x.^2); % Plot the function to be interpolated plot(x,y,'-k','linewidth',1.6,'markersize',10,'markerfacecolor','k') xp=cos((2*i-1)*pi/(2*n)); yp=1./(1 + 25 * xp.^2); hold on % Plot the Chebyshev interpolation points plot(xp,yp,'ok','linewidth',1.6,'markersize',7,'markerfacecolor','k') C=polyfit(xp,yp,n-1); Interp=polyval(C,x); % Plot the interpolated function plot(x,Interp,'--k','linewidth',1.6) axis([-1 1 0 1]) set(gca,'FontSize',36) set(gca,'Ytick',[0:.2:1],'linewidth',1.6) set(gca,'Xtick',[-1:.5:1],'linewidth',1.6) str1={'N = '}; str2=num2str(n); str=strcat(str1,str2); text(-.8,.8,str,'fontsize',36) set(gcf, 'Units','centimeters','Papersize',[36,36]) set(gcf, 'Units','centimeters','Position',[3 3 24 20]) end