% Poisson eq. on [-1,1] x [-1,1] with homogeneous Dirichlet boundary conditions

% Set up grids and tensor product Laplacian and solve for u:

  N = 24; [D,x] = cheb(N); y = x;

  [xx,yy] = meshgrid(x(2:N),y(2:N));
  xx = xx(:); yy = yy(:);

  f = 10*sin(8*xx.*(yy-1));
  D2 = D^2; D2 = D2(2:N,2:N); I = eye(N-1);
  L = kron(I,D2) + kron(D2,I);

  figure(1), clf, spy(L), drawnow
  tic, u = L\f; toc

  uu = zeros(N+1,N+1);
  uu(2:N,2:N) = reshape(u,N-1,N-1);
  [xx,yy] = meshgrid(x,y);

  [xxx,yyy] = meshgrid(-1:.04:1,-1:.04:1);
  uuu = interp2(xx,yy,uu,xxx,yyy,'cubic');
  figure(2), clf, mesh(xxx,yyy,uuu), colormap(1e-6*[1 1 1]);
  xlabel x, ylabel y, zlabel u
