We simulate two competing firms in a Cournot duopoly market structure where each firm decides its production quantity ($q_1$ and $q_2$).
The firms interact under the following assumptions:
- Inverse Demand Function:
$( P = a - b(Q) )$, where $(Q = q_1 + q_2)$ is the total market quantity. - Cost Function:
$(C(q_i) = c \cdot q_i)$ (linear cost).
Given:
- $(a = 100)$: Intercept of demand curve.
- $(b = 2)$: Slope of demand curve.
- $(c = 20)$: Marginal cost for each firm.
Objective:
Find the Nash equilibrium where both firms choose output quantities that maximize their profits.
Python Implementation
We solve this problem using an optimization approach to find the equilibrium quantities for both firms.
1 | import numpy as np |
Code Explanation
Parameters:
a,b: Define the linear demand curve $(P = a - bQ)$.c: Marginal cost per unit.
Profit Maximization:
- The profit for each firm depends on the price and their quantity.
First-order conditions (gradients) are derived and solved numerically.
- The profit for each firm depends on the price and their quantity.
Optimization:
- We use the
scipy.optimize.minimizefunction to find Nash equilibrium quantities $(q_1, q_2)$.
- We use the
Visualization:
- Best-response curves for Firm 1 and Firm 2 are plotted.
- The Nash equilibrium is where the two curves intersect.
Explanation of Results
Optimal Quantity (Firm 1): 13.33 Optimal Quantity (Firm 2): 13.33 Market Price: 46.67 Profit (Firm 1): 355.56 Profit (Firm 2): 355.56

Optimal Quantities:
Both firms (Firm 1 and Firm 2) produce 13.33 units of output.
This is the symmetric Nash Equilibrium in a Cournot Duopoly, where neither firm has an incentive to unilaterally change its production.Market Price:
Given the total output of $( Q = 26.67 )$ ($13.33$ from each firm), the market price is determined to be 46.67.Profits:
Both firms earn a profit of 355.56.
The symmetry reflects the identical cost structures and competitive conditions.
Graph Interpretation
Best Response Curves:
- The blue line represents Firm 2’s best response curve, showing Firm 2’s optimal output for each quantity produced by Firm 1.
- The orange line represents Firm 1’s best response curve.
Nash Equilibrium:
- The intersection of the two best response curves, marked with a red dot, represents the equilibrium where both firms’ strategies are mutually optimal.
At the equilibrium point $(13.33, 13.33)$, both firms’ outputs are stable, and no firm can improve its profit by unilaterally changing its output.








