% Question:
% How big do A and b have to be 
% in order for A\b to be appreciably
% faster than inv(A)*b  when solving
% the square system A*x = b ?

N = 100;

mins = [];

for testruns = 1:N
      
    for n = 1:50;
	    A = rand(n,n);
        b = rand(n,1);
        tic; inv(A)*b; time1=toc;
        tic; A\b; time2=toc;
        diff = time1-time2;
	    if diff > eps
		    break
	    end
    end

    mins = [mins, n];
    
end

% Further Questions: 
% What is the minimum n? (Optimization)
% What is the distribution of n? (Statistics)

subplot(2,1,1)
hist(mins) 
title('\bf{Minimum System Size for Appreciable Time Difference}')
ylabel('Number of Test Runs')
subplot(2,1,2)
boxplot(mins,1,'*',0) 