function leap_logistic

%  leapfrog method for logistic equation
%  y' = ry(1-y)  with   y(0) = y0    '

clear *
clf

hold on

% set parameters for problem
r=12;
t0=0; y0=0.01;
tmax=2;
M=160;

% 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,'--k')

% define legend and axes used in plot
xlabel('t-axis','FontSize',14,'FontWeight','bold')
ylabel('Solution','FontSize',14,'FontWeight','bold')
title(['Leapfrog with M = ', int2str(M)],'Color','k','FontSize',16,'FontWeight','bold')

% have MATLAB use certain plot options (all are optional)
box on
axis([0 tmax 0 1.5])	
% Set the fontsize to 14 for the plot
set(gca,'FontSize',14); 

% calculate leapfrog solution
t=linspace(t0,tmax,M+1);
h=t(2)-t(1);
y=y0;
yy=1/(1+a0*exp(-r*h));
leap=[y, yy];
ts=[0 h];
for i=3:M+1
	yyy=y+2*r*h*yy*(1-yy);
	leap=[leap, yyy];
	ts=[ts t(i)];
	y=yy;
	yy=yyy;
	plot(ts,leap,'-r','LineWidth',1.1)
	if i==3
		legend(' Exact',' Leapfrog',2)
		% Set legend font to 14/bold 
		set(findobj(gcf,'tag','legend'),'FontSize',14,'FontWeight','bold');
	end;
	
%	pause(0.05);

	% make movie frame
	F(i-2) = getframe(gcf);

end;        

hold off

movie2avi(F,'leap.avi');