  function ShowGershgorin()
% All the eigenvalues of A are in the union of the disks D1,...,Dn
% where disk Di has center A(i,i) and radius 
%   |A(i,1)| +...+A(i,i-1)| + |A(i,i+1)| + ... + |A(i,n)|

close all
n = 5;
A = .3*randn(n,n);
A = A + A';
for i=1:n
    A(i,i) = -8+3*i;
end
c = cos(linspace(0,2*pi));
s = sin(linspace(0,2*pi));
% The x-axis...
plot(norm(A)*[-1 1],[0 0],'k')
hold on
for i=1:n
    % Draw the ith disk...
    r = sum(abs(A(i,[1:i-1 i+1:n])));
    fill(A(i,i)+c*r,s*r,'y')
end
plot(eig(A),zeros(n,1),'xm')
hold off
axis equal
shg
