function fig7_5

%  error using euler method as a function of M
%  this also produces Table 7.3 
%  y' = ry(1-y)  with   y(0) = y0  

r=10;
y0=0.01;
tmax=1;
a0=(1-y0)/y0;
MM=[10 100 1000 1e4 1e5 1e6 1e7];
for im=1:length(MM)
    M=MM(im);
    h=tmax/M;
    y=y0;
    emax=0.0;
    t=0;
    for i=2:M+1
        t=t+h;
        yy=y+r*h*y*(1-y);
        ye=1/(1+a0*exp(-r*t));
        em=abs(yy-ye);
        if emax < em
            emax=em;
        end
        y=yy;
    end
    maxerror(im)=emax;
    pterror(im)=em;
    points(im)=M;
     
	fprintf('\\, %i \\, & \\, %5.1e \\, & \\,\\, %5.1e \\\\\\hline \n',M,h, emax)

end

clf
% get(gcf)
set(gcf,'Position', [25 1115 658 230])
subaxis(1,1,1,1,'MT',0.01,'MB',0.19,'MR',-0.02,'ML',0.06,'P',0.04)
co = [0 0 1;
    0 0.5 0;
    1 0 0;
    0 0.75 0.75;
    0.75 0 0.75;
    0.75 0.75 0;
    0.25 0.25 0.25];
set(groot,'defaultAxesColorOrder',co)

loglog(points,maxerror,'--bo','MarkerSize',8,'LineWidth',1.8)
hold on
set(gca,'ytick',[1e-8 1e-6 1e-4 1e-2 1])
xlabel('Number of Time Points (M)')
ylabel('Iterative Error')
grid on
axis([1 1e7 1e-8 1])
set(gca,'MinorGridLineStyle','none')
set(gca,'FontSize',16,'FontWeight','bold')
hold off

%exportgraphics(gcf,'/Users/mark/Desktop/errorI.eps')











