figure;
clf;
%findfigs;
hold on;
s=2/sqrt(3);
axis([0 s 0 1]);

% Triangle borders
line(s*[0 1/2],s*[0 sqrt(3)/2],'Color',[0 0 0],'LineWidth',2.5);
line(s*[1 1/2],s*[0 sqrt(3)/2],'Color',[0 0 0],'LineWidth',2.5);
line(s*[0 1],s*[0 0],'Color',[0 0 0],'LineWidth',2.5);
text(-0.05,0,'O_{1}','FontWeight','bold');
text(2/sqrt(3)+0.01,0,'O_{2}','FontWeight','bold');

% EndowSet
%x(1,:)=[0.5 0]; y(1,:)=[0.5 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
%x(1,:)=[0.0 0]; y(1,:)=[0.5 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
%line(s*[0.5 0.75],[0 1/2],'Color',[0 0 0],'LineWidth',1.5);
%text(s*0.75+0.02,1/2,'B','FontWeight','bold');
%line(s*[0.5 0.25],[0 1/2],'Color',[0 0 0],'LineWidth',1.5);
%text(s*0.25-0.045,1/2,'A','FontWeight','bold');
plot(s*0.5,0,'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
text(s*0.5-0.01,-0.03,'\omega','FontWeight','bold');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Fix the two agents' Cobb-Douglass preference parameters:
ai=0.75;
aj=0.25;

% here are Lindahl equilibrium prices and quantities
pi = (1-ai)/(1-ai+1-aj);
pj = (1-aj)/(1-ai+1-aj);
xeqi = ai/2;
xeqj = aj/2;
yeq = (1-ai)/(2*pi);

clear x y;
% Various agent-1 indifference curves
c=0.3;
x(1,:)=[0:0.01:1]; y(1,:)=(c*(x(1,:).^(-ai))).^(1/(1-ai));
line((1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0.7 0.7 0.7],'LineWidth',1);

c=0.5;
x(1,:)=[0:0.01:1]; y(1,:)=(c*(x(1,:).^(-ai))).^(1/(1-ai));
line((1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0.7 0.7 0.7],'LineWidth',1);

c=((xeqi)^ai)*((yeq)^(1-ai));
x(1,:)=[0:0.01:1]; y(1,:)=(c*(x(1,:).^(-ai))).^(1/(1-ai));
line((1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0.7 0.7 0.7],'LineWidth',1);

%PLR 1 offer curve
clear x y;
x(1,:)=(ai/2)*ones(1,101); y(1,:)=(1/2-x(1,1))./[0.1:0.1:10.1];
%line((1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0 0 0],'LineWidth',1);

clear x y;
% Various agent-2 indifference curves

c=0.3;
x(1,:)=[0:0.01:1]; y(1,:)=(c*(x(1,:).^(-aj))).^(1/(1-aj));
line(s-(1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0.7 0.7 0.7],'LineWidth',1,'LineStyle','--');

c=0.4;
x(1,:)=[0:0.01:1]; y(1,:)=(c*(x(1,:).^(-aj))).^(1/(1-aj));
line(s-(1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0.7 0.7 0.7],'LineWidth',1,'LineStyle','--');

c=((xeqj)^aj)*((yeq)^(1-aj));
x(1,:)=[0:0.01:1]; y(1,:)=(c*(x(1,:).^(-aj))).^(1/(1-aj));
line(s-(1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0.7 0.7 0.7],'LineWidth',1,'LineStyle','--');

%PLR 2 offer curve
clear x y;
x(1,:)=(aj/2)*ones(1,101); y(1,:)=(1/2-x(1,1))./[0.1:0.1:10.1];
%line(s-(1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0 0 0],'LineWidth',1);

% Lindahl equilibirum point
clear x y;
x(1,:)=[xeqi 0]; y(1,:)=[yeq 0];
plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);

% Equilibirum price hyperplane
clear x y;
x(1,:)=[0:0.01:0.5]; y(1,:)=(0.5-x(1,:))./(1-ai);
line((1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0 0 0],'LineWidth',1);

clear x y;
% PO Set
x(1,:)=[0:0.01:1]; y(1,:)=(1-aj)+((aj-ai)/ai).*x(1,:);
line((1/sqrt(3))*(2*x(1,:)+y(1,:)),y(1,:),'Color',[0 0 0],'LineWidth',0.5);

clear x y;
% Use these to show what one agent can get in autarky
%line(s*[0.5 0.75],[0 1/2],'Color',[0 0 0],'LineWidth',1.5);
%line(s*[0.5 0.25],[0 1/2],'Color',[0 0 0],'LineWidth',1.5);

% plotting single points
x(1,:)=[0.0 0]; y(1,:)=[0.7 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
x(1,:)=[0.0 0]; y(1,:)=[0.6 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
x(1,:)=[0.0 0]; y(1,:)=[0.5 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
x(1,:)=[0.3 0]; y(1,:)=[0.7 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
x(1,:)=[0.4 0]; y(1,:)=[0.6 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);
x(1,:)=[0.5 0]; y(1,:)=[0.5 0];
%plot((1/sqrt(3))*(2*x(1,1)+y(1,1)),y(1,1),'-ok','MarkerSize',5,'MarkerFaceColor',[0 0 0]);

axis off;