% p9.m - polynomial interpolation in equispaced and Chebyshev pts
% AJ experiment with N
  N = 20;
  xx = -1.01:.005:1.01; clf
  for i = 1:2
    if i==1, s = [num2str(N) ' equispaced points']; x = -1 + 2*(0:N)/N; end
    if i==2, s = [num2str(N) ' Chebyshev points'];  x = cos(pi*(0:N)/N); end
    subplot(2,1,i)
    u = 1./(1+16*x.^2);
    uu = 1./(1+16*xx.^2);
    p = polyfit(x,u,N);              % interpolation
    pp = polyval(p,xx);              % evaluation of interpolant
    plot(x,u,'.','markersize',13)
    line(xx,pp)
    axis([-1.1 1.1 -1 1.5]), title(s)
    error = norm(uu-pp,inf);
    text(-.5,-.5,['max error = ' num2str(error)])
  end
