load(draw)$ 
set_draw_defaults(draw_realpart=false)$
fpprintprec:5$ ratprint:false$ kill(all)$

# Oligopoly

his chapter examines models that offer insights into the behavior of
oligopolists.

## Introduction and Overview

This section in the text defines oligopoly, emphasizing that each
firm makes its owns decisions. It also introduces game theory, which is often
used to analyze oligopoly.

## The Cournot Model

The illustration below rests on these assumptions:
Two firms constitute the industry (no additional entry).
Homogeneous product, so x1 and x2 can be summed. 
Single period of production and sales.
A linear inverse market demand curve: p = A + B*X = A + B*(x1 + x2).
Linear marginal cost curves: mc1 = b1 + c1*x1 and and mc2 = b2 + c2*x2.
Each firm determines its quantity and the market determines the price.

p(x1,x2,A,B):= A + B*(x1 + x2);
[mc1(x1,b1,c1) := b1 + c1*x1, mc2(x2,b2,c2):= b2+c2*x2];

Parameter values:

[A0,B0,b10,c10,b20,c20] : [100, -2, 5, 2, 10, 1]$
matrix(["Inverse Market Demand", "Firm1's mc", "Firm2's mc"],
[p(x1,x2,A0,B0),mc1(x1,b10,c10),mc2(x2,b20,c20)]);

Each firm takes the other's x as given and the firm reacts to the given
value. Therefore, We define each firm's reaction function in terms of the 
other firm's quantity produced. We define the two firms' profit 
functions, given the assumed behavior. F1 and F2 are fixed costs.

ratsimp(p(x1,x2,A,B)*x1-(F1+integrate(mc1(x1,b1,c1),x1)));
P1(x1,x2,A,B,b1,c1):= ''%$
ratsimp(p(x1,x2,A,B)*x2-(F2+integrate(mc2(x2,b2,c2),x2)));
P2(x1,x2,A,B,b1,c1):= ''%$

In each pair of equations above, the first command could be embedded
in the second command as below.

P1(x1,x2,A,B,b1,c1):= ''(
  ratsimp(p(x1,x2,A,B)*x1-(F1+integrate(mc1(x1,b1,c1),x1))));
P2(x1,x2,A,B,b1,c1):= ''(
  ratsimp(p(x1,x2,A,B)*x2-(F2+integrate(mc2(x2,b2,c2),x2))));

### Firms' Optimal Reactions

Derivatives of the two profit functions provide a set of two
equations. Both are expressed in terms of x1 and x2. Solving Firm1's
(Firm2's) output in terms of x1 (x2) generae the two expressions
for reaction curves. The third output line shows the two expressions
given the system's parameters.

solve(diff(P1(x1,x2,A,B,b1,c1),x1),x1); 
 R1(x2,A,B,b1,c1):=''(rhs(%[1]))$
solve(diff(P2(x1,x2,A,B,b2,c2),x2),x2);  
 R2(x1,A,B,b2,c2):=''(rhs(%[1]))$
radcan([R1(x2,A0,B0,b10,c10),R2(x1,A0,B0,b20,c20)]);

The two pairs of commands above could be collapsed into two single
commands as below. Also, subst( ) can be used to show the parameter-
defined expressions.

R1(x2,A,B,b1,c1):=''(rhs(solve(diff(P1(x1,x2,A,B,b1,c1),x1),x1)[1]));
subst([A=A0,B=B0,b1=b10,c1=c10],%);
R2(x1,A,B,b2,c2):=''(rhs(solve(diff(P2(x1,x2,A,B,b2,c2),x2),x2)[1]));
subst([A=A0,B=B0,b2=b20,c2=c20],%);

x1 can attain any of a range of values depending on x2, and vice versa. 
For both firms to be at equilibrium, the conjectures must be consistent 
with actual behavior.

To equilibrium values, solve the two reaction curve functions for x1 and 
x2. The resulting expressions are labeled x1N (N for Nash) and x2N.

Subscript treatment differs slightly from that in the text. The two 
approaches are logically equivalent.

solnNash: solve([R1(x2,A,B,b1,c1)=x1,R2(x1,A,B,b2,c2)=x2],
  [x1,x2])[1];
[x1N, x2N]: [rhs(solnNash[1]),rhs(solnNash[2])]$

The graph below shows the two reaction curves. Expressions x2max0 and x1max0 
are used to guide the graphing.

The code below solves for the monopoly levels of output for the two firms, 
and then depicts the reaction functions on a graph. 
The graph shows that if Firm 2 were to produce no output then Firm
1 (a monopolist) would produce $x1 = \frac{47.5}{3} = 15\frac{5}{7}$. 
Each one-unit change in $x2$ would reduce $x1$ by $\frac{1}{3}$, as 
we saw above. Likewise, if Firm 2 were a monopolist, the resulting
output would be 18 units, and Firm 2's output falls by $\frac{2}{5}$
units per one-unit increase in $x1$, so that $x1=45$ results in $x2=0$.

[[x1max,x2max] : [rhs(solve(R1(x1,A,B,b2,c2),x1)[1]),
     rhs(solve(R1(x2,A,B,b1,c1),x2)[1])],
[x1max0,x2max0]: subst([A=A0,B=B0,b1=b10,b2=b20],
  [x1max,x2max])];

wxdraw2d(xlabel="x1",ylabel="x2",line_width=2,key="R1",
implicit(R1(x2,A0,B0,b10,c10)-x1,x1,0,x1max0,x2,0,x2max0),
 color=red,key="R2", explicit(R2(x1,A0,B0,b20,c20),x1,0,x1max0), 
 title="Reaction Curves")$

### Solution

The values below are the Cournot solution.

[x1N0,x2N0]: float(subst([A=A0,B=B0,b1=b10,b2=b20,c1=c10,
   c2=c20],[x1N,x2N]))$     p0: p(x1N0,x2N0,A0,B0)$
matrix(["Firm1's x","Firm2's x","price"],[x1N0,x2N0,p0]);

The two firms' earn profit levels (ignoring fixed costs)
appear below.

P1cournot0:x1N0*p0-integrate(mc1(x1,b10,c10),x1,0,x1N0)$
P2cournot0:x2N0*p0-integrate(mc2(x2,b20,c20),x2,0,x2N0)$
Pcournot0: P1cournot0 + P2cournot0$
matrix(["Firm 1 Profit",P1cournot0],
["Firm 2 Profit",P2cournot0],["Total Profit",Pcournot0]);

Consider three aspects of the Cournot solution: how it compares to a 
situation in which the firms are price takers, the inefficiency implicit
in the solution, and how Cournot behavior compares to a situation 
in which the two firms collude to form a perfect cartel (monopoly).


Price Takers

If the two firms were price takers, then the horizontal sum of their 
marginal cost curves would be the industry supply curve.  The cell below
generates the hypothetical supply curve.

solve([mc1(x1,b1,c1)=p, mc2(x2,b2,c2)=p],[x1,x2]);
Xs(p,b1,c1,b2,c2):= ''(rhs(%[1][1])+rhs(%[1][2]));
Xd(p,A,B):= ''(rhs(solve(p=A + B*X,X)[1]));

f the two firms were price takers than the market would be as
represented in the next graph.

wxdraw2d(xlabel="x",ylabel="$ per unit",
 line_width=2, key="Supply",
 implicit(Xs(p,b10,c10,b20,c20)-X,X,0,50,p,0,50 ),
 color=green,key="Demand",
 implicit(Xd(p,A0,B0)=X,X,0,50,p,0,50),
 title="Market for Two Price Takers" )$

The next cell determines the price and quantity that the 
graph shows.

/* Equilibrium price function */
pcompexpr: solve(Xs(p,b1,c1,b2,c2)=Xd(p,A,B),p)$ 
pcomp(A,B,b1,c1,b2,c2):=''(rhs(%[1]))$

/* Price and quantity values */
pcomp0: float(pcomp(A0,B0,b10,c10,b20,c20))$
x1comp0:float(rhs(solve(mc1(x1,b10,c10)=pcomp0,x1)[1]))$
x2comp0:float(rhs(solve(mc2(x2,b20,c20)=pcomp0,x2)[1]))$
Xcomp0: x1comp0+x2comp0$

matrix(["Price,function","Price", "x1, comp", 
"x2, comp","Market X"],[rhs(pcompexpr[1]),
  pcomp0,x1comp0,x2comp0,Xcomp0]);

Profits are determined as before. The Cournot solutions are
added for comparison. Note the empty quotation marks, "", in
the first list inside matrix( ). All lists must have the same
length.

P1comp0: pcomp0*x1comp0 - 
  integrate(mc1(x1,b10,c10),x1,0,x1comp0)$
P2comp0: pcomp0*x2comp0 - 
  integrate(mc2(x2,b20,c20),x2,0,x2comp0)$
Pcomp0 : P1comp0+P2comp0$
matrix(["","Firm 1 Profit","Firm 2 Profit", 
"Total Profit, competition"],
["Price Takers",P1comp0,P2comp0,Pcomp0],
["Cournot",P1cournot0,P2cournot0,Pcournot0]);

Efficiency

The next cell compares consumer and producer surpluses when the
firms are price takers and when they are Cournot duopolists.

CScournot0:integrate(A0+B0*X,X,0,x1N0+x2N0)-p0*(x1N0+x2N0)$
CScomp0 : integrate(A0+B0*X,X,0,Xcomp0) - pcomp0*Xcomp0$
TotalCournot0: Pcournot0 + CScournot0$
TotalComp0: Pcomp0 + CScomp0$     
transpose(matrix(  
 ["CS, Cournot","CS, comp","Profits, Cournot","Profits,comp",
"Surpluses, Cournot","Surpluses, comp"],
 [CScournot0,CScomp0,P1cournot0,P1comp0,TotalCournot0,TotalComp0]));

Collusion

In a perfect cartel, the two firms treat each firm as a plant and allocate
production so that mc1 = mc2, in order to minimize total cost of each Xmonop
(Xmonop = x1monop + x2monop). They produce X such that mc = mr.

The first command produces the relationship between the firms' output, given 
equal mc values. The second command substitutes the result of the first 
command for x2 and solves for x1 in terms of Xmonop. The third command
uses the definition x2 = X - x1 to determine Firm2's output as a function
of Xmonop. The last command generates the relationship for our illustration.
(The solution applies over the range of Xmonop for which x2 is not negative.) 

solnmc: solve(mc1(x1,b1,c1)=mc2(x2,b2,c2),x2);
x1monop: rhs(solve(Xmonop=x1+rhs(solnmc[1]),x1)[1]);
x2monop: radcan(Xmonop-x1monop); [x1monop0,x2monop0]:
   subst([b1=b10,c1=c10,b2=b20,c2=c20],[x1monop,x2monop]);

Placing the terms in the list above into the two firms' mc curves
generate two identical expressions for the monopoly's mc curve.

radcan([mc1(x1monop,b1,c1),mc2(x2monop,b2,c2)]);
subst([b1=b10,c1=c10,b2=b20,c2=c20],%);

The next cell creates a function expression using Firm1 values.

MCmonop(Xmonop,b1,c1,b2,c2):= 
''(radcan(mc1(x1monop,b1,c1)));
MCmonop0(Xmonop):= ''(MCmonop(Xmonop,b10,c10,b20,c20));

Setting mc = mr yields an expression for the monopoly output.

solve(MCmonop(Xmonop,b1,c1,b2,c2)=A+2*B*Xmonop, Xmonop);
Xmonop(A,B,b1,c1,b2,c2):=''(rhs(%[1]));

The cell below shows X, x1, x2, and p for the monopoly.

[Xmonop0 : float(Xmonop(A0,B0,b10,c10,b20,c20)),
[x1monop0,x2monop0]:subst(Xmonop=Xmonop0,[x1monop0,
  x2monop0]),     pmonop0: A0+B0*Xmonop0];

The graph shows the same results.

wxdraw2d(xlabel="X",ylabel="$ per unit",points_joined=true,
 points([[0,pmonop0],[Xmonop0,pmonop0],[Xmonop0,0]]),
 line_width=2,key="MC, given that mc1 = mc1",  
 explicit(  MCmonop(X,b10,c10,b20,c20),X,0,50),color=black,
 key="Demand",explicit(A0+B0*X,X,0,50),color=red,
 key="MR",explicit(A0+2*B0*X,X,0,25))$

The table shows the consumer, producer, and total surplus values 
for the three cases that we have considered.

CSmonop0:float(integrate(A0+B0*X-pmonop0,X,0,Xmonop0))$
P1monop0:pmonop0*x1monop0 -integrate(mc1(x1,b10,c10),
   x1,0,x1monop0)$
P2monop0: pmonop0*x2monop0 -integrate(mc2(x2,b20,c20),
   x2,0,x2monop0)$
SurplusMonop0: CSmonop0+P1monop0+P2monop0;
matrix(["","Cournot","Competition","Collusion"],
  ["CS",CScournot0,CScomp0,CSmonop0],["P1",P1cournot0,
   P1comp0,P1monop0],["P2",P2cournot0,P2comp0,P2monop0],
  ["Surpluses",CScournot0+P1cournot0+P2cournot0,CScomp0+
  P1comp0+P2comp0,CSmonop0+P1monop0+P2monop0]);

Collusion gives each firm more profit than the Cournot equilibrium. The 
next two cells show, however, that both firms will cheat on a collusion
if they hold a Cournot view, thinking that the other firm's output can 
be treated as given (perhaps, each firm thinking that its increased output
will not be noticed by the other firm).

The first cell creates a draw( ) scenario in which Firm1 takes Firm2's
monopoly output as given.

Firm1: gr2d(yrange=[0,A0],xlabel="x1",ylabel="$ per unit",
 line_width=2,key="mc1", explicit(mc1(x,b10,c10),x,0,25),
 color=red,key="mr1", explicit(A0-x2monop0+2*B0*x,x,0,25),
 points_joined=true,key="x1monop0",line_type=dots,points(
  [[x1monop0,0],[x1monop0,A0-x2monop0+2*B0*x1monop0]]) )$

The second cell does the same for Firm2 and draws the resulting 
graphs. In each case the firm's (conjectural) marginal revenue 
exceeds its marginal cost.

Firm2: gr2d(yrange=[0,A0],xlabel="x2",ylabel="$ per unit",
 line_width=2,key="mc2", explicit(mc2(x,b20,c20),x,0,25),
 color=red, key="mr2", explicit(A0-x1monop0+2*B0*x,x,0,25),
 points_joined=true,key="x2monop0",line_type=dots,points(
  [[x2monop0,0],[x2monop0,A0-x1monop0+2*B0*x2monop0]]) )$ 
wxdraw(Firm1  ,Firm2, dimensions= [480,400])$

### Increasing the Number of Firms

The next cell adds a third firm to the industry. Firm3's marginal cost is 
intermediate between that of the first two firms

kill(all)$
p(x1,x2,x3,A,B):= A + B*(x1 + x2 + x3);
mc1(x1,b1,c1) := b1 + c1*x1; mc2(x2,b2,c2):= b2+c2*x2;
  mc3(x3,b3,c3):= b3+c3*x3;
[A0,B0,b10,c10,b20,c20,b30,c30] : 
   [100,-2,5.0,2.0,10.0,1.0,7.5,1.5]$

The profit functions are defined as before.

p(x1,x2,x3,A,B)*x1-(F1+integrate(mc1(x1,b1,c1),x1));
 P1(x1,x2,x3,A,B,b1,c1):= ''%$
p(x1,x2,x3,A,B)*x2 -(F2+integrate(mc2(x2,b2,c2),x2));
 P2(x1,x2,x3,A,B,b1,c1):= ''%$
p(x1,x2,x3,A,B)*x3-(F3+integrate(mc3(x3,b3,c3),x3));
 P3(x1,x2,x3,A,B,b1,c1):= ''%$

The reaction curves are defined as before.

solve(diff(P1(x1,x2,x3,A,B,b1,c1),x1),x1)$  
  R1(x2,x3,A,B,b1,c1):=''(rhs(%[1]));
solve(diff(P2(x1,x2,x3,A,B,b2,c2),x2),x2)$  
  R2(x1,x3,A,B,b2,c2):=''(rhs(%[1]));
solve(diff(P3(x1,x2,x3,A,B,b3,c3),x3),x3)$  
  R3(x1,x2,A,B,b3,c3):=''(rhs(%[1]));
[R10,R20,R30]:radcan([R1(x2,x3,A0,B0,b10,c10),
  R2(x1,x3,A0,B0,b20,c20),R3(x1,x2,A0,B0,b30,c30)]);

The three firms' output values are determined below. Firm1 and Firm2 
produce less than before, but total output rises.

soln3firms: float(solve([R10=x1,R20=x2,R30=x3],
    [x1,x2,x3])[1]);

The third firm results in increased output and a lower price. (Also, its
presence makes effecting and maintaining collusion more difficult.)

[X3: rhs(sum(soln3firms[i],i,1,3)), p3: A0+B0*X3];