Supply and demand equilibrium calculator
A straight demand line Qd = a − bP slopes down when b is greater than 0. A straight supply line Qs = c + dP slopes up when d is greater than 0. They meet at one price, P* = (a − c) / (b + d), and one quantity, Q* = a − bP*. At any other price the two quantities differ. If buyers want more than sellers offer, the gap is a shortage. If sellers offer more than buyers want, the gap is a surplus. This page runs that arithmetic in your browser. It is a classroom sketch for AP Macroeconomics and introductory economics, not a reading of a UK or US market, and not advice about prices.
Which calculation
Equilibrium. Enter Qd = a − bP and Qs = c + dP. The page solves for the price and quantity where the lines meet, then the consumer surplus and producer surplus areas when price and quantity are both positive.
Quantity demanded when the price is 0, in Qd = a − bP. The EXAMPLE default is 100. a may be any finite number. A negative a means quantity demanded is already below 0 at a price of 0.
How much quantity demanded falls when the price rises by 1. The EXAMPLE default is 2, so the EXAMPLE demand line is Qd = 100 − 2P. Enter a number greater than 0. Zero and negative values flip the usual downward slope.
Quantity supplied when the price is 0, in Qs = c + dP. The EXAMPLE default is 10. c may be positive, zero, or negative. A negative c means the supply line meets the vertical axis at a positive price.
How much quantity supplied rises when the price rises by 1. The EXAMPLE default is 1, so the EXAMPLE supply line is Qs = 10 + P. Enter a number greater than 0. Zero and negative values flip the usual upward slope.
The price to test. The EXAMPLE default is 20. With the EXAMPLE lines, 20 is below the equilibrium price of 30, quantity demanded is 60, quantity supplied is 30, and the shortage is 30.
Equilibrium price
Equilibrium quantity
Quantity demanded at this price
Quantity supplied at this price
Consumer surplus
Producer surplus
Total surplus
Formula with your numbers
How to read this
The EXAMPLE uses invented numbers, Qd = 100 − 2P and Qs = 10 + P. These are not statistics for any country or any good. Equilibrium price is (100 − 10) / (2 + 1) = 90 / 3 = 30. Equilibrium quantity is 100 − 2 × 30 = 40, and the supply line agrees: 10 + 30 = 40. The demand choke price, where quantity demanded is 0, is 100 / 2 = 50. Consumer surplus is 0.5 × (50 − 30) × 40 = 400. Supply meets the horizontal axis at quantity 10, so producer surplus is a trapezoid: 10 × 30 + 0.5 × 1 × 30 × 30 = 750. Total surplus is 1,150. At price 20, quantity demanded is 60 and quantity supplied is 30, so the shortage is 30. At price 40, quantity demanded is 20 and quantity supplied is 50, so the surplus is 30. Equilibrium mode opens on these lines. Shortage or surplus mode opens at price 20.
Not investment advice and not advice about price controls. Nothing here says a government should set a ceiling, set a floor, or change a tax. A price from this sketch is not a forecast. The calculator does not fetch live data.
The classroom formula
Qd = a − bP
Qs = c + dP
P* = (a − c) / (b + d)
Q* = a − bP*
The letter a is quantity demanded at a price of 0. The letter b is the drop in quantity demanded when the price rises by 1. For the usual downward demand line, b is greater than 0. The letter c is quantity supplied at a price of 0. c may be positive, zero, or negative. The letter d is the rise in quantity supplied when the price rises by 1. For the usual upward supply line, d is greater than 0. Units are whatever you have in mind. The page does not name a currency.
Set the quantities equal: a − bP = c + dP. Collect the price terms on one side: a − c = (b + d)P. Divide by (b + d). That is P*. Then substitute back into demand: Q* = a − bP*. Substitute into supply as a check: Q* = c + dP*. The two expressions for Q* are the same algebra when b + d is not 0. If b + d equals 0, the division is not defined, and the lines are parallel in a way that does not give a single price. A b or a d of 0 or below flips a slope. This calculator rejects those inputs.
At a chosen price P0, quantity demanded is Qd0 = a − bP0 and quantity supplied is Qs0 = c + dP0. When Qd0 is greater than Qs0, the shortage is Qd0 − Qs0. When Qs0 is greater than Qd0, the surplus is Qs0 − Qd0. When the two quantities are equal, that price is an equilibrium price. A negative quantity means the straight line has crossed an axis. A market graph usually stops at 0. The calculator still reports the straight line value, so you can see the arithmetic before you trim the graph.
Consumer surplus, for a straight demand line with positive price and positive quantity, is the triangle under demand and above the price, from quantity 0 out to Q*. Demand meets the vertical axis at the choke price a / b. Consumer surplus = 0.5 × (a / b − P*) × Q*. The area is positive when the choke price is above P*, which is the same condition as Q* greater than 0.
Producer surplus is the area above supply and below the price, from quantity 0 out to Q*, counting only the region where price and quantity are both at least 0. When c is 0 or negative, supply meets the vertical axis at the price −c / d, which is 0 or positive. Producer surplus is then the triangle 0.5 × (P* − (−c / d)) × Q*. When c is positive, sellers offer c units at a price of 0, so supply meets the horizontal axis at quantity c. The area is a trapezoid: c × P* plus the triangle 0.5 × d × P* × P*. The triangle formula that uses a negative intercept −c / d includes a wedge below the horizontal axis. This page leaves that wedge out.
Those areas are equilibrium areas. They are not the shortage or the surplus of units at some other price. Total surplus here is consumer surplus plus producer surplus. A price ceiling or a price floor changes which units trade, and the lost area on that diagram is a further topic. This page stops at the equilibrium areas and at the unit gap.
Worked example. Demand is 100 − 2P. Supply is 10 + P. Then a = 100, b = 2, c = 10, and d = 1. P* = (100 − 10) / (2 + 1) = 30. Q* = 100 − 2 × 30 = 40. Choke price = 50. Consumer surplus = 0.5 × (50 − 30) × 40 = 400. Because c is positive, producer surplus = 10 × 30 + 0.5 × 1 × 900 = 750. Total surplus = 1,150. At P0 = 20, Qd0 = 60 and Qs0 = 30, so the shortage is 30. At P0 = 40, Qd0 = 20 and Qs0 = 50, so the surplus is 30. At P0 = 30, the quantities match.
| Price | Quantity demanded | Quantity supplied | Gap |
|---|---|---|---|
| 20 | 60 | 30 | Shortage of 30 |
| 30 | 40 | 40 | Equilibrium |
| 40 | 20 | 50 | Surplus of 30 |
A second EXAMPLE uses a negative supply intercept so producer surplus is a triangle. Keep Qd = 100 − 2P and set Qs = −10 + P, so c = −10 and d = 1. P* = (100 − (−10)) / (2 + 1) = 110 / 3. Q* = 80 / 3. Supply meets the vertical axis at price 10. Producer surplus = 0.5 × (110 / 3 − 10) × (80 / 3) = 3,200 / 9. Consumer surplus = 0.5 × (50 − 110 / 3) × (80 / 3) = 1,600 / 9. Type a = 100, b = 2, c = −10, and d = 1 to see the rounded display of those same fractions. The figures are still invented classroom arithmetic.
Changing a, with b held fixed, is one way to sketch a demand shift. Changing c, with d held fixed, is one way to sketch a supply shift. Type the new intercept and calculate again. Elasticity is a separate idea. The slope is one input, and price elasticity also depends on the price and the quantity at a point. This calculator reports the slope arithmetic for price, quantity, the unit gap, and the equilibrium areas.
UK and US framing
UK and US courses teach this arithmetic early. In the United States, AP Macroeconomics Unit 1 includes demand, supply, and market equilibrium. The course description lists topic 1.4 Demand, topic 1.5 Supply, and topic 1.6 Market Equilibrium, Disequilibrium, and Changes in Equilibrium. Those names are course context only. This page is not an official exam question and is not affiliated with the College Board. In the United Kingdom, introductory and A level economics use the same straight lines. The numbers on this page are a classroom sketch. They are not a UK market and they are not a US market.
A calculated price is not a forecast of groceries, housing, or energy, and it is not a recommendation to buy, sell, or pass a price rule. For how a real price index is built, read inflation. For the one line definitions, see equilibrium and elasticity. For the wider setting, read supply and demand. Questions about what this site is, and is not, are on the FAQ.
Sources
- College Board: AP Macroeconomics course (Unit 1, Basic Economic Concepts, as course context only)
- College Board: AP Macroeconomics Course and Exam Description (topic 1.4 Demand, topic 1.5 Supply, topic 1.6 Market Equilibrium, Disequilibrium, and Changes in Equilibrium)
- OpenStax: Principles of Economics 3e, 3.1 Demand, Supply, and Equilibrium in Markets for Goods and Services
- OpenStax: Principles of Economics 3e, 3.4 Price Ceilings and Price Floors
- OpenStax: Principles of Economics 3e, 3.5 Demand, Supply, and Efficiency
All calculators · Supply and demand · Equilibrium · Elasticity · Opportunity cost calculator · FAQ