## Supply and Demand

Until recently, I thought I understood the concept of supply and demand functions pretty well: for each possible price of a good, we look at how much of the good consumers would collectively purchase if it was offered at that price, and how much of it producers would sell if offered that price for it. Sounds simple enough.

### Ambiguity

Problem is, the amount of something that a consumer will buy or that a producer will sell depends on more factors than just its price. So in order to determine how much of a good would be demanded or supplied in a counterfactual where its price changes, we also need to know about these other factors. You might want to let everything else stay the same, but this cannot be done. Changing the price of a good must come with some other changes as well. For instance, if the good has a substitute, then the price and quantity of the substitute cannot both stay the same when the price of the good changes.

So for supply and demand functions to be well-defined, we need a counterfactual model, which tells us what exactly is happening in the counterfactual where we set the price of a good and ask how much is demanded or supplied.

Given multiple goods (for simplicity, two goods, $x$ and $y$), we could consider joint supply and demand functions for them, which take as input a pair consisting of the price of the first good and the price of the second, and outputs a pair consisting of the quantities of each good supplied (for the supply function) or demanded (for the demand function) given those prices. So if $p_x$ and $p_y$ are the prices of $x$ and $y$, respectively, then $D(p_x,p_y)_x$ and $D(p_x,p_y)_y$ are the quantities demanded of $x$ and $y$, respectively, and $S(p_x,p_y)_x$ and $S(p_x,p_y)_y$ are the quantities supplied of $x$ and $y$, respectively. Given joint supply and demand functions, how should we extract supply and demand functions for each good individually? That is, how do we determine the demand function $D_x(p_x)$ and supply function $S_x(p_x)$ for the good $x$? To answer this question, we need to know what we mean by supply and demand functions, and answering this question provides similar information about what we mean by supply and demand functions as providing a counterfactual model does.

I'm going to make a couple simplifying assumptions for this discussion, not because they are true, but because they are convenient. First, producers and consumers are two entirely separate groups of people. Consumers don't get the money they spend on consumption by producing something, and producers don't spend the money they get for production on consuming anything else. Consumers just magically have money, and producers just hoard money so they can swim in it like Scrooge McDuck. Second, a system of equations has exactly one solution whenever I want it to.

Wikipedia suggests that in the counterfactuals considered for demand functions, prices of substitutes and complements should stay the same. This gives an answer to the question of how to extract individual demand functions from a joint demand function. Let $p_y^*$ be the equilibrium price of $y$ (i.e. the price such that there is some $p_x^*$ such that $D(p_x^*,p_y^*)=S(p_x^*,p_y^*)$). Then $D_x(p_x)=D(p_x,p_y^*)_x$. A counterfactual model to go along with this is that all producers disappear, and then a monopoly enters the market and offers to the consumers an unlimited supply of the same goods for the same prices that were being offered previously, except for the price of the good in question, which they change. The analogous assumption to make for supply functions is that the prices of other goods that the producers could be making instead (and any goods that can be most efficiently produced along with the good in question) stay the same. Then individual supply curves can be obtained from joint supply curves by $S_x(p_x)=S(p_x,p_y^*)_x$. And a counterfactual model is that all consumers disappear, and a monopsony enters the market and offers to purchase from the producers unlimited quantities of goods for the same prices the consumers were previously paying, except for the good in question, which they offer a difference price for.

End of story? No; there are other answers that could be given to these questions. You may have noticed that the counterfactual models I suggested were not especially realistic, which could be considered a drawback, so let's look at some other possibilities.

Suppose the government plans to tax or subsidize a good, and we want to know what effect this will have on the quantity of the good, the price paid by consumers, and the price received by the producers. The usual story for how to figure this out from supply and demand functions $S$ and $D$ is that, where $t$ is the amount of tax (or negative the amount of subsidy) on each unit of the good, if $p$ is the price paid by the consumer, then $p-t$ is the price received by the producer, and the quantity demanded is $D(p)$ and quantity supplied is $S(p-t)$; since quantities supplied and demanded must be equal, then we can just solve the equation $D(p)=S(p-t)$ for $p$ to get the price paid by the consumer, and the common value of $D(p)$ and $S(p-t)$ will be the quantity traded. What do we have to mean by supply and demand functions in order for this story to be correct? The counterfactual model here is clear: the government institutes a tax or subsidy of exactly the right amount so that the consumer/producer ends up paying/receiving a price equal to the input of the demand/supply function, respectively. In other words, $D(p)$ means quantity traded if the tax or subsidy is adjusted so that the price paid by consumers is $p$, and $S(p)$ means the quantity traded if the tax or subsidy is adjusted so that the price received by producers is $p$. To figure out the corresponding way to extract individual supply and demand functions from joint supply and demand functions, note that if the government taxes or subsidizes the good $x$ such that the price paid by consumers is $p_x^d$ and the price received by producers is $p_x^s$ (using superscripts as indices, not exponents), and $p_y$ is the price of the good $y$, then $S(p_x^s,p_y)=D(p_x^d,p_y)$, as these are the pairs consisting of quantities supplied of $x$ and $y$, and quantities demanded of $x$ and $y$, respectively. So $D_x(p_x)=D(p_x,p_y)_x$, where $(p_y,p_x^s)$ is the solution to $S(p_x^s,p_y)=D(p_x,p_y)$, and $S_x(p_x)=S(p_x,p_y)_x$, where $(p_y,p_x^d)$ is the solution to $S(p_x,p_y)=D(p_x^d,p_y)$.

Another possible counterfactual model is that a new agent enters the market and offers to buy or sell unlimited amounts of a good for a fixed price $p$, thus forcing $p$ to be the new market price. $D(p)$ is then the quantity purchased by the original consumers, and $S(p)$ is the quantity sold by the original producers. This happens, for example, with backing currency, where a government promises to sell as much of some good as anyone will buy at some fixed price, as a way of ensuring that money remains valuable. A related example is a fixed exchange rate, where a government pegs the price of its currency relative to a foreign currency at a fixed rate by exchanging the currencies in both directions at the pegged price with anyone who wants to trade them at that price, though this example is atypical in that the good being exchanged for money is also money. To figure out the way of extracting individual supply and demand functions from joint supply and demand functions corresponding to this counterfactual model, note that if the government pegs the price of a good $x$ but doesn't get involved in the market for another good $y$, then supply and demand for $y$ still must balance; that is, $D(p_x,p_y)_y=S(p_x,p_y)_y$, where $p_x$ is the pegged price of $x$ and $p_y$ is the market price of $y$. So the supply and demand functions for $x$ should be given by $D_x(p_x)=D(p_x,p_y)_x$ and $S_x(p_x)=S(p_x,p_y)_x$, where $p_y$ is such that $D(p_x,p_y)_y=S(p_x,p_y)_y$.

### Cases in which the appropriate notion of supply and demand functions is unclear

There are other situations that economists use supply and demand functions to describe, and each situation may need a different notion of what supply and demand functions mean, and the right way to define them for a given purpose might not always be obvious. For instance, suppose we want to predict the effects of price controls. This may only give meaning to the demand function on prices greater than or equal to the market price, and the supply function on prices less than or equal to the market price, since if supply and demand aren't equal due to price controls, then whichever one is smaller will determine the quantity traded, so it isn't clear that there's an objective way to say what the larger one should be.

Supply and demand functions are supposed to help us understand the effects of changes to supply or demand on price and quantity. The demand curve describes the set of (price, quantity) pairs that can be obtained by changes to how easy the good is to produce, and the supply curve describes the set of (price, quantity) pairs that can be obtained by changes to how desirable the good is. This is not completely well-specified, so what the supply and demand functions should be depends on which sorts of shocks should be considered to only affect demand for the good, or to only affect supply of the good. This isn't as straightforward as it might sound, since, for instance, two supply shocks might have different effects on demand because of having different effects on the market for a complement or substitute for the good; the supply shock can't have no effect on the market for the complement or substitute, because it affects the market for the original good, and the markets are linked, so some decision must be made about what assumptions to make about how a supply shock is supposed to affect the markets for other goods, which will depend on, for example, the extent to which the supply shock is due to producers leaving the market for a substitute or complement in order to produce the good in question instead, or vice-versa.

The area of the region bounded by the supply and demand curves and the price axis is used as an estimate of how much wealth is created by the market for the good (neglecting externalities). It isn't clear to me what way of defining supply and demand functions makes this the best metric, and it's not going to be perfect in any case, as it measures wealth in units of money, and the value of a certain amount of money to someone can vary depending on circumstances (for instance, on how much money they already have). Another problem is that areas of smaller regions in a supply and demand graph are used as measures of deadweight loss caused by market distorsions, but the nature of the market distorsion in question would require us to use one particular meaning of supply and demand functions in order to correctly describe the effects of the distorsion; if this meaning is not one for which area in the supply and demand graph accurately represents value, then accurately representing deadweight loss as the area of a region in a graph isn't possible.

### Example

A possible explanation for why these subtleties are not emphasized is that they don't make much difference in practice, as supply and demand functions tend to not depend too much on how exactly they're defined. But we can construct examples in which they are quite different.

Consider the supply function in the market for left shoes. Assume no one actually buys one shoe at a time, so no matter what the prices of left and right shoes are, the demand for each will be the same. Also assume that making left shoes and making right shoes is always equally easy for the producers, so they would shift entirely to producing just the more expensive chirality of shoe if the prices differed. That is, there is a demand function for pairs of shoes, $D_{pair}$, and the joint demand function for left shoes and right shoes is given by $D(p_{left},p_{right})=(D_{pair}(p_{left}+p_{right}),D_{pair}(p_{left}+p_{right}))$, since $p_{left}+p_{right}$ is the price of a pair of shoes. And there is a supply function for total shoes, $S_{shoes}$, and the joint supply function for left shoes and right shoes is given by $S(p_{left},p_{right})=(S_{shoes}(p_{left}),0)$ if $p_{left}>p_{right}$, $(0,S_{shoes}(p_{right})$ if $p_{right}>p_{left}$, and, if $p_{left}=p_{right}=p$, can be any $(q_{left},q_{right})$ such that $q_{left}+q_{right}=S_{shoes}(p)$ (if you don't like multi-valued functions, you can pretend we're working with a continuous approximation to this joint supply function).

The market prices for left shoes and for right shoes must be the same, since otherwise the producers would only make shoes of one chirality. Let $p^*$ be this market price for shoes, and now let's figure out the supply function $S_{left}$ for left shoes according to each of the three conventions I described in the section on possible answers.

If we are to assume that the prices of right shoes are constant, then $S_{left}(p_{left})=0$ for $p_{left}, and $S_{left}(p_{left})=S_{shoes}(p_{left})$ for $p_{left}>p^*$, since all production shifts to the more expensive chirality of shoe when we vary the price of left shoes.

If we assume that the government taxes or subsidizes left shoes such that the price received by the producer for left shoes is $p_{left}$, then the price received by the producer for right shoes must also be $p_{left}$, since consumers will still be buying both chirality of shoe, which means prices must adjust so that producers will still make both chiralities of shoe (this will mean that consumers will pay different prices for left and right shoes, with the difference being the amount of the tax or subsidy). So the producers will make $S_{shoes}(p_{left})$ shoes in total. Since the consumers will buy equal numbers of each, the producers must make equal numbers of each in order to sell them all, so $S_{left}(p_{left})=\frac{1}{2}S_{shoes}(p_{left})$.

If we assume a new agent offers to buy or sell unlimited numbers of left shoes for $p_{left}$, then again right shoes are going to end up going for the same price (except in the extreme cases where the original producers don't end up making any left shoes, or the original consumers don't end up buying any shoes, but let's suppose that doesn't happen). The original producers will supply $S_{shoes}(p_{left})$ shoes in total. The original consumers will buy $D_{pairs}(2p_{left})$ pairs of shoes. In particular, the original consumers will buy $D_{pairs}(2p_{left})$ right shoes, which is the same as the number of right shoes sold by the original producers, since the new agent does not buy or sell any right shoes. Thus, the original producers make $S_{left}(p_{left})=S_{shoes}(p_{left})-D_{pairs}(2p_{left})$ left shoes.

Of these three purported supply functions, the first is radically different from the others, in that the latter two are continuous (if $S_{shoes}$ and $D_{pairs}$ are), but the first is discontinuous at $p_{left}=p^*$. The relationship between the latter two supply functions for left shoes depends on the relationship between $S_{shoes}$ and $D_{pairs}$, but they certainly can be quite different.

One could argue that this example doesn't count, because a pair of perfect complements can just be considered a single good sold as a bundle (as left and right shoes typically are in practice). But complements that are not perfect complements also exist, and producers do sometimes have some ability to shift between markets, so approximate versions of this example should exist in real life.

### Joint supply and demand functions for infinitely many types of goods

We can, of course, consider joint supply and demand functions of arbitrarily many goods, instead of just two. For $n$ goods, $D(p_1,...,p_n)$ and $S(p_1,...,p_n)$ would be the $n$-tuples consisting of the quantities demanded or supplied of each good when $p_i$ is the price of the $i$th good. But sometimes goods can vary across a continuum of possibilities, and in such cases, it might not be appropriate to think of the market as just involving finitely many types of goods. For example, goods may vary by quality, with higher-quality goods being both more preferred by the consumers and harder to produce, and goods of different qualities substituting for each other. Or in the case of goods that can't easily be moved, like buildings, consumers may have preferences about their location, and location may affect how easily the goods can be produced. Quality and location can each be modeled as varying across a continuum of possibilities.

Where $X$ is some space of goods, prices can be represented as a function $p:X\rightarrow\mathbb{R}_+$, where $p(x)$ is the price of the good $x$. Quantity can be represented as a finite measure $\mu$ on $X$, where for $Y\subseteq X$, $\mu(Y)$ is the combined quantity of all goods in $Y$.

So, where $\mathbb{R}_+^X$ is the set of measurable functions $X\rightarrow\mathbb{R}_+$ and $M(X)$ is the set of finite measures on $X$, joint supply and demand functions for $X$ should be functions $S:\mathbb{R}_+^X\rightarrow M(X)$ and $D:\mathbb{R}_+^X\rightarrow M(X)$. The market equilibrium price function is the solution $p^*$ to $S(p^*)=D(p^*)$ ($S$ and $D$ should satisfy some conditions which should ensure that this exists), and the common value of $S(p^*)$ and $D(p^*)$ is the measure representing the market equilibrium quantities traded of types of goods in $X$.