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

clc
eps3 = .005          % 3-digit machine precision
nRepeat = 10;        % number of trials per n-value
disp('   n   1-norm factor    ')
disp('------------------------')
for n = 2:10
   s = 0;
   for r = 1:nRepeat
      A  = randn(n,n);
      B  = randn(n,n);
      A1 = A+eps3*(ones(n,n)-2*rand(n,n));
      B1 = B+eps3*(ones(n,n)-2*rand(n,n));
format short e
      C = A*B;
format long e
      E = C-A1*B1;
      s = s+norm(E,1)/(eps3*norm(A,1)*norm(B,1));
   end
   disp(sprintf('%4.0f    %8.3f   ',n,s/nRepeat))
end

