Supply and Demand Simulator: Market Equilibrium & Tax Effects

simulator beginner ~8 min
Loading simulation...
P* = 48, Q* = 52 — market clears at the intersection

With default parameters (demand intercept 100, demand slope 1, supply intercept -20, supply slope 1.5), the market equilibrium price is $48 and equilibrium quantity is 52 units. Consumer and producer surplus are maximized with no deadweight loss when tax is zero.

Formula

Demand: Q_d = a - b·P
Supply: Q_s = c + d·P
Equilibrium price: P* = (a - c) / (b + d)
Equilibrium quantity: Q* = (a·d + b·c) / (b + d)
Price elasticity of demand: E_d = (dQ/dP) · (P/Q) = -b · (P/Q)

The Law of Supply and Demand

The supply and demand model is the most fundamental framework in economics, first formalized by Alfred Marshall in 1890. The demand curve slopes downward — as price rises, consumers buy less. The supply curve slopes upward — as price rises, producers supply more. Where these curves intersect, the market clears: quantity demanded equals quantity supplied.

Finding Equilibrium

In this linear model, demand is Q_d = a - b·P and supply is Q_s = c + d·P. Setting them equal gives the equilibrium price P* = (a-c)/(b+d) and quantity Q* = (a·d+b·c)/(b+d). The parameters a and c represent intercepts (base demand and supply), while b and d represent slopes (price sensitivity). Steeper slopes mean less elastic responses to price changes.

Surplus and Welfare

Consumer surplus (the blue area above the price line and below demand) represents the benefit consumers get from paying less than their maximum willingness to pay. Producer surplus (the green area below the price line and above supply) represents profit above the minimum price producers would accept. Together, they measure total economic welfare.

The Effect of Taxation

When a per-unit tax is imposed, the supply curve shifts upward by the tax amount. The new equilibrium has a higher buyer price, lower seller price, and reduced quantity. The deadweight loss triangle — the red shaded area — represents trades that no longer occur. This welfare loss goes to no one: not buyers, not sellers, not the government. It is a pure inefficiency, and it grows with the square of the tax rate, explaining why economists generally prefer broad-based, low-rate taxes.

FAQ

What determines the equilibrium price in a market?

The equilibrium price is determined by the intersection of the supply and demand curves. At this price, the quantity demanded by consumers exactly equals the quantity supplied by producers. Mathematically, for linear curves Q_d = a - b·P and Q_s = c + d·P, the equilibrium price is P* = (a-c)/(b+d).

What is consumer surplus?

Consumer surplus is the difference between what consumers are willing to pay (represented by the demand curve) and what they actually pay (the market price). Graphically, it is the triangular area between the demand curve and the price line, up to the equilibrium quantity.

How does a tax affect market equilibrium?

A per-unit tax shifts the supply curve upward by the tax amount, creating a new equilibrium with higher price for buyers, lower price for sellers, and reduced quantity. The difference between the old and new total surplus is the deadweight loss — a pure efficiency loss from taxation.

What is deadweight loss?

Deadweight loss represents the reduction in total economic surplus that results from an inefficiency such as a tax, price ceiling, or monopoly pricing. It represents transactions that would have been mutually beneficial but no longer occur due to the distortion.

Sources

Embed

<iframe src="https://homo-deus.com/lab/economics/supply-demand/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub