Skip to content

Supply and Demand Calculator

Enter a linear demand curve and a linear supply curve and the calculator solves for the equilibrium price and quantity, measures consumer and producer surplus, and draws the graph with price on the vertical axis. Add a per-unit tax or subsidy to see who really pays, how much revenue it raises, and how much surplus it destroys. Free, no sign-up, and it runs in your browser.

Demand and supply

Both slopes (b and d) must be above 0. The intercepts a and c can be any number, and c is often negative.

Government intervention

It makes no difference to the result whether the law taxes buyers or sellers: the gap between the price buyers pay and the price sellers keep is the same.

Results

30

Equilibrium price (P*)

60

Equilibrium quantity (Q*)

900

Consumer surplus

600

Producer surplus

1,500

Total surplus

1 · 1.5

Elasticity at equilibrium (|Ed| · Es)

Working

  • Set Qd = Qs: 120 − 2P = −30 + 3P
  • P* = (a − c) ÷ (b + d) = (120 − (−30)) ÷ (2 + 3) = 30
  • Q* = a − bP* = 120 − 2 × 30 = 60
  • Price intercepts: demand α = 60, supply γ = 10
  • Consumer surplus = ½ × (α − P*) × Q* = ½ × (60 − 30) × 60 = 900
  • Producer surplus = ½ × (P* − γ) × Q* = ½ × (30 − 10) × 60 = 600

Effect of the tax

A tax of 5 per unit drives a wedge between the price buyers pay (Pb) and the price sellers keep (Ps): Pb − Ps = 5. The new quantity is where the demand line sits 5 above the supply line.

  • Q = Q* − t × bd ÷ (b + d) = 60 − 5 × (2 × 3) ÷ (2 + 3) = 54
  • Buyers pay Pb, the price on the demand line at Q = 54: 33
  • Sellers keep Ps = Pb − t = 33 − 5 = 28
  • Tax revenue = t × Q = 5 × 54 = 270
  • Deadweight loss = ½ × t × |Q* − Q| = ½ × 5 × 6 = 15

Buyers’ price is 3 higher (60% of the tax); sellers’ price is 2 lower (40%).

The side with the less elastic curve bears more of the tax. Buyers’ share = Es ÷ (Es + |Ed|), with Es = 1.5 and |Ed| = 1 at the original equilibrium.

MeasureBeforeAfterChange
Price buyers pay3033+3
Price sellers receive3028−2
Quantity6054−6
Consumer surplus900729−171
Producer surplus600486−114
Tax revenue0270+270
Total welfare (surplus plus government budget)1,5001,485−15
Deadweight loss015−15
Supply and demandSupply and demand graph with price on the vertical axis and quantity on the horizontal axis. Demand slopes down from a price of 60; supply slopes up from a price of 10. They cross at quantity 60 and price 30. With the intervention, quantity is 54, buyers pay 33 and sellers receive 28.Quantity (Q)Price (P)Consumer surplusProducer surplusTax revenueDeadweight loss0102030405060020406080100120DSS + taxEBuyers paySellers keep
Show the graph data as a table
PointQuantity (Q)Price (P)
Equilibrium6030
Buyers pay5433
Sellers keep5428

How to Use the Supply and Demand Calculator

  1. 1. Pick the form of your equations. Quantity form writes demand as Qd = a − bP and supply as Qs = c + dP. Price form writes the inverse, P = a − bQ and P = c + dQ. Use whichever your course or problem set gives you.
  2. 2. Enter the four numbers. Both slopes, b and d, must be above zero so that demand slopes down and supply slopes up. The supply intercept c is often negative, as in Qs = −30 + 3P.
  3. 3. Choose an intervention if the question has one. A per-unit tax or subsidy shifts the supply curve by that amount. It makes no difference whether the law says buyers or sellers pay it, so the calculator does not ask.
  4. 4. Read the working and the graph. Every figure is written out as a formula with your numbers in it, and the graph shades consumer surplus, producer surplus, tax revenue and deadweight loss.

Equilibrium and Surplus

The market clears where the quantity demanded equals the quantity supplied. In quantity form, set a − bP = c + dP and solve for the price, then substitute back to find the quantity. In price form, set the two prices equal and solve for Q.

Quantity form

P* = (a − c) ÷ (b + d)     Q* = a − bP*

Price form

Q* = (a − c) ÷ (b + d)     P* = a − bQ*

Consumer surplus

CS = ½ × (highest price on demand line − P*) × Q*

Producer surplus

PS = ½ × (P* − price intercept of supply line) × Q*

Consumer surplus is the area between the demand curve and the market price, up to the quantity traded: what buyers would have paid minus what they did pay. Producer surplus is the area between the price and the supply curve: what sellers received minus the least they would have accepted. For straight lines both areas are triangles, which is why the formula has the ½ in it. When the supply line meets the price axis below zero, the triangle is measured down to that intercept, as most textbooks do, and the graph shows only the part above the axis.

Worked Example: A $5 Tax

The calculator opens with demand Qd = 120 − 2P and supply Qs = −30 + 3P, taxed at $5 per unit.

MeasureBefore the taxAfter the tax
Quantity6054
Price buyers pay$30$33
Price sellers keep$30$28
Consumer surplus900729
Producer surplus600486
Tax revenue0270
Total welfare1,5001,485
Deadweight loss015

The tax opens a $5 wedge between the buyers' price and the sellers' price. Buyers pay $3 more than before (60% of the tax) and sellers keep $2 less (40%). Consumers and producers together lose 1,500 − 1,215 = 285 of surplus, the government collects 270, and the remaining 15 is deadweight loss: trades that were worth making and no longer happen.

Tax Incidence and Deadweight Loss

Tax incidence asks who bears the burden, and the answer depends on how readily each side can walk away. With elasticities measured at the original equilibrium, buyers' share of a per-unit tax is Es ÷ (Es + |Ed|), and sellers' share is |Ed| ÷ (Es + |Ed|). In the example Es = 1.5 and |Ed| = 1, so buyers bear 1.5 ÷ 2.5 = 60%. The less elastic side, the one with fewer alternatives, bears more.

For linear curves the deadweight loss has a closed form. In price form, with P = a − bQ and P = c + dQ, a tax t cuts the quantity by t ÷ (b + d), and the loss is the triangle ½ × t × (Q* − Q), which equals ½t² ÷ (b + d). A subsidy is a negative tax and gives a triangle by the same formula: it pushes output past the point where the cost of a unit exceeds its value to the buyer.

A quick check on your homework

The deadweight loss grows with the square of the tax. Doubling a tax quadruples the loss, which is why economists prefer broad, low-rate taxes.

Frequently Asked Questions

How do you find equilibrium price and quantity?
Set quantity demanded equal to quantity supplied, solve for price, and substitute the price into either curve to get the quantity. For Qd = 120 − 2P and Qs = −30 + 3P, setting them equal gives 150 = 5P, so P = 30 and Q = 120 − 2 × 30 = 60.
Does it matter whether the tax is paid by buyers or sellers?
No. A per-unit tax creates a wedge between the price buyers pay and the price sellers receive, and the market settles on the same quantity and the same two prices whoever sends the cheque to the government. What decides each side's burden is the elasticity of its curve, not the wording of the law.
What is deadweight loss?
It is the total surplus that disappears when a tax, subsidy or other distortion stops mutually beneficial trades from happening. Those trades would have made buyers and sellers better off by more than they cost, so the loss is not collected by anyone, including the government.
Why does a subsidy cause a deadweight loss?
A subsidy pushes quantity beyond the equilibrium. For each extra unit, the cost of producing it is greater than the value buyers place on it, so total surplus falls by the triangle between the curves, even though buyers and sellers both gain individually. The government pays for the difference.
What does a negative supply intercept mean?
In quantity form, a positive c in Qs = c + dP means sellers would supply some units even at a price of zero. A negative c means no one supplies until the price passes −c ÷ d. Many textbook problems use a negative c so that the supply line starts at a positive price.
Why must the slopes b and d be positive?
The law of demand says buyers want less as price rises, and the law of supply says producers offer more. Entering b > 0 and d > 0 in these forms keeps the curves sloping that way, and keeps the equilibrium unique. A slope of zero would make a vertical or horizontal curve, and the formulas here divide by the slope, so those extreme cases are better worked by hand.

Related Tools

More in Economics, Business & Finance

See all Economics, Business & Finance