Market equilibrium calculator: price and quantity
A market finds its equilibrium at the single price where the quantity buyers want to buy equals the quantity sellers want to sell. Above that price, unsold stock piles up; below it, the goods run out. This crossing point — the famous supply-and-demand cross — is the foundation of just about every microeconomic argument.
This calculator crosses two linear functions, the form used in every textbook problem: Qd = a − b·P for demand, Qs = c + d·P for supply. From them it derives the equilibrium price and quantity, both surpluses (the net gain to buyers and to sellers), the elasticities at equilibrium, and the shortage or surplus a price control would create.
The coefficients b and d are slopes in quantity per unit of price: with Qd = 1,200 − 20·P, every extra pound loses 20 units of sales. If the textbook gives the inverse functions instead (price as a function of quantity, P = 60 − Q/20), flip them first: Q = 1,200 − 20·P.
The market's two functions
An asterisk after a technical term points to its entry in the glossary at the end of the page.
Why the Marshallian cross puts price on the vertical axis
Every principles textbook draws the same cartoon: price up the page, quantity along the floor. It looks upside down to anyone who learned graphs in a maths class. The profession kept Marshall's layout because price is the lever both sides of the market actually twist until leftover crates and leftover queues disappear. The drawing is still called the Marshallian cross*.
Demand slopes down: dearer, fewer buyers. Supply slopes up: dearer, more sellers willing to turn up. Where the two lines meet, the quantity people want to buy is the quantity people want to sell. That crossing is the equilibrium — P* on the axis, Q* on the floor.
Above it, unsold stock. Below it, empty shelves. The picture is a diagram of pressures, not a photograph of a supermarket aisle. A free price is supposed to pull the market back to the crossing. Stocks, contracts and habit can delay that. The sketch gives the direction, not the timetable.
Clearing the market: set Qd = Qs and recover (P*, Q*)
One sentence in symbols: quantity demanded equals quantity supplied. One unknown: the price.
Qd(P) = Qs(P) ⇒ P* = (a − c) / (b + d) · Q* = a − b·P*
Write both functions in terms of P. Set them equal, solve for P*, then plug P* into either function to get Q*. The other function is a check: if the two disagree, a sign has slipped.
A small drill: Qd = 100 − 2P and Qs = 20 + 3P. Then 100 − 2P = 20 + 3P, so 80 = 5P, so P* = 16. Quantity is 100 − 2 × 16 = 68, or 20 + 3 × 16 = 68. Same pair. This calculator does that arithmetic for any a, b, c, d, including the awkward case where c is negative and producers only enter above a floor price. Inverse functions, if the textbook wrote P = g(Q), have to be flipped first.
Direct form versus inverse form, and the slope trap
Textbooks flip without warning. One page writes Q = f(P). The next writes P = g(Q), because that is how the Marshallian graph is read — price on the upright axis. Same market. Different subject of the sentence.
- Direct — Q as a function of P. “At this price, how many units?” That is what the form on this page asks for.
- Inverse — P as a function of Q. “For this quantity, what price clears it?” Useful for surplus triangles, which live in (Q, P) space.
Q = a − b·P ⇒ P = (a − Q) / b = a/b − (1/b)·Q
Q = c + d·P ⇒ P = (Q − c) / d = −c/d + (1/d)·Q
The trap is the slope. In direct form the demand slope is −b (units per pound). On the graph the inverse is what is being looked at, and its slope is −1/b (pounds per unit). Mix those two and a “steep” curve in the picture is a “small b” in the equation. a/b is the choke price: above it, demand is nil. −c/d, when c is negative, is the price at which the first unit of supply appears.
A shift of a curve is not a movement along it
Two motions, one diagram, endless mix-ups in the press.
A movement along the demand curve is a response to a price change, nothing else altered: the good got dearer, so less is bought, and the market slides down the same line. A shift of the curve is everything except own price — income, a rival’s tag, a heatwave, a new tax. The whole line jumps left or right, and the old price is no longer an equilibrium. The market then slides along the other curve to the new crossing.
Did the tag change, or did the world change? If only the tag, the market is on the line. If the world, the line moved. Get that wrong and a VAT rise gets called a “fall in demand” when what happened is a movement up the demand curve after supply shifted. In practice the newspaper “price shock” is often a supply shift that then moved the tag. The curve moved. The sticker followed.
Income, substitutes, tastes, expectations: demand shifters
Demand jumps when something other than this good’s own price changes. The usual suspects:
- Income — a rise shifts demand right for a normal good (most things), left for an inferior one (the own-brand loaf dropped when wages recover).
- Price of a substitute — butter up, margarine demand right. Rail fares up, coach tickets right.
- Price of a complement — petrol up, the appetite for thirsty cars left. Printers cheap, ink demand right.
- Preferences — fashion, a health scare, a celebrity chef, a boycott. Soft, and real.
- Expectations — a rumour that the price will be higher on Monday pulls Saturday’s demand to the right, which is how a rumour of a shortage becomes a shortage.
A population bulge, a new housing estate, a tourist season: more buyers at every price, same idea. The line moves. P* and Q* then move with it. In a two-coefficient form, all of that sits inside “a went up”. The work is saying why.
Costs, technology, entry, taxes: supply shifters
Supply jumps when it becomes cheaper, or dearer, to put a unit on the market — still at the same sticker price the buyer sees.
- Costs — feed, wages, energy, rent. Down, and supply shifts right. Up, and it shifts left.
- Technology — a better seed, a faster packing line. More output at every price, rightward shift.
- Number of producers — a new chain opens, or a bad year knocks three farms out. Entry right, exit left.
- Taxes and subsidies — a per-unit tax is a cost; supply shifts left (or up, in inverse form). A subsidy does the opposite.
- Shocks — drought, a strike, a blocked canal, a freeze on the rails. Anything that takes capacity out without asking the price first.
Farmers who expect a lower harvest price may dump stored grain now. Today’s supply shifts right — and pushes the feared price down further. Expectations work on this side of the market too.
Consumer surplus and producer surplus as areas, not decoration
The shaded triangles on the figure are a money measure of “how glad this trade happened.”
Consumer surplus* is what buyers would have paid (the height of the demand curve — willingness to pay) minus what they paid (P*). On a straight demand line that is a triangle under demand and above P*, area ½ · Q* · (choke price − P*). Producer surplus is what sellers received minus the extra cost of producing those units (the height of the supply curve). Triangle above supply and below P* — with a wrinkle this calculator is careful about: if some output would have been offered even at a zero price, that slice is not a cost, so the area under supply is truncated at zero.
Add the two and the result is total surplus, the welfare of this market. A tax, a floor, a ceiling: some trades that were worth doing no longer happen. That missing piece is the deadweight loss*. It is a partial measure — it ignores externalities, market power, and people who never made it into the diagram — but it is the right starting point for “did this intervention shrink the pie?”
CS = ½ · Q* · (a/b − P*) · PS = P*·Q* − area under supply
Ceilings and floors: shortage, glut, black markets, deadweight loss
Leave the price free and the cross does the rationing. Pin the price by law and something else has to.
A price ceiling* below P* (rent control, a wartime max price) makes demand larger than supply. The short side wins: only Qs units change hands, fewer than at equilibrium. Queues, waiting lists, a black market at a price the statute forbids, landlords who pick tenants by anything except willingness to pay. A price floor above P* (a guaranteed farm price, a minimum wage if labour is treated as this diagram) does the reverse: extra supply, thinner demand, unsold units — a glut.
Both create deadweight loss. Trades that would have made buyer and seller better off do not happen. That said, the diagram is silent on the point of the policy — cheap housing for sitting tenants, a wage floor, food security. It only prices the pie that shrank. A ceiling only binds below equilibrium, a floor only above it. Set the legal price at P* and a number has been printed that does nothing.
A ceiling above P*, or a floor below it, is inert. The calculator then reports a gap of zero: not a bug, a regulation that does not bite.
A specific tax and how incidence follows the elasticities
Levy T pounds per unit. The price the buyer pays, Pc, and the price the seller keeps, Pp, now differ by T:
Pc − Pp = T
Who is unhappy, and by how much, is not written on the Finance Bill. It is written in the two elasticities at the old equilibrium. That split is tax incidence*. Inelastic demand, elastic supply: buyers take most of T (cigarettes, petrol in the short run). Inelastic supply, elastic demand: sellers take most of it (a harvest already in the barn, a hotel night that vanishes at midnight). The less elastic side has nowhere to go, so it pays. The same logic as price elasticity of demand, now applied to both sides of the market.
Graphically the tax is a wedge. Quantity shrinks, surplus falls by more than the Treasury takes, and that extra bite is deadweight loss again. Worth noting: ad valorem VAT is a percentage, not a fixed T, so the wedge widens as P rises — same idea, slightly bent geometry.
A steep line is not the same thing as inelastic demand
On a straight demand line the slope is constant. Elasticity is not. That single fact saves a lot of bad exam answers.
Slope is ΔQ/ΔP. It carries units — loaves per pound, barrels per dollar — so a UK wheat market cannot be compared with a US one, or even bread with petrol, by looking at b. Elasticity is (ΔQ/Q) ÷ (ΔP/P), a pure number. Comparable. On the linear demand this page uses, |e| is high at the top of the line (price high, quantity small) and low at the bottom. The unit-elastic point sits in the middle, which is why revenue peaks there.
A “steep” picture is not the same as “inelastic demand.” Steepness depends on how the axes were drawn. Elasticity does not. A perfectly inelastic demand is a vertical line in Marshall’s picture, slope infinite in inverse form, e = 0. The words and the ink fight each other unless slope and elasticity stay in separate drawers. This page reports both: b and d are slopes; ed and es at equilibrium are elasticities.
The cobweb: a rest point the market may never reach
The cross is a rest point. Getting there, when supply is decided last season, is another story. Think of a crop: farmers plant on last year’s price, harvest this year’s quantity, this year’s price then sets next year’s planting. Trace it and a cobweb appears on the diagram.
- If supply is flatter than demand (in absolute slope), the spiral winds in. Price converges to P*.
- If supply is steeper, the spiral winds out. Explosive cycles, each year worse.
- If the absolute slopes match, the market orbits forever. Same two prices, year after year, never the crossing.
Real farmers are not this mechanical — they look ahead, they store, they have futures markets — but the model is a clean warning: lags plus naive expectations can keep a market bouncing even when a well-behaved equilibrium exists on paper. Agricultural prices have always been noisier than the static diagram admits. In short, the figure on this page is a still. The cobweb is the film.
A drought on a wheat market, worked through
Take a wheat market in million tonnes, price in pounds per tonne:
- Qd = 50 − 2P
- Qs = 10 + 3P
Set them equal: 50 − 2P = 10 + 3P → 40 = 5P → P* = 8, Q* = 50 − 16 = 34. Thirty-four million tonnes at £8.
A drought knocks 20% off supply at every price. New supply: Qs′ = 0.8 × (10 + 3P) = 8 + 2.4P. New crossing: 50 − 2P = 8 + 2.4P → 42 = 4.4P → P*′ ≈ 9.55, Q*′ = 50 − 19.1 ≈ 30.9. Price up from 8 to 9.55 (+19.3%), quantity down from 34 to 30.9 (−9.1%). Buyers are unambiguously worse off: they pay more for less, so consumer surplus shrinks. Producer surplus can go either way — fewer tonnes, but a fatter margin on each, and costs may have risen with the drought itself. The diagram does not let that last check be skipped.
Anyway, that is a supply shift, then a slide along demand. Not “demand for wheat fell.” Quantity fell because the harvest did. A demand shock would have moved P and Q in the same direction. A headline that quotes only the price cannot tell which of the two occurred.
Rent controls and the waiting list they create
Pin rents below the market-clearing level and the UK diagram is the ceiling case. Demand for those flats exceeds the number landlords will offer at the legal rent. The short side is supply: fewer homes let, a queue, key money under the table, landlords who pick tenants by job and passport rather than by who values the flat most. Sitting tenants who keep the controlled rent gain surplus. Would-be tenants who never get a viewing lose it. Some of the loss is a transfer. Some is deadweight: a matching that should have happened, and did not.
England has been wary of hard caps for decades, with periodic arguments about them in tight cities. Scotland’s recent experiments with rent controls are the live case to watch: same geometry, different statute. A freeze that binds below P* will show up as a shortage, not as a free lunch. All the same, the diagram will not say whether the political goal — keeping existing tenants in their homes — is worth that shortage. It will say the shortage is not an accident.
The energy price cap: a ceiling on a bill, not on a wholesale market
Ofgem’s energy price cap is the British policy almost every household met in 2022. It is a ceiling on the default tariff a supplier may charge, not a cap on the wholesale gas price itself. When wholesale costs shot through the cap, suppliers could not raise the retail ticket enough to cover what they were paying. Several failed. The remaining book was, for a stretch, a market with a binding ceiling and a government-shaped subsidy behind it.
The wholesale market still had a P* — a very high one. The retail cap sat below the cost-reflective retail P*. That is a ceiling: pressure on the short side, queues in the political sense (who gets the support, which supplier is still standing), and a deadweight story tangled up with a necessity good. Households did not stop heating; they cut what they could and the Treasury filled a hole. Calling the cap “the equilibrium price” was the error. It was a legal price, and the diagram’s warning is what happens when those two disagree.
How 20% VAT splits on a pint and on a haircut
Standard-rate VAT is 20%. On a pint in a busy city pub, demand is not infinitely elastic — the evening was already planned — but it is not a drug either; there is the next pub, or a can from the off-licence. Supply of an extra pint on a Saturday night is fairly elastic (the keg is already there). A good chunk of the VAT then sits on the drinker, which is why a duty-plus-VAT rise shows up in the pump price more than in the brewery’s margin.
A haircut is stickier. It is needed, there is a regular, shopping around every week is rare. Demand is less elastic, so a VAT change on personal services (when they are standard-rated) passes through more completely to the client. Zero-rated food off a supermarket shelf is a different diagram again: no VAT wedge on the staple, a wedge on the meal deal eaten in. The 20% is one number on HMRC’s list and four or five different incidences once the good is named.
Feed a taxed market into this calculator by shifting supply left by the per-unit equivalent of the tax, then compare the new P* with the old. The gap between what buyers pay and what sellers keep is the split that was being asked for.
Glossary
- Marshallian cross
- The standard supply-and-demand diagram with price on the vertical axis and quantity on the horizontal, the convention Alfred Marshall fixed in the late nineteenth century. Not the mathematician’s habit (the “cause” on x): the picture the whole profession reads.
- Consumer surplus
- Buyers’ net gain from trade: willingness to pay minus the price actually paid. On a linear demand curve it is the triangle under demand and above P*. Producer surplus is the matching triangle above supply and below P*. Together they are total surplus, the market’s welfare in this model.
- Deadweight loss
- The slice of total surplus that vanishes because mutually beneficial trades no longer happen — a tax, a ceiling, a floor. It is not the money transferred to the Treasury or to the other side of the market: it is the triangle of trades that stop.
- Price ceiling / price floor
- A legal maximum (ceiling) or minimum (floor) on price. A ceiling bites only below P*: demand exceeds supply, a shortage appears, and the quantity traded is the short side. A floor bites only above P*: a glut. At P* itself the control is inert.
- Tax incidence
- How the burden of a tax actually splits between buyers and sellers, regardless of who remits it to HMRC. The less elastic side of the market — the side less able to walk away — bears more of it.