function   simpleodeerror()
%Accuracy of ode integration


%DESCRIBE THE DESIRED ACCURACY
% Play with this number and see how time of computation
% and error vary
thisgood=1e-10; % same as 10^-10 

tspan=linspace(0,10,11);
z0=1;

% SOLUTION DOESN'T USE THE STRICTER OF THE TWO ERROR BOUNDS,
% RATHER, THE MORE LENIENT
% Type help odeset for more explanation
options=odeset('reltol', thisgood/100, 'abstol', thisgood);

% NOTE:  ode45 tends to be more accurate and to run faster
% than   ode23 when desired errors are less than, typically, 1e-6.
% Try both and see.

tic
[tarray zarray] = ode45(@rhs,tspan, z0,options);
elapsed = toc;  %To time calculations

disp('**************************************************')
disp(['desired error bound = '    num2str(thisgood)])
disp(['Actual error        =   '  num2str(norm(zarray(end) - exp(10)))])
disp(['Calculation time    =   '  num2str(elapsed)])

end




%%%%%%%%%%%%%%%%%%%%
function zdot = rhs(t,z)
  zdot = z;
end