% Analyzes modification of the solution for a random
% perturbation of the RHS for an ill-conditioned system;

% Originally written by Dr. D. Pelinovsky


A = hilb(15); % Hilbert matrices are ill-conditioned

b1 = ones(15,1); % b1 is the vector of ones

b2 = b1 + 0.01*rand(15,1); % b2 is a small random perturbation to b1

x1 = A\b1;  y1 = x1'

x2 = A\b2;  y2 = x2'

% Two solutions of linear systems with almost equal right-hand-sides

bdif = norm(b2-b1), ydif = norm(y2-y1)


% plot of the matrix;
colormap(copper);
figure(1); contourf(log(abs(A))); colorbar;
