Graphic Approach to Cournot Games

with Linear Demand

General Setup for Quantity Games

Mathematica notes are presented in this format.

Economic notes are in this format.

Setup for the problem.

Because we want to study the analytical solution to this simply problem, we 
need to tell Mathematica what the parameters (or constants) of the model are.  
Everything else will be treated as a variable.  The semi-colons at the end of 
input lines suppress the display of output.

SetAttributes[a, Constant] 
SetAttributes[b, Constant] 
SetAttributes[c1, Constant] 
SetAttributes[c2, Constant]

The Clear command tells Mathematica to wipe out any previous values 
associated with the listed variables.    Below, we are clearing not only the 
constants but a number of other symbols which we will use later in the 
program.

Clear[a,b,c1,c2,temp1,temp2,pie1,pie2]; 
Clear[Q1,Q2,eqPr1,eqPr1,focPr1,focPr2,R2,pie1c,pie2c];

Total market quantity (Q) is the sum of firm 1's qty (Q1) and firm 2's qty (
Q2).

Q = Q1 + Q2 ;

A single equal sign (=) in a Mathematica input is used to specify an 
assignment.  It does not define an equation.  Therefore, the above statement 
specifies that the expression Q1 + Q2 will be assigned the variable name Q.

Next, we specify a functional form for the inverse market demand faced by the 
duopolists; in this case a linear function.

Price = a - b*Q ;

Cournot Game

Firm 2's payoff is simply its profit.

Profits of Firm 2's (Profit2) are equal to the output of firm 2 (Q2) 
multiplied by the difference between the unit revenue (P[Q1,Q2]) and the unit cost.  Firm 2's total revenue is firm 2's own quantity (Q2) times market price which is a function of firm 2's own quantity as well as firm 1's quantity (i.e.: P[Q1,Q2]).  Firm 2's total cost of production is quantity Q2 times a 
constant unit cost c.

eqPr2 = Profit2 == Q2(P[Q1,Q2] - c2) ;

The above statement defines the equation for the profits of firm 2 as 
specified in the above comment and assigns the name eqPr2 (equation for the 
profits of firm 2) to the equation.  It is important to note that the equal 
sign in the input is used in Mathematica for assigning names to expressions.  
It does not define a formula or equation.  To create a formula, you must use 
two consecutive equal signs (==).

Because a linear inverse demand function is given, we want to replace the 
general form of the price function with the linear demand given above (Price = 
a - bQ).

In Mathematica % refers to the last result generated (ie: %% uses the 2nd to 
last result generated) and /. is the replacement identifier.  So below, we 
take the original profit equation (defined above) and replace the general form 
of our demand equation P[Q1,Q2] with our explicit linear inverse demand 
equation "Price" which is specified above.

eqPr2 = Expand[%/. P[Q1,Q2] -> Price]

To find firm 2's profit maximizing quantity define a new equation named 
focPr2 (representing the first order condition of the profit equation of firm 
2) to be the derivative (D[ ]) of firm 2's profit (payoff) function with 
respect to its choice of its own quantity Q2.

focPr2 = D[eqPr2, Q2]

Use the Mathematica Solve statement to solve the first order condition for Q2 
and name the output temp2.  It is helpful to note that the output from a solve 
statement is a list of solutions.  Consequently, temp2 is the name of the list 
of solutions.  In the case below, the list temp2 has only one solution and 
therefore a single element.

temp2 = Solve[focPr2, Q2]

It is clear from the first order condition above that firm 2's optimal choice 
of Q2 will depend on firm 1's optimal choice Q1.  This is the key to game 
theoretic problems; each party must consider what the other parties will do.  
Because firm 2's choice of Q2 is a function of firm 1's choice Q1, we call the 
expression above firm 2's Best Response or Reaction Function.  As its name 
implies, this function dictates how firm 2 chooses Q2 as a best response (or 
in reaction) to firm 1's choice Q1.  In the simply linear case, we can solve 
for firm 2's best response quantity (R2[Q1]) explicitly.

Note: In the next line of code, we create an expression called React2 (firm 2'
s reaction function) that represents firm 2's optimal response (R2[Q1]) to 
firm 1's quantity choice Q1.  The right hand side of this expression is simply 
the solution for Q2 that we found above.  In other words, R2[Q1] is equal to 
Q2 where Q2 is replaced ( /. ) by the first solution ( [[1]] ) from the output 
list "temp2".  R2[Q1] is just another name for Q2 that reflects the fact that 
this quantity is chosen in response to Q1.

React2 = R2[Q1] == Q2 /. temp2[[1]]

Next, we use the Plot[] command to provide a graph of the reaction curve.  The
syntax for the Plot command is Plot[f, {x, xmin, xmax}, option -> value] where f is the expression to be plotted, the list {x, xmin, xmax} specifies the minimum and maximum values that the variable in the expression takes, and option -> value statements are used to set any display attributes of the graph.

reactPlot =  
	Plot[{Q2 /. Solve[focPr2 /. {a -> 1, b -> 1, c2 -> .5},Q2][[1]]}, 
	     {Q1, 0, .55}, 
	     PlotRange -> {0, .55}, 
	     PlotStyle->{RGBColor[1,0,0],Thickness[0.010]}, 
	     AxesLabel->{"Q1","Q2"}, 
	     PlotLabel->"Reaction Curve" ]

Firm 1's payoff is simply its profit.

In the simultaneous move Cournot game, firm 1 solves for its own Best Response 
quantity in the same manner as firm 2 has. 
The profits of Firm 1 (Profit1) are equal to the difference between the 
revenue from selling its own quantity Q1 and the cost of selling this 
quantity.

eqPr1 = Profit1 == Q1*(P[Q1,Q2]-c1) ;

The above statement defines the equation for the profits of firm 1 as 
specified in the above comment and assigns the name eqPr1 (equation for the 
profits of firm 1) to the equation.

Once again, because a linear demand function is given, we replace the general 
form of the price function with the linear demand given above (Price = a - bQ)
.

eqPr1 = Expand[%/. P[Q1,Q2] -> Price]

To find firm 1's profit maximizing quantity define a new equation named 
focPr1 (first order condition of the profit equation of firm 1) to be the 
derivative (D[ ]) of firm 1's profit (payoff) function with respect to its 
choice of its own quantity Q1.

focPr1 = D[eqPr1, Q1]

Use the Mathematica Solve statement to solve the first order condition for Q1 
and name the output temp1.

temp1 = Solve[focPr1, Q1];

Note: We name the function relating firm 1's optimal response (R1[Q2]) to 
firm 2's quantity choice "React1".

React1 = R1[Q2] == Simplify[Q1 /. temp1[[1]]]

reactPlot =  
	Plot[{Q2 /. Solve[focPr1 /.{a -> 1, b -> 1, c1 -> .5}, Q2][[1]]}, 
	     {Q1, 0, .55}, 
	     PlotRange -> {0, .55}, 
	     PlotStyle->{RGBColor[0,0,1],Thickness[0.001]}, 
	     AxesLabel->{"Q1","Q2"}, 
	     PlotLabel->"Reaction Curve"]

Next a plot is made to show the sensitivity of the reaction function of firm 1 
to a change in the unit cost from 0.5 to 0.6.

reactPlot =  
	Plot[{Q2 /. Solve[focPr1 /.{a -> 1, b -> 1, c1 -> .5}, Q2][[1]], 
	      Q2 /. Solve[focPr1 /.{a -> 1, b -> 1, c1 -> .6}, Q2][[1]]},  
	     {Q1, 0, .55}, 
	     PlotRange -> {0, .55}, 
	     PlotStyle->{{RGBColor[0,0,1],Thickness[0.001],                  }, 
			 {RGBColor[0,0,1],Thickness[0.001],Dashing[{.03,.02}]} 
			}, 
	     AxesLabel->{"Q1","Q2"}, 
	     PlotLabel->"Reaction Curves"]

Solution to the simply Cournot Game.

At this point we have the reaction functions (or best response functions) for 
both of the Cournot firms.  Each of these functions specifies how the firm 
will choose its optimal quantity in response to the quantity choice of the 
other firm.  If we knew firm 1's choice of Q1 we could solve firm two's 
reaction function for its optimal choice of Q2.  Similarly, if we knew firm 2'
s choice Q2 we could solve firm one's reaction function for its optimal choice 
of Q1.  The difficulty with the Cournot game is that the players 
simultaneously choose their respective quantities.  Therefore, the solution to 
the simultaneous move Cournot game is found by solving both firms' reaction 
functions simultaneously for the quantities Q1 and Q2.  Intuitively, the 
solution to the Counot game has each firm choosing its best response quantity 
in reaction to the hypothesized quantity of the other firm.

reactPlot =  
	Plot[{Q2 /. Solve[focPr1 /.{a -> 1, b -> 1, c1 -> .5}, Q2][[1]], 
              Q2 /. Solve[focPr2 /.{a -> 1, b -> 1, c2 -> .5}, Q2][[1]]}, 
	     {Q1, 0, .55}, 
	     PlotRange -> {0, .55}, 
	     PlotStyle->{{RGBColor[0,0,1],Thickness[0.001]}, 
			 {RGBColor[1,0,0],Thickness[0.010]} 
			}, 
	     AxesLabel->{"Q1","Q2"}, 
	     PlotLabel->"Reaction Curves"]