function fig7_3

%  euler method for various M values
%  y' = ry(1-y)  with   y(0) = y0 '

r=10;
t0=0; y0=0.01;
tmax=1;

clf
% get(gcf)
set(gcf,'Position', [25 1115 658 230])
subaxis(1,1,1,1,'MT',0.01,'MB',0.16,'MR',-0.03,'ML',0.04,'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)
hold on

% calculate and plot exact solution
tt=linspace(t0,tmax,100);
a0=(1-y0)/y0;
for it=1:100
    exact(it)=1/(1+a0*exp(-r*tt(it)));
end
plot(tt,exact,'r','LineWidth',1.4)
box on

% calculate and plot using euler
m=4;
for im=1:3
    t=linspace(t0,tmax,m+1);
    h=t(2)-t(1);
    euler=y0;
    y=y0;
    for i=2:m+1
        yy=y+r*h*y*(1-y);
        euler=[euler, yy];
        y=yy;
    end
    if im==1
        plot(t,euler,'--ks','MarkerSize',7,'LineWidth',1.1)
    elseif im==2
        plot(t,euler,'--m*','MarkerSize',7,'LineWidth',1.1)
    else
        plot(t,euler,'--bo','MarkerSize',7,'LineWidth',1.1)
    end
    m=4*m;
end

axis([0 1 0 1.05])
%legend(' Exact',' M = 4',' M = 16',' M = 64 ',2)
grid on
%  get(legend)
%  'Position',[left, bottom, width, height]
legend({' Exact',' M = 4',' M = 16',' M = 64'},'Location','NorthWest','FontSize',16,'FontWeight','bold')

xlabel('t-axis')
ylabel('Solution')
set(gca,'FontSize',16,'FontWeight','bold')
hold off

%exportgraphics(gca,'/Users/mark/Desktop/euler.eps')


















