# Leibniz

Buyers and sellers participate in a market because they each benefit from doing so, and consumer and producer surplus provide a measure of their gains from trade. Here we show how to calculate the surplus mathematically, and prove that the competitive equilibrium allocation maximizes the gains from trade.

We described the gains from trade in the market for bread in one city using Figure 8.9a, reproduced as Figure 1 below. The surplus obtained by consumers is represented by the area below the demand curve and above the horizontal line at the level of the market price. Producer surplus is the area above the supply curve and below the horizontal price line. The sum of these two areas is the total gain from trading in this market.

To determine the gains from trade mathematically, suppose the demand for bread is described by the inverse demand function $P=f(Q)$, where $P$ is the price and $Q$ is the number of loaves. Under the usual assumption that demand curves slope downward (the Law of Demand), $f$ is a decreasing function. Remember that the demand function tells us the willingness to pay (WTP) for bread. If consumers are lined up in order of willingness to pay for a loaf, then the $q^{th}$ consumer is willing to pay $P = f(q)$. Any buyer whose willingness to pay for a good is higher than the market price receives a surplus. If we suppose that the market price for a loaf of bread is $P_0$, then the surplus of the $q^{th}$ consumer will be $f(q) - P_0$. In the diagram, this is the vertical distance at the quantity $q$ between the demand curve and the horizontal line at the market price.

The consumer surplus is found by adding up the surpluses for all the consumers who purchase bread at this price. Because we have described demand using a continuous function (we are not dealing with discrete numbers of loaves), we use integration to sum the individual surpluses. Suppose the price is $P_0$ and the total quantity sold is $Q$. Then we need to add up the surpluses $(f(q)-P_0)$ at all points on the demand curve between $q=0$ and $q=Q$:

In this expression, we have introduced the notation $F(Q)$ to denote the integral of the function $f$. That is, the area under the demand curve for quantities between 0 and $Q$. By the fundamental theorem of calculus:

It follows from the Law of Demand that $F'$ is a decreasing function, so $F$ is a concave function.

The red-shaded area in Figure 1 shows the consumer surplus in the case when the market is in competitive equilibrium, with $P_0 = 2$ and $Q = 5,000$. It is the area of the roughly triangular region bounded by the demand curve, the vertical axis and the horizontal line $P=P_0$. (By ‘roughly triangular’ we mean that the region would be a triangle if the demand curve were a straight line.)

We can calculate producer surplus in a similar way. Remember from Leibniz 8.4.1 that the inverse supply curve is the marginal cost curve from bread production in this market. If we let the total cost to bakeries of producing a quantity $Q$ of bread be $C(Q)$, then the marginal cost is $C'(Q)$, and $P=C'(Q)$ is the equation of the inverse market supply function.

We assume as in the text that $C'(Q)$ is positive and increases with $Q$, which means that $C$ is an increasing, convex function. We will also assume that $C(0) = 0$, in which case we can write:

by the fundamental theorem of calculus. This equation tells us that the total cost $C(Q)$ is the area under the marginal cost curve, for quantities less than or equal to $Q$. If $C(0)$ were not zero we would say instead that the area under the marginal cost curve is equal to total variable costs—that is, total costs excluding the fixed costs which are incurred even if the bakeries produce no bread.

If a bakery sells the $q^{th}$ loaf of bread at the price $P_0$, its surplus from this transaction will be $P_0$ less the cost of producing this loaf, $C'(q)$. If the total number of loaves produced and sold at price $P_0$ is $Q$, the producer surplus is the sum of the surpluses on each loaf:

From this expression you can see that, under our assumption that $C(0) = 0$, the producer surplus is equal to the firm’s profit. If the firm also had fixed costs, its profit would be equal to its producer surplus minus its fixed costs.

The purple-shaded area in Figure 1 shows the producer surplus in the case of competitive equilibrium, with $P_0 = 2$ and $Q = 5,000$. It is the area of the roughly triangular region bounded by the supply curve, the vertical axis and the horizontal line $P = P_0$.

Notice that the expressions we have obtained for consumer surplus, $F(Q)-P_0Q$, and producer surplus, $P_0Q-C(Q)$, give the value of consumer surplus for any price $P_0$ and any quantity $Q$; they apply whether or not the price is the at the market-clearing level. Figure 2 shows the consumer and producer surplus for the general case of an arbitrary $P_0$ and quantity $Q$.

Consumer and producer surplus when the price and quantity are not at their equilibrium values.

Figure 2 Consumer and producer surplus when the price and quantity are not at their equilibrium values.

### Maximizing consumer and producer surplus

Since consumer and producer surplus measure the gains from trade, it is useful to know what conditions make them as large as possible. Consider first our expression for consumer surplus, which we will call $CS$:

For a given price $P_0$, the quantity $Q$ that maximizes consumer surplus can be found by setting the derivative of $CS$ to zero:

Note that since $F(Q)$ is concave the second derivative of $CS$ is negative, which confirms that this condition gives us a maximum point.

This equation tells us that if the price is $P_0$, $CS$ is maximized when the quantity sold is on the demand curve at $P_0$—that is, when all consumers whose willingness to pay is greater than or equal to $P_0$ participate in the market. If fewer consumers participate there are unexploited gains; if any other consumers bought bread they would receive a negative surplus, decreasing the aggregate consumer surplus.

In exactly the same way, you can show that producer surplus

is maximized when

So whatever the price, producers maximize their surplus if the marginal cost of bread is equal to the price.

### Maximizing total surplus

The sum of the producer and consumer surplus is the total surplus. When the price is $P_0$ and the quantity sold is $Q$:

The total surplus can be simplified to:

Note that the total surplus depends only on the quantity sold. Whatever the price, the amount paid for bread is a loss for consumers and an equal gain for firms, so the two cancel out when we evaluate the total surplus from the market.

To find the quantity $Q^*$ that maximizes the total surplus, we set the derivative of $N(Q)$ to zero. Then $Q^*$ is the quantity that satisfies the equation:

To be sure that $Q^*$ maximizes $N$, we need to consider the second derivative. Remember that $F$ is concave, and $C$ is convex. So the second derivative of $F$ is negative, and the second derivative of $C$ is positive. We can deduce that the second derivative of $N$ is negative, and hence that $Q^*$ corresponds to a maximum point.

Since $F'(Q^*) =f(Q^*),$ this equation tells us that $Q^*$ is at the point where the inverse demand curve $P=f(Q)$ meets the inverse supply curve $P=C'(Q)$. $Q^*$ is the level of output at which demand and supply curves cross. This is the level of output achieved when the market is in competitive equilibrium. Thus we have proved that in the competitive equilibrium allocation, in which the market clears at the equilibrium price $P^* = f(Q^*) =C'(Q^*)$, the quantity sold maximizes the total gains from trade.

Read more: Sections 8.4 and 19.1 of Malcolm Pemberton and Nicholas Rau. 2015. Mathematics for economists: An introductory textbook, 4th ed. Manchester: Manchester University Press.