
    lam = [ 1 2 4 7];
    L = diag(lam);
    disp(' ')
    disp('original eigenvalues of diagonal matrix ')
    lam'
    
    disp(' Perturbation of the diagonal matrix ')
    P = rand(4,4);
    P = P - diag(diag(P))
   
    N = 51
    s = linspace(0, 1, N);
    disp(' ')
    disp('radii of Gershgorin disks ')
    
    format compact
    r1 = s(N)*sum(abs(P(1,:)))
    r2 = s(N)*sum(abs(P(2,:)))
    r3 = s(N)*sum(abs(P(3,:)))
    r4 = s(N)* sum(abs(P(4,:)))
    format loose
    
    t = linspace(0, 2*pi, 101);
    
    plot(real(lam), imag(lam), '*')
    hold on
    plot(r1*cos(t) +real(lam(1)), r1*sin(t) +imag(lam(1)) )
    plot(r2*cos(t) +real(lam(2)), r2*sin(t) + imag(lam(2)) )
    plot(r3*cos(t) +real(lam(3)), r3*sin(t) + imag(lam(3)) )
    plot(r4*cos(t) + real(lam(4)), r4*sin(t) + imag(lam(4)) )
    hold on
    
    d = zeros(N,4);
    
    for n = 1:N
       A = L + s(n)*P;
       [S,D] = eig(A);
       d(n,:) = diag(D)';
    end
    
    d = (sort(d'))';
    disp( ' ')
    disp(' eigevalues of the perturbed matrix ')
    d(N, :)'
    for m = 1:4
      plot(real(d(:,m)), imag(d(:,m)), 'r')
      plot(real(d(N-1,m)), imag(d(N-1,m)), 'r*')
    end
    axis equal
    hold off
