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, and ), 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 and are the prices of and , respectively, then and are the quantities demanded of and , respectively, and and are the quantities supplied of and , 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 and supply function for the good ? 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.

### Possible answers

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 be the equilibrium price of (i.e. the price such that there is some such that ). Then . 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 . 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 and is that, where is the amount of tax (or negative the amount of subsidy) on each unit of the good, if is the price paid by the consumer, then is the price received by the producer, and the quantity demanded is and quantity supplied is ; since quantities supplied and demanded must be equal, then we can just solve the equation for to get the price paid by the consumer, and the common value of and 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, means quantity traded if the tax or subsidy is adjusted so that the price paid by consumers is , and means the quantity traded if the tax or subsidy is adjusted so that the price received by producers is . 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 such that the price paid by consumers is and the price received by producers is (using superscripts as indices, not exponents), and is the price of the good , then , as these are the pairs consisting of quantities supplied of and , and quantities demanded of and , respectively. So , where is the solution to , and , where is the solution to .

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 , thus forcing to be the new market price. is then the quantity purchased by the original consumers, and 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 but doesn't get involved in the market for another good , then supply and demand for still must balance; that is, , where is the pegged price of and is the market price of . So the supply and demand functions for should be given by and , where is such that .

### 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, , and the joint demand function for left shoes and right shoes is given by , since is the price of a pair of shoes. And there is a supply function for total shoes, , and the joint supply function for left shoes and right shoes is given by if , if , and, if , can be any such that (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 be this market price for shoes, and now let's figure out the supply function 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 for , and for , 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 , then the price received by the producer for right shoes must also be , 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 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 .

If we assume a new agent offers to buy or sell unlimited numbers of left shoes for , 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 shoes in total. The original consumers will buy pairs of shoes. In particular, the original consumers will buy 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 left shoes.

Of these three purported supply functions, the first is radically different from the others, in that the latter two are continuous (if and are), but the first is discontinuous at . The relationship between the latter two supply functions for left shoes depends on the relationship between and , 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 goods, and would be the -tuples consisting of the quantities demanded or supplied of each good when is the price of the 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 is some space of goods, prices can be represented as a function , where is the price of the good . Quantity can be represented as a finite measure on , where for , is the combined quantity of all goods in .

So, where is the set of measurable functions and is the set of finite measures on , joint supply and demand functions for should be functions and . The market equilibrium price function is the solution to ( and should satisfy some conditions which should ensure that this exists), and the common value of and is the measure representing the market equilibrium quantities traded of types of goods in .