  function GradeMyExp()
% Explores what m = 2^k should be so that R_{m}(A) is good enough for
% a given tol. 

% Key findings as a result of playing with this script:

% 1. n doesn't matter.
% 2. It makes sense to choose m = 2^k since high powers can
%    be reached cheaply.
% 3. The smallest tol that can be handled is 10^-10
clc
n = 100;
fprintf('\nn = %1d\n',n)
fprintf('\n  tol           Actual Error\n')
fprintf('--------------------------\n')
for tol = logspace(-1,-12,12)
   A = randIntensity(n);
   F0 = expm(A);
   F = MyExpCVL(A,tol);
   fprintf('%10.3e  %10.3e\n',tol,max(max(abs(F - F0))))  
end


  function A = randIntensity(n)
% A is a random nxn normalized intensity matrix.
A = rand(n,n)/n;
for j=1:n
    A(j,j) = 0;
    A(j,j) = -sum(A(:,j));
end
