Sub topic 7
Finding Equilibrium with Linear Equations
This chapter assumes you can solve a linear equation, read a price-quantity graph with price on the vertical axis, and recognize a demand curve (quantity demanded falls as price rises) and a supply curve (quantity supplied rises as price rises). You will turn those two curves into equations and solve them for the equilibrium price and quantity. You will also check the answer, see the common ways the algebra goes wrong, and handle the edge cases where the solution is not economically meaningful.
The setup: two equations, two unknowns
A market has two unknowns: the price P and the quantity traded Q. A linear model gives one equation for each side of the market.
- Demand: Qd = a − b·P
- Supply: Qs = c + d·P
Here Qd is the quantity demanded and Qs is the quantity supplied. The parameters have these roles:
| Parameter | Meaning | Usual sign |
|---|---|---|
| a | Demand intercept: the quantity demanded if the price were 0 | positive |
| b | Demand slope in quantity terms: how many units demand falls when price rises by 1 | positive (so −b is negative) |
| c | Supply intercept: the quantity supplied if the price were 0 | any sign |
| d | Supply slope in quantity terms: how many units supply rises when price rises by 1 | positive |
The sign convention matters. In this form the demand equation already contains the minus sign, so b is a positive number. If you write demand as Qd = a + bP and plug in a positive b, you have described an upward-sloping demand curve, which is a different (and unusual) market.
The supply intercept c is often negative. That is not a mistake. It means sellers offer nothing until the price rises above some minimum, as the next sections show.
A market is in equilibrium when quantity demanded equals quantity supplied: Qd = Qs. At that price, every buyer who wants to buy at that price finds a seller, and every seller finds a buyer, so there is no pressure to change the price.
Solving step by step
Set Qd equal to Qs and solve for P.
- Start with the equilibrium condition: a − b·P = c + d·P
- Collect the P terms on one side: a − c = b·P + d·P
- Factor out P: a − c = (b + d)·P
- Divide: P* = (a − c) / (b + d)
The star marks the equilibrium value. To find the quantity, substitute P* into either equation. Both must give the same answer, which makes a useful check.
- Q = a − b·P
- Q = c + d·P
Notice what the formula says. The numerator a − c is the horizontal gap between the curves at a price of zero. The denominator b + d is the combined responsiveness of both sides. A large initial gap pushes the price up. Strong responsiveness on either side holds the price down, because only a small price change is needed to close the gap.
A worked example
Take demand Qd = 100 − 2P and supply Qs = −20 + 4P. Here a = 100, b = 2, c = −20 and d = 4.
- P* = (100 − (−20)) / (2 + 4) = 120 / 6 = 20
- Q* = 100 − 2·20 = 60
- Check with supply: −20 + 4·20 = 60
Both equations give 60, so the solution is consistent. The same calculation in code:
def equilibrium(a, b, c, d):
# Demand: Qd = a - b*P Supply: Qs = c + d*P
price = (a - c) / (b + d)
quantity = a - b * price
return price, quantity
print(equilibrium(100, 2, -20, 4))Running it prints (20.0, 60.0).
Checking the answer with excess demand
A second way to confirm an equilibrium is to compute excess demand, which is Qd − Qs at a given price. It is positive when there is a shortage, negative when there is a surplus, and zero at equilibrium.
For this market, excess demand is (100 − 2P) − (−20 + 4P) = 120 − 6P. This is zero when P = 20, which matches the formula. It also shows why the market tends toward that price: below 20 the expression is positive (buyers want more than sellers offer), and above 20 it is negative.
def excess_demand(price):
qd = 100 - 2 * price
qs = -20 + 4 * price
return qd - qs
for p in (10, 20, 30):
gap = excess_demand(p)
kind = "shortage" if gap > 0 else "surplus" if gap < 0 else "equilibrium"
print(p, gap, kind)The output is:
10 60 shortage
20 0 equilibrium
30 -60 surplusAt a price of 10, buyers want 80 units and sellers offer only 20, so the shortage is 60. At a price of 30, buyers want 40 and sellers offer 100, so the surplus is 60. The size of the gap is a direct measure of how far the price is from equilibrium.
Why the price moves toward equilibrium
The algebra tells you where equilibrium is. It does not say how the market gets there. The usual story is that a shortage lets sellers raise prices, because buyers compete for scarce units, and a surplus makes sellers cut prices to clear unsold stock. A simple way to model this is to raise the price in proportion to excess demand each round.
price = 10.0
for step in range(8):
qd = 100 - 2 * price
qs = -20 + 4 * price
print(step, round(price, 2), qd, qs)
price += 0.05 * (qd - qs)The price starts at 10 and rises toward 20, while the gap between Qd and Qs shrinks each step. Here the adjustment speed of 0.05 is an assumption of this model, not something the demand and supply equations determine. Each round closes 30% of the remaining gap to the equilibrium price, because 0.05 × 6 = 0.3, where 6 is b + d. So the gap after n rounds is 0.7ⁿ times the original gap.
This is a reminder of an important separation. The equilibrium formula depends only on a, b, c and d. How fast the market arrives depends on additional assumptions about how sellers and buyers react.
Comparative statics: what happens when a parameter changes
Once you have a formula for equilibrium, you can see how it responds to changes. A shift in demand changes a. A shift in supply changes c. Changes in slope change b or d.
Suppose demand increases so that the intercept rises from 100 to 130, with the supply curve unchanged. Reusing the function:
print(equilibrium(130, 2, -20, 4))This prints (25.0, 80.0). Check by hand: P = (130 + 20) / 6 = 25, and Q = 130 − 2·25 = 80. Both price and quantity rise, which matches the rule that a rightward demand shift raises both.
The formula also gives the size of the change directly. Since P* = (a − c) / (b + d), a one-unit rise in a raises the price by 1 / (b + d). In this example that is 1/6, so a rise of 30 in a raises the price by 5. The slopes b and d control the pass-through: the steeper the responsiveness of buyers and sellers (large b and d), the less the price has to move.
Supply shifts work in the opposite direction on price. Raising c by 12 (an increase in supply) lowers P* by 12/6 = 2 and raises the quantity.
Common errors
The mistakes below account for most wrong answers on this type of problem.
- Sign errors with negative c. Subtracting a negative intercept means adding. In the example, a − c = 100 − (−20) = 120, not 80.
- Mixing up slope conventions. If a problem gives price as a function of quantity (inverse demand, P = 50 − 0.5Q), the slope is 0.5 in price terms. The quantity-form coefficient is its reciprocal: Q = 100 − 2P. Using 0.5 as b in the formula gives a wrong answer.
- Solving for the wrong variable. The equation Qd = Qs gives P first. Substituting it back gives Q. Stopping at P leaves the problem half-done.
- Checking with only one equation. Substituting into just one curve cannot reveal an error in the other. Use both.
- Assuming the result is valid. The next section covers this.
Edge cases: when the solution does not make sense
A linear model is a local approximation. It can return numbers that no market could produce.
Negative price or quantity. Suppose a = 10, b = 2, c = 30 and d = 1. Then P* = (10 − 30) / 3 = −6.67. A negative price means the supply curve sits entirely to the right of the demand curve at every non-negative price. Sellers would not supply at all at any price buyers will pay. The sensible conclusion is that no trade occurs, not that the price is −6.67.
Supply that starts above zero price. With c = −20 and d = 4, supply is zero at P = 5, since −20 + 4P = 0. Below a price of 5 the formula gives negative quantities, which are impossible. The correct supply is max(0, c + d·P). Equilibrium is valid only if the quantity at P is at least zero on both sides, which holds here since Q = 60.
Zero slope sum. If b + d = 0, the formula divides by zero. With b > 0 and d > 0 this cannot happen. It can occur if you have an upward-sloping demand curve (negative b) that cancels the supply slope, and then the curves are parallel or coincide. Parallel curves with different intercepts have no equilibrium. Coincident curves have infinitely many.
Multiple or unstable equilibria. Two straight lines cross at most once, so a linear model has a single equilibrium whenever one exists. Curved or kinked curves can cross several times, and then the algebra needs more care.
A short guard in code makes these checks explicit:
def safe_equilibrium(a, b, c, d):
if b + d == 0:
return None # parallel or identical curves
price = (a - c) / (b + d)
quantity = a - b * price
if price < 0 or quantity < 0:
return None # no economically meaningful trade
return price, quantity
print(safe_equilibrium(100, 2, -20, 4))
print(safe_equilibrium(10, 2, 30, 1))The first call prints (20.0, 60.0). The second prints None, because the computed price is negative.
Summary of the method
- Write demand and supply in quantity form, with signs checked.
- Set Qd = Qs and solve for P* = (a − c) / (b + d).
- Substitute P into both equations to get Q and confirm they match.
- Check that P and Q are non-negative and that the formula's denominator is not zero.
- For a shift, change the relevant intercept and recompute, or use the 1 / (b + d) pass-through.
Exercise
Demand is Qd = 200 − 5P and supply is Qs = 20 + 1P. (a) Find the equilibrium price and quantity. (b) At a price of 25, state whether there is a shortage or a surplus and compute its size. (c) Supply then shifts so the intercept becomes 50 (Qs = 50 + P). Find the new equilibrium and say whether price rises or falls.
Show answer
(a) P = (200 − 20) / (5 + 1) = 30, and Q = 200 − 5·30 = 50. Check with supply: 20 + 30 = 50. (b) At P = 25, Qd = 200 − 125 = 75 and Qs = 20 + 25 = 45, so there is a shortage of 30. (c) P = (200 − 50) / 6 = 25, and Q = 200 − 125 = 75. Price falls from 30 to 25 and quantity rises from 50 to 75, as expected for an increase in supply.
Exercise
A market has demand Qd = 40 − 2P and supply Qs = 60 + 3P. Compute the formula result for P*, then explain whether it is a valid market outcome.
Show answer
P* = (40 − 60) / (2 + 3) = −4. A negative price is not a valid outcome. At a price of 0, demand is 40 but supply is already 60, so sellers would offer more than buyers want even for free. Supply exceeds demand at every non-negative price, so the market does not clear at a positive price and no meaningful trade-off price exists in the model.