% A3 = poisson3d(n)
%
% Compute the standard Poisson discretization with Dirichlet
% boundary conditions for a mesh with n-by-n-by-n interior points.

function A3 = poisson3d(n);

e = ones(n,1);
T = spdiags([-e 2*e -e], -1:1, n, n)/(n+1);
I = speye(n);
A3 = kron(kron(T,I),I) + kron(kron(I,T),I) + kron(kron(I,I),T);