Market Equilibrium Calculator
Introduction to linear market equilibrium and what this calculator solves
A competitive market is in equilibrium when the quantity buyers wish to purchase exactly matches the quantity sellers wish to offer. OpenStax defines equilibrium as the situation where quantity demanded is equal to the quantity supplied; the combination of price and quantity where there is no economic pressure from surpluses or shortages that would cause price or quantity to change. This calculator takes the two straight-line schedules that appear in almost every introductory microeconomics problem set, solves them simultaneously, and then reports everything a grader normally asks for alongside the answer: the market-clearing price and quantity, consumer surplus, producer surplus, total surplus, the point price elasticities of demand and supply at that equilibrium, and the full incidence of an optional per-unit excise tax.
The distinguishing feature of this page is that it does not stop at the algebra. Straight lines extended far enough always intersect somewhere, but the intersection is only economically meaningful when it sits at a non-negative price and a strictly positive quantity. Many equilibrium calculators simply print whatever number falls out of the division, including negative prices and negative quantities. This one classifies the outcome first, draws the geometry so you can see the surplus triangles it is measuring, and refuses to dress up a meaningless intersection as a market outcome.
Everything here is partial equilibrium: one good, one period, all other prices and incomes held fixed. That is exactly the setting of MIT 14.01 lectures 1 and 9 and of chapters 3, 5 and 6 of the OpenStax Principles of Economics sequence, and it is the right tool for checking homework, sanity-checking a policy argument, or building intuition about how slopes translate into elasticities.
How to use the four curve parameters, the tax slider and the shareable link
The calculator is written in the quantity-as-a-function-of-price form, which is the form most textbooks state first:
- Demand:
- Supply:
Enter the four coefficients as follows.
- Demand intercept is the quantity demanded when the price is zero. It must be positive, otherwise nobody buys the good at any price a seller would accept.
- Demand slope is entered as a positive magnitude. The minus sign is already in the equation, so a value of 4 means quantity demanded falls by four units for every one-unit rise in price. Enter 0 for perfectly inelastic demand.
- Supply intercept is the quantity supplied at a price of zero. It is frequently negative in textbook problems, which simply means producers offer nothing until the price clears the shutdown price .
- Supply slope is the extra quantity offered per one-unit rise in price, entered as a non-negative number. Enter 0 for perfectly inelastic supply, such as a fixed stock of tickets.
If your problem gives you inverse curves such as , rearrange before entering: multiply through so that quantity stands alone. That example becomes , so and . The calculator echoes both the direct and the inverse form of each curve back to you so you can confirm the translation.
The optional per-unit tax field adds a specific excise tax collected from sellers. Leave it at zero for the untaxed market. Once you have calculated an equilibrium the slider rescales itself so that its right-hand end is the largest tax the market can absorb before sellers stop supplying; dragging it re-solves the model live and redraws the diagram, which makes the incidence and deadweight-loss geometry easy to see. Every result panel also offers a shareable permalink that encodes all five inputs in the address bar, and a CSV download of the full numeric breakdown for pasting into a spreadsheet.
Formula derivation: solving the market-clearing condition for P* and Q*
Equilibrium is defined by a single condition, that the two schedules agree:
Formula: Q_d(P) = Q_s(P)
Substituting the two linear forms turns this into one equation in one unknown:
Formula: a_d − b_d P = a_s + b_s P
Collecting the price terms on one side and the constants on the other gives:
Formula: (b_d + b_s) P = a_d − a_s
Dividing by the sum of the two slope magnitudes produces the core formula:
Formula: P^* = (a_d − a_s) / (b_d + b_s)
Substituting that price back into either schedule gives the equilibrium quantity. Doing the substitution symbolically and simplifying yields a form that is numerically better behaved than plugging a rounded price back in, and it is the form the calculator actually evaluates:
Formula: Q^* = a_s + b_s P^* = (a_d b_s + a_s b_d) / (b_d + b_s)
The denominator is the only place the calculation can break. It is zero exactly when both curves are perfectly inelastic, that is when both lines are vertical in price-quantity space and therefore parallel. In that case there is no price that equates the two fixed quantities unless they happen to be identical, and the calculator says so rather than returning an infinity. Because both slopes are constrained to be non-negative, the denominator can never be a small difference of large numbers, so the division is well conditioned for every admissible input.
Two derived prices matter for the geometry. The choke price is the price at which quantity demanded reaches zero, and the shutdown price is the lowest non-negative price at which any output is offered:
Formula: P_choke = a_d / b_d, P_shut = max(0, − a_s / b_s)
A strictly positive traded quantity exists if and only if the shutdown price is below the choke price, that is . The calculator tests that inequality explicitly before reporting an equilibrium.
Formulas for consumer surplus, producer surplus and total surplus
MIT 14.01 states the geometry directly: consumer surplus is the area under the demand curve and above the price, because the demand curve represents the marginal willingness to pay; producer surplus is the area above the supply curve and below the price, because the supply curve represents marginal cost. Both are areas measured against the inverse curves, that is with price on the vertical axis, and both are bounded on the left by the price axis.
Inverting the two schedules gives the marginal willingness-to-pay and marginal-cost functions the areas are measured under:
Formula: P_d^−1(Q) = a_d / b_d − Q / b_d, P_s^−1(Q) = (Q − a_s) / b_s
Consumer surplus is then the definite integral of the gap between willingness to pay and the price actually paid, from the first unit to the last unit traded:
Formula: CS = ∫_0^Q^* [P_d^−1(Q) − P^*] d Q = 1 / 2 Q^* (P_choke − P^*) = (Q^*)^2 / (2 b_d)
The last equality follows because . Notice that the height of the triangle is measured from the choke price, not from the top of whatever chart happens to be drawn: getting that bound wrong is the single most common error in surplus questions. When the choke price is infinite and consumer surplus is unbounded, which the calculator reports as such instead of printing a number.
Producer surplus is the mirror image, but with one correction that many quick treatments skip. The region is bounded below by a price of zero, because no producer is compelled to pay for the privilege of selling. Integrating the supply schedule with respect to price from the shutdown price up to the market price gives the correct area in every configuration:
Formula: PS = ∫_P_shut^P^* Q_s(P) d P = a_s (P^* − P_shut) + b_s / 2 ((P^*)^2 − P_shut^2)
When the supply intercept is negative the shutdown price is positive and this collapses to the familiar triangle . When the supply intercept is positive the shutdown price is zero, the region is a trapezoid rather than a triangle, and using the triangle formula overstates producer surplus. Total surplus, which OpenStax calls social surplus, is simply the sum:
Formula: TS = CS + PS
In the competitive equilibrium this total is at its maximum; any intervention that moves the traded quantity away from reduces it, and the shortfall is the deadweight loss.
Point elasticity versus midpoint (arc) elasticity at the equilibrium
MIT 14.01 defines the price elasticity of demand as the proportional change in quantity divided by the proportional change in price. Evaluated at a single point of a differentiable curve this is the point elasticity:
Formula: ε_d = (d Q_d) / (d P) ⋅ P / Q = − b_d P^* / Q^*, ε_s = b_s P^* / Q^*
Two things are worth emphasising. First, elasticity is not the slope. A single straight demand line has the same slope everywhere but an elasticity that runs from zero at the horizontal intercept to minus infinity at the choke price, so an elasticity is only meaningful once you name the point at which it is evaluated. This calculator always evaluates at the equilibrium and labels it as such. Second, the ratio is what converts a slope into an elasticity, which is why two markets with identical slopes can have very different elasticities.
The midpoint or arc elasticity used by OpenStax is a different object. It compares two separate points and divides each change by the average of the two endpoint values:
Formula: ε_d^arc = (Q_2 − Q_1) / ((Q_2 + Q_1) /2) / (P_2 − P_1) / ((P_2 + P_1) /2)
Its advantage, in the words of the OpenStax text, is that one obtains the same elasticity between two price points whether there is a price increase or a decrease. Its cost is that it is an average over an interval rather than a property of a point, so it only approaches the point elasticity as the interval shrinks. Reporting a midpoint figure where a point figure was asked for, or vice versa, is a classic exam mistake, so this calculator labels every elasticity it prints.
When you switch on the tax, the calculator also reports arc elasticities. That is not decoration. MIT 14.01 notes that accurately estimating an elasticity requires a shift along the other curve, for example a tax on suppliers that shifts the supply curve up and traces out two points of the demand curve. The taxed and untaxed equilibria lie on the same demand curve when measured at the buyer price, and on the same supply curve when measured at the seller price, so the midpoint elasticities computed between them are legitimate arc elasticities of demand and of supply respectively, and they bracket the point elasticities at the two endpoints.
Formula for a per-unit tax: incidence, revenue and deadweight loss
A specific tax of per unit collected from sellers drives a wedge between the price buyers pay and the price sellers keep, . Solving the market-clearing condition with that wedge in place gives:
Formula: P_b = P^* + t b_s / (b_d + b_s), P_s = P^* − t b_d / (b_d + b_s)
The two fractions are the incidence shares, and they sum to one. Because the point elasticities share the common factor , the buyer share can be rewritten purely in elasticities as , which is the precise version of the OpenStax statement that if demand is more inelastic than supply consumers bear most of the tax burden, and if supply is more inelastic than demand sellers bear most of it. Nothing in the algebra depends on which side the tax is legally collected from.
Traded quantity, tax revenue and deadweight loss follow immediately:
Formula: Q_t = Q^* − t (b_d b_s) / (b_d + b_s), R = t Q_t, DWL = 1 / 2 t (Q^* − Q_t) = 1 / 2 t^2 (b_d b_s) / (b_d + b_s)
The calculator does not take that deadweight-loss shortcut on trust. It recomputes consumer surplus at the buyer price and producer surplus at the seller price from the same integrals used for the untaxed case, adds tax revenue, and reports the shortfall against untaxed total surplus. The two routes agree to floating-point precision whenever the taxed equilibrium is still interior, which is a useful internal check that the surplus bounds are right. If the tax is large enough to push the seller price below the shutdown price, the calculator says the market closes rather than extrapolating the triangles into a region where they are meaningless.
Worked example: a regional wheat market priced in dollars per bushel
Take a regional wheat market measured in thousands of bushels per week and dollars per bushel:
- Demand:
- Supply:
So , , and . The equilibrium price is
Formula: P^* = (120 − 20) / (4 + 2) = 100 / 6 ≈ 16.67
and substituting into the supply schedule gives
Formula: Q^* = 20 + 2 × 100 / 6 = 160 / 3 ≈ 53.33
so the market clears at about USD 16.67 per bushel with roughly 53,333 bushels traded per week. The choke price is and the shutdown price is zero, because the supply intercept is positive.
Consumer surplus is the triangle between the choke price and the market price:
Formula: CS = 1 / 2 × 53.33 × (30 − 16.67) ≈ 355.56
Producer surplus is a trapezoid rather than a triangle, because 20 thousand bushels are offered even at a price of zero:
Formula: PS = 20 × 16.67 + 2 / 2 × 16.67^2 ≈ 333.33 + 277.78 = 611.11
Total surplus is therefore about 966.67 thousand dollars per week. Had you used the naive triangle for producer surplus you would have reported 711.11 and overstated total surplus by more than ten per cent, which is precisely the choke-price and shutdown-price bookkeeping the derivation above is guarding against.
The point elasticities at this equilibrium are and . Demand is elastic and supply is inelastic at this point, so a tax should fall mostly on sellers.
Set the tax slider to USD 3.00 per bushel and that is what happens. Buyers pay 17.67, sellers keep 14.67, and the traded quantity falls to 49.33 thousand bushels. Buyers absorb of the tax and sellers the remaining 66.7 per cent, matching the elasticity ranking. Revenue is thousand dollars and the deadweight loss is thousand dollars, about 0.6 per cent of the untaxed total surplus. The arc elasticity of demand measured between the two equilibria is about , sitting between the point elasticity of at the old equilibrium and at the new one, exactly as the midpoint method should.
These coefficients are illustrative teaching values chosen to give round intermediate results. They are not estimated from any published wheat series, and no claim is made that they describe an actual market.
Comparative statics and a sensitivity example for the four parameters
The signs below are the partial derivatives of the closed-form solutions, and they hold whenever demand slopes down, supply slopes up and the equilibrium price is positive, that is .
| Parameter change | Partial derivative of | Effect on | Effect on |
|---|---|---|---|
| Demand shifts out, rises | Rises | Rises | |
| Demand shifts in, falls | Same expression, sign reversed | Falls | Falls |
| Supply shifts out, rises | Falls | Rises | |
| Supply shifts in, falls | Same expression, sign reversed | Rises | Falls |
| Demand becomes flatter, rises | Falls | Falls, and is unchanged only if supply is perfectly inelastic | |
| Supply becomes flatter, rises | Falls | Rises, and is unchanged only if demand is perfectly inelastic |
An earlier version of this page claimed that a rise in the demand slope leaves the effect on quantity ambiguous. That is wrong whenever supply slopes up: since , anything that lowers the equilibrium price must also lower the equilibrium quantity. The table above has been corrected and the signs verified against the derivatives.
Applying a ten per cent increase to each parameter of the wheat example in turn gives the following sensitivity, which the calculator also produces live for whatever coefficients you enter:
| Parameter raised by 10 per cent | New | Change in | New | Change in |
|---|---|---|---|---|
| Demand intercept, 120 to 132 | 18.67 | +12.00 per cent | 57.33 | +7.50 per cent |
| Demand slope, 4 to 4.4 | 15.63 | -6.25 per cent | 51.25 | -3.91 per cent |
| Supply intercept, 20 to 22 | 16.33 | -2.00 per cent | 54.67 | +2.50 per cent |
| Supply slope, 2 to 2.2 | 16.13 | -3.23 per cent | 55.48 | +4.03 per cent |
The demand intercept is by far the most powerful lever here, which is the usual result when supply is comparatively inelastic: a demand shock has to be absorbed mostly by price.
Corner cases: negative prices, market gluts and no-trade outcomes
Straight lines happily intersect outside the economically meaningful quadrant, and a calculator that prints that intersection anyway is reporting nonsense with two decimal places of false precision. Three corner cases are detected and reported explicitly instead.
- Excess supply at a price of zero. If then the unconstrained solution has a negative price. Because prices cannot go below zero, the constrained outcome is a free good: the price sits at zero, buyers take units, and units go unsold. The calculator reports the glut rather than a negative price.
- No trade at all. If the shutdown price is at or above the choke price, the cheapest unit any producer will supply costs more than the most any consumer will pay. Traded quantity is zero, no price is determined within the interval, and no surplus exists. This shows up as a negative unconstrained quantity, which the calculator intercepts.
- Parallel curves. If both slopes are zero the two schedules are vertical lines and never cross unless they coincide, so the price is indeterminate. The old script divided by and could return an infinity here; the current one refuses the input.
Negative slopes are also rejected. Entering a negative demand slope would describe an upward-sloping demand curve and a negative supply slope a downward-sloping supply curve; either can make the denominator a small difference of similar numbers and turn the solution into an ill-conditioned mess, and neither is what the surplus formulas on this page assume. If you genuinely need a Giffen good or a backward-bending supply curve, this is not the right tool.
Limitations and assumptions behind this partial-equilibrium model
The results are only as good as the model that generates them. The main assumptions and limitations are:
- Perfect competition. Many small buyers and sellers, all price takers, no strategic behaviour. Under monopoly or oligopoly the output is below the competitive level and the surplus arithmetic here does not apply.
- Strict linearity. Both schedules are straight lines over the entire range, including the extrapolated stretches that the surplus triangles depend on. Real schedules are usually curved, and the closed-form areas are the first thing to break.
- Static, single period. There is no adjustment path, no inventories, no expectations. The calculator answers where the market ends up, not how long it takes to get there or whether it overshoots.
- Partial equilibrium. Incomes, the prices of substitutes and complements, and every other market are held fixed. Large shocks that move those variables invalidate the exercise.
- No externalities, and surplus as a welfare measure. Total surplus counts a dollar to a buyer and a dollar to a seller identically and ignores third-party costs and benefits. It measures efficiency, not fairness, and it is silent on distribution.
- Only a per-unit tax is modelled. Price ceilings, price floors, quotas, subsidies and ad valorem taxes each change the geometry in a different way and are not covered by the tax block on this page.
- Illustrative parameters, not estimates. The coefficients you enter are yours. Nothing on this page estimates a real demand or supply curve, and the worked example is a teaching construction rather than measured data.
Within those limits the model is genuinely useful: it is the standard framework for reasoning about tax incidence, price controls, subsidies and demand shocks, and being explicit about the assumptions is what separates an argument from an assertion.
Frequently asked questions about supply, demand and equilibrium
What is the formula for equilibrium price with linear supply and demand?
Set quantity demanded equal to quantity supplied. With Qd = ad - bd P and Qs = as + bs P, the market clears at P* = (ad - as) / (bd + bs), and substituting that price back into either equation gives Q* = (ad bs + as bd) / (bd + bs). The denominator is the sum of the two slope magnitudes, so it vanishes only when both curves are perfectly inelastic and the two lines are parallel.
Why does the calculator refuse to report a negative equilibrium price?
An equilibrium price below zero is an artefact of extending straight lines past the region where they make economic sense. When the supply intercept exceeds the demand intercept, quantity supplied already exceeds quantity demanded at a price of zero, so the market never clears at a positive price. The calculator reports the constrained outcome instead: a price of zero, trade equal to quantity demanded at that price, and the remaining excess supply.
How is consumer surplus calculated from a linear demand curve?
Consumer surplus is the area under the inverse demand curve and above the market price, between zero and the equilibrium quantity. For a straight demand line the choke price is ad divided by bd, so the region is a triangle whose height is the choke price minus P* and whose base is Q*, which simplifies to Q* squared divided by twice bd. It is unbounded when demand is perfectly inelastic, because the choke price is then infinite.
What is the difference between point elasticity and midpoint elasticity?
Point elasticity is measured at a single point on a curve and equals the derivative of quantity with respect to price multiplied by price and divided by quantity, so the demand elasticity at equilibrium is minus bd times P* divided by Q*. Midpoint or arc elasticity compares two separate points and divides each change by the average of the two values, which returns the same number whether the price rose or fell. The two agree only in the limit of a vanishingly small price change.
Who really pays a per-unit tax in this model?
The statutory side does not matter. With linear curves buyers pay the fraction bs divided by bd plus bs of a per-unit tax and sellers absorb bd divided by bd plus bs, which is the same as saying the burden falls more heavily on whichever side is less elastic at the equilibrium. The traded quantity falls by the tax multiplied by bd bs divided by bd plus bs, and the deadweight loss is half the tax multiplied by that fall in quantity.
Does this calculator work with non-linear supply and demand curves?
No. Every formula on this page assumes both curves are straight lines over the whole relevant range, which is what makes the closed-form surplus triangles and the constant slopes valid. For a constant-elasticity or otherwise curved specification you would have to integrate the actual inverse demand and inverse supply functions instead of using triangle areas, and the elasticity would change along the curve in a different way.
Sources for the equilibrium, surplus and elasticity definitions
Sources. Definitions of equilibrium, equilibrium price and quantity, surplus and shortage follow OpenStax (Rice University), Principles of Economics 3e, sections 3.1 and 3.5 and the chapter 3 key terms: 3.1 Demand, Supply, and Equilibrium in Markets for Goods and Services and 3.5 Demand, Supply, and Efficiency, which define consumer surplus, producer surplus, social surplus and deadweight loss. The geometric statements that consumer surplus is the area under the demand curve and above the price, and producer surplus the area above the supply curve and below the price, are taken from MIT OpenCourseWare, 14.01 Principles of Microeconomics (Fall 2023), Lecture 9 notes on Supply and Demand, Consumer and Producer Surplus: ocw.mit.edu 14.01 Fall 2023. The point-elasticity definition used here is the 14.01 Lecture 4 definition, the proportional change in quantity divided by the proportional change in price; the midpoint formula is the OpenStax 5.1 Price Elasticity of Demand and Price Elasticity of Supply. The statement that the tax burden falls more heavily on the less elastic side is from OpenStax 5.3 Elasticity and Pricing. MIT OpenCourseWare material is used under CC BY-NC-SA and OpenStax under CC BY. No real-world price or quantity data is used on this page; all coefficients are supplied by you and the worked example is an illustrative teaching construction.
Arcade Mini-Game: Supply and Demand Concept Sorter
Catch the statements that are true of a linear competitive equilibrium and dodge the classic exam errors, such as reading an elasticity off the wrong point or measuring a surplus triangle from the wrong bound.
Start the game, then use your pointer or arrow keys to catch correct statements and avoid the errors.
