%make a plot of the spruce budworm RHS

set(0,                           ...
   'defaultaxesfontsize', 20,   ...
   'defaultaxeslinewidth', 1.0, ...
   'defaultlinelinewidth', 1.2, ...
   'defaultpatchlinewidth', 0.7); 

 
formatSpecF = '%5.1f\n';
%parameters

alf = 1.11;
Ku = 355;
a = alf/Ku
 
v = [0:.01:1];
slist = [3.,4,6,8];
xplace=[0.4,0.4,0.4,0.4];
yplace=[-0.16,0.1,0.6,1.1];
for j = 1:4
sig = slist(j);
f=sig*v.*(1-v)-v.^2./(a^2+v.^2);
figure(1)
plot(v,f,'linewidth',2)
hold on
xlabel('u/K_uS','fontsize',20)
ylabel('f_g(u)- f_d(u)','fontsize',20)
text(xplace(j),yplace(j),strcat('\sigma = ',sprintf(formatSpecF,sig)),'fontsize',20)
end

plot(v,zeros(101,1),'--','linewidth',2)
 
hold off
 
s = [3:.01:6];
a = 0.14;
R =  a.^2.*(a.^2+1)^2.*s.^3+ a.^2*(3.* a^2-5).*s.^2 +(3.* a^2-1/4).*s+1 ;
figure(2)
plot(s,R,s,zeros(length(s),1),'--','linewidth',2)
ylabel('R','fontsize',20)
xlabel('sigma','fontsize',20)

clear S
clear A
al = [0:.001:0.2];
s=[3:.01:6];
[S,A]=meshgrid(s,al);
Rp = 4*A.^6.*S.^3 + 8*A.^4.*S.^3 + 12*A.^4.*S.^2 + 4*A.^2.*s.^3 - 20*A.^2.*s.^2 ...
    + 12*A.^2.*S - S + 4;
 figure(3)
 
contour(S,A,Rp,[0 0],'linewidth',2);
ylabel('\kappa','fontsize',24)
xlabel('\sigma','fontsize',24)
text(3.5,0.07,'I','fontsize',20)
text(4.5,0.07,'II','fontsize',20)

