% Chebyshev differentiation of a smooth function
%
  xx = -1:.01:1;
  uu = exp(xx).*sin(5*xx);
%
  N = 10;
  [D,x] = cheb(N); u = exp(x).*sin(5*x);
  subplot(2,2,1);
  plot(x,u,'.','markersize',14), grid on;
  line(xx,uu);
  title(['u(x), N = ', int2str(N)]);
%
  err = D*u - exp(x).*(sin(5*x)+5*cos(5*x));
  subplot(2,2,2);
  plot(x, err, '.', 'markersize', 14), grid on;
  line(x,err);
%
  N = 20;
  [D,x] = cheb(N); u = exp(x).*sin(5*x);
  subplot(2,2,3);
  plot(x,u,'.','markersize',14), grid on;
  line(xx,uu);
  title(['u(x), N = ', int2str(N)]);
%
  err = D*u - exp(x).*(sin(5*x)+5*cos(5*x));
  subplot(2,2,4);
  plot(x, err, '.', 'markersize', 14), grid on;
  line(x,err);
