function ShowSparse4()
% The concept of fill-in
% In matrix computations,order of operation can have a big impact
% on work, e.g. y = (A*A*A)*x versus y = A*(A*(A*x)). In sparse
% matrix computations, order of operation can have a big impact on
% storage requirements because of "fill-in"

% Here is a tridiagonal matrix...
A = sparse(triu(tril(randn(50,50),1),-1));
M = A;
spy(M)
title('M = A')
shg
pause
% Now we look at the sparsity of A^2, A^3, A^4,...
for k=2:20
M = A*M;
spy(M)
title(sprintf('M = A^{%1d}',k))
shg
pause
end