Supply and demand studio
Drag the demand and supply lines, or type their equations, and watch the equilibrium, the surplus areas and the effect of a per-unit tax or subsidy update as you go.
Inputs
The price at which buyers want nothing (a in P = a − bQ). Raising it shifts demand up and to the right.
How much the price falls for each extra unit (b). Enter it as a positive number; 0 is flat.
The lowest price at which sellers offer anything (c in P = c + dQ). It can be negative.
How much the price must rise for each extra unit sellers offer (d).
0 means no policy. It makes no difference whether the law puts the tax on buyers or on sellers.
Equilibrium price
40
Equilibrium quantity 30. At this price buyers want to buy exactly as much as sellers want to sell.
- Equilibrium quantity
- 30
- Consumer surplus
- 900
- Producer surplus
- 450
- Total surplus
- 1,350
- Price elasticity at equilibrium
- demand −0.667 · supply 1.33
- Demand
- P = 100 − 2Q
- Supply
- P = 10 + Q
- Demand (D)
- Supply (S)
- Consumer surplus 900
- Producer surplus 450
Drag a line, its round knob or its ring to move it. On a keyboard, tab to a knob and use the arrow keys.
Demand P = 100 − 2Q and supply P = 10 + Q cross at a price of 40 and a quantity of 30. Without any policy, consumer surplus (the triangle under demand and above the price) is 900 and producer surplus (above supply and below the price) is 450, a total of 1,350.
How to read this graph
- Price goes up the side, quantity along the bottom. Every point on a line answers “at this price, how many?”
- Demand (D, blue) slopes down. The lower the price, the more people want to buy.
- Supply (S, orange) slopes up. The higher the price, the more sellers want to sell.
- The dot where they cross is the equilibrium (E). At that price buyers want exactly as much as sellers offer, so there’s no shortage and no pile of unsold goods.
- The blue triangle is consumer surplus: what buyers would have paid, minus what they did pay. The orange triangle is producer surplus: what sellers got, minus the least they’d have accepted.
- Add a tax with the slider and a gap (the wedge) opens between the price buyers pay and the price sellers keep. Fewer units trade. The green rectangle is the tax the government collects, and the hatched triangle is the deadweight loss: value from trades that no longer happen, which nobody gets.
- Move a curve to ask “what if?” Drag demand up and to the right (more buyers, higher incomes) and both price and quantity rise. Drag supply to the right (cheaper inputs, better technology) and the price falls while quantity rises.
How it works
The curves are straight lines, written with price on the left as they’re drawn:
demand P = a − b × Q supply P = c + d × Q equilibrium Q* = (a − c) ÷ (b + d) P* = a − b × Q* with a per-unit tax t (a subsidy is a negative tax): quantity Q = (a − c − t) ÷ (b + d) buyers pay Pb = a − b × Q sellers keep Ps = Pb − t consumer surplus = ½ × Q × (a − Pb) producer surplus = ½ × Q × (Ps − c) tax revenue = t × Q (for a subsidy, its cost = s × Q) deadweight loss = ½ × t × (Q* − Q)
- a is where demand meets the price axis: the most anyone would pay for the first unit. c is where supply meets it: the least any seller would take.
- b and d are the slopes: how far the price changes for one more unit. Enter them as positive numbers.
- Who bears a tax. Buyers bear b ÷ (b + d) of it and sellers d ÷ (b + d). The steeper (less elastic) side bears more.
- Elasticity at equilibrium is the point elasticity (1 ÷ slope) × P* ÷ Q*, negative for demand.
- Nothing has units. Use dollars and units, euros and tonnes, or whatever your problem uses.
Worked example
Barkley’s gasoline market (Kansas State): demand P = 8 − Q, supply P = 2 + Q, a tax of 2 per gallon. Open it in the studio.
- Equilibrium: 8 − Q = 2 + Q, so Q* = 3 and P* = 5. Consumer surplus is ½ × 3 × (8 − 5) = 4.5, producer surplus the same, 9 in total.
- With the tax: Q = (8 − 2 − 2) ÷ 2 = 2. Buyers pay 8 − 2 = 6, sellers keep 6 − 2 = 4.
- Surplus after the tax: consumers ½ × 2 × (8 − 6) = 2 (down 2.5), producers ½ × 2 × (4 − 2) = 2 (down 2.5), tax revenue 2 × 2 = 4, deadweight loss ½ × 2 × (3 − 2) = 1. Check: 2 + 2 + 4 + 1 = 9, the surplus we started with.
- Both lines have the same slope, so buyers and sellers each bear half the tax (1 each).
More worked problems to open and compare:
- OpenStax pizzas: Qd = 16 − 2P and Qs = 2 + 5P cross at P = 2 and Q = 12.
- UW–Madison soft drinks: a 4 tax on Q = 20 − P and Q = 3P. Quantity falls from 15 to 12, buyers pay 8, sellers keep 4, revenue 48, deadweight loss 6. Buyers bear three quarters of the tax.
- Barkley’s corn subsidy: a subsidy of 2 raises quantity from 2.5 to 3, buyers pay 6 and sellers get 8. It costs 6, buyers and sellers each gain 2.75, and 0.5 is lost.
Tips
- Check your algebra against the graph. If your Q* doesn’t sit under the crossing point, one of your equations is probably upside down (Qd = … instead of P = …).
- Try the extremes. Flatten demand (slope near 0) and add a tax: sellers bear almost all of it. Make supply very steep and buyers barely notice it. That’s tax incidence in one drag.
- Watch the deadweight loss grow. Doubling a tax quadruples the deadweight loss (as long as some trade continues), because both the height and the width of the triangle double.
- A tax bigger than a − c stops all trade. The studio says so, and the whole surplus becomes deadweight loss.
- The model is a simplification. Real curves bend, and markets with a few big sellers don’t behave like this one. It’s the competitive-market model from principles courses.
FAQ
How do you find the equilibrium price and quantity?
Set the two equations equal and solve. With demand P = 100 − 2Q and supply P = 10 + Q, 100 − 2Q = 10 + Q gives Q = 30, and putting 30 back into either line gives P = 40. On the graph it's where the lines cross.
My textbook writes demand as Qd = 16 − 2P. How do I enter that?
Turn it round so price is on its own. Qd = 16 − 2P becomes P = 8 − 0.5Q, so the demand intercept is 8 and the slope 0.5. Move the P term to one side, then divide everything by the number in front of P. Qs = 2 + 5P becomes P = −0.4 + 0.2Q. The Demand and Supply boxes under the result show both forms so you can check.
Does it matter whether the tax is on buyers or on sellers?
No. The price buyers pay, the price sellers keep, the quantity, the revenue and the deadweight loss come out the same either way. What decides who bears more of the tax is which curve is steeper, not who hands the money to the government.
Why does a subsidy cause a deadweight loss when buyers and sellers both gain?
Because it costs the government more than they gain. The extra units it encourages are worth less to buyers than they cost sellers to make. In Barkley's corn example the subsidy costs 6 and buyers and sellers gain 2.75 each, so 0.5 is lost.
Can I use this for homework?
Yes, to check your answers and to see why they come out the way they do. Show your own working, and use the download button if you want the graph. The numbers match the worked examples in OpenStax, a UW–Madison course handout and Kansas State's welfare-analysis chapter.
Sources
- Appendix A: The Use of Mathematics in Principles of Economics, OpenStax, Principles of Economics 3e (Rice University). Solves Qd = 16 − 2P and Qs = 2 + 5P for an equilibrium price of 2 and quantity of 12.
- 3.5 Demand, Supply, and Efficiency, OpenStax, Principles of Economics 3e (Rice University). Definitions of consumer surplus, producer surplus, social surplus and deadweight loss.
- ECON 101: Principles of Microeconomics, Discussion Section Week 5 (handout with solutions), University of Wisconsin–Madison, TA Kanit Kuevibulvanich (Fall 2013). Worked answers for a $4 per-unit tax on Q = 20 − P and Q = 3P (quantity, both prices, revenue, deadweight loss, incidence) and a $60 price guarantee that works as a $20 subsidy.
- The Economics of Food and Agricultural Markets, 2.5 Taxes and 2.6 Subsidies, Andrew Barkley, Kansas State University (New Prairie Press), via LibreTexts. A gasoline tax (P = 8 − Q, P = 2 + Q, t = 2) and a corn subsidy (P = 12 − 2Q, P = 2 + 2Q, s = 2) with every change in consumer surplus, producer surplus, government and deadweight loss.
- The Economics of Food and Agricultural Markets, 2.1 Price Ceiling, Andrew Barkley, Kansas State University (New Prairie Press), via LibreTexts. Consumer, producer and total surplus worked out for P = 20 − 2Q and P = 4 + 2Q (16, 16 and 32).
Formula and sources last checked September 30, 2026. How we test formulas.