(* 31C01000 Topics in Economic Theory and Policy *)
(* Economics of Strategy for Online and Digital Markets *)
(* Class examples - 15 Feb 2019. *)
(* Iivo Vehviläinen *)

(* First the network effects *)
(* Define the willingness to pay function *)
wtp[n_]:=(1000-n)*n;
(* Plot it *)
Plot[wtp[n],{n,0,1000}, AxesLabel->{v,p},PlotStyle->{Red,Thick}, Ticks->{{{0,0}, {1000,1000}},{}},PlotRangePadding->{Scaled[.01],0}]

(* Second the simplest platform example *)
(* Define the willingness to pay equations *)
(* Here nb is the number of buyers, ns the number of sellers, and 150 000 is the price *)
wtpb=(1000-nb)*ns-150000;
wtps=(1000-ns)*nb-150000;
(* Plot the arrows *)
plot1=VectorPlot[{wtpb,wtps},{nb,0,1100},{ns,0,1100}, VectorStyle->Arrowheads[.02],FrameTicks->False,PlotRangePadding->None,FrameLabel->{buyers,sellers}];
(* Plot the indifference curves, first solving when willingess-to-pay is equal to price *)
plot2=Plot[ns/.Solve[wtpb==0,ns],{nb,0,1000},PlotStyle->{Red,Thick},Axes->{False,False}];
plot3=Plot[ns/.Solve[wtps==0,ns],{nb,0,1200},PlotStyle->{Blue,Thick},Axes->{False,False}];
(* Solve the equilibria *)
eqp = {nb,ns}/.Join[Solve[{wtpb==0,wtps==0},{nb,ns}],{{nb->0,ns->0}}];
(* Combine and show all the plots *)
Show[{plot1,plot2,plot3},Epilog->{Black,PointSize[0.025],Point[eqp]}]