**Leibniz** 8.5.1 Gains from trade

For an introduction to the Leibniz series, please see ‘Introducing the Leibnizes’.

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 , where is the price and is the number of loaves. Under the usual assumption that demand curves slope downward (the Law of Demand), 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 consumer is willing to pay . 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 , then the surplus of the consumer will be . In the diagram, this is the vertical distance at the quantity 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 and the total quantity sold is . Then we need to add up the surpluses at all points on the demand curve between and :

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

It follows from the Law of Demand that is a decreasing function, so 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 and . It is the area of the roughly triangular region bounded by the demand curve, the vertical axis and the horizontal line . (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 of bread be , then the marginal cost is , and is the equation of the inverse market supply function.

We assume as in the text that is positive and increases with , which means that is an increasing, convex function. We will also assume that , in which case we can write:

by the fundamental theorem of calculus. This equation tells us that the total cost is the area under the marginal cost curve, for quantities less than or equal to . If 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 loaf of bread at the price , its surplus from this transaction will be less the cost of producing this loaf, . If the total number of loaves produced and sold at price is , the producer surplus is the sum of the surpluses on each loaf:

From this expression you can see that, under our assumption that , 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 and . It is the area of the roughly triangular region bounded by the supply curve, the vertical axis and the horizontal line .

Notice that the expressions we have obtained for consumer surplus, , and producer surplus, , give the value of consumer surplus for any price and any quantity ; 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 and quantity .

## 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 :

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

Note that since is concave the second derivative of is negative, which confirms that this condition gives us a maximum point.

This equation tells us that if the price is , is maximized when the quantity sold is on the demand curve at —that is, when all consumers whose willingness to pay is greater than or equal to 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 and the quantity sold is :

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 that maximizes the total surplus, we set the derivative of to zero. Then is the quantity that satisfies the equation:

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

Since this equation tells us that is at the point where the inverse demand curve meets the inverse supply curve . 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 , 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.