% Script File: ProdBound
% Examines the error in 3-digit matrix multiplication

clc
eps3 = .00005 % 3-digit machine precision
nRepeat = 10; % number of trials per n-value
disp(' n 1-norm factor ')
disp('------------------------')
for n = [5, 10, 20, 50, 100, 200, 400]
s = 0;
% for r = 1:nRepeat
A = randn(n,n);
Am = inv(A);
kon=norm(A,inf)*norm(Am,inf);
x = randn(n,1);
A1 = A+eps3*(ones(n,n)-2*rand(n,n));
x1 = x+eps3*(ones(n,1)-2*rand(n,1));
format short e
b = A*x;
b1= A1*x1;
b2= A *x1;
b3= A1*x ;
format long e
E1 = norm(b-b1,inf);
E2 = norm(b-b2,inf);
E3 = norm(b-b3,inf);
% s = s+norm(E,1)/(eps3*norm(A,1)*norm(B,1));
% end
disp(sprintf('%4.0f %8.5f %8.5f %8.5f %8.5f',n,E1,E2,E3,kon))
% disp(sprintf('%4.0f %8.3f ',n,s/nRepeat))
end