Nadia keeps 120 dollars a week for the bakery on Harbor Falls' main street. Coffee is 4 dollars a cup, pastries are 6. She has never written down an equation about this in her life, and yet if you follow her for a month you find her buying, almost exactly, fifteen coffees and ten pastries a week. Not twenty and seven. Not six and sixteen. The same corner of the same two-dimensional space, week after week.
That regularity should bother you slightly, because nothing has forced it. She could afford thirty coffees and no pastries. She could afford twenty pastries and no coffee. She could afford any of the infinitely many mixtures in between, and every one of them uses the full 120 dollars just as completely as the bundle she actually picks. Whatever selects fifteen-and-ten out of that continuum is not the budget — the budget is indifferent between all of them.
And here is why it matters beyond one person's breakfast. Supply, Demand, and Market Equilibrium opened with a demand curve, , and justified it in a sentence: at higher prices, buyers want less. Elasticity and Its Applications then built an entire apparatus on top of that curve — measuring its slope, classifying its responsiveness, deriving who bears a tax. Both topics used the demand curve. Neither derived it. Where does a demand curve come from? What is it a picture of?
This is the first university-level topic in this track, and it is where that question gets answered rather than deferred. Everything before this described markets from the outside — curves crossing, surpluses, wedges. From here we go underneath, to the person, and build the curve out of something more primitive: what she can afford, what she wants, and one piece of constrained optimization. The mathematics is calculus with several variables and a Lagrange multiplier. That is not a detour and it will not be apologized for — it is the only honest way to get the result, and the multiplier itself turns out to have an economic meaning so clean that it is worth the whole derivation on its own.
What you can afford: the budget constraint
Start with the part that involves no psychology at all. Write for cups of coffee per week and for pastries per week, with prices and and income . Nadia can buy any bundle that satisfies
and with her numbers, . The set of bundles satisfying this is the budget set; its outer edge, where the inequality binds,
is the budget line. Solve it for to see it as a graph:
Three numbers in that line are worth naming, because every comparative-static result later in the topic is one of them moving.
The vertical intercept is what she gets spending everything on pastries. The horizontal intercept is everything on coffee. And the slope, , is the interesting one. It is not a statement about Nadia. It says: the market will trade you one more coffee in exchange for two-thirds of a pastry, and it will do so at that rate all day. Give up a pastry, free 6 dollars, buy one and a half coffees. The slope of the budget line is the market rate of exchange between the two goods — the opportunity cost of coffee measured in pastries, which is exactly the notion Opportunity Cost and the Production Possibilities Frontier built for production and which now reappears, unchanged, on the consumption side.
Notice what the slope does not contain: income. Divide the constraint by and appears only in the intercept. So the two kinds of change are cleanly separated:
- Income changes. Double to 240 and the line becomes : same slope, both intercepts doubled. The budget line shifts out parallel to itself. Nothing about relative scarcity changed; there is simply more of everything available.
- A price change. Raise from 4 to 6 and the line becomes : the vertical intercept is untouched (spending everything on pastries is unaffected by the price of coffee), the horizontal intercept falls from 30 to 20, and the line pivots, getting steeper.
That asymmetry is the seed of something. A price change does two things at once — it shrinks the budget set, like a loss of income, and it tilts it, changing the exchange rate. Hold that thought; the closing section comes back to it, and it is the reason a whole separate topic exists.
One assumption is buried in writing the constraint with an equality. Why should Nadia spend all 120 dollars? Only because we are about to assume she always prefers more to less, so that leftover money is wasted utility. That assumption is called monotonicity, and it is one of four we now have to be explicit about.
What you want: preferences and indifference curves
The budget set says what is possible. To pick a point out of it we need to describe what Nadia wants, and the trick that makes this tractable is to describe preferences by ranking bundles rather than by measuring them. Write to mean "she likes the first at least as well as the second." Four assumptions on that ranking do all the work:
Completeness. For any two bundles, either or (or both). She is never simply unable to compare. This buys you the existence of a best element — without it, an optimum might not be well defined at all.
Transitivity. If and then . This buys you consistency, and it is less innocuous than it sounds: a consumer with intransitive preferences can be walked around a cycle of trades she accepts at every step and returned to where she started, minus a fee. Transitivity is what rules out that money pump.
Monotonicity. More is better: if a bundle has at least as much of both goods and strictly more of one, it is strictly preferred. This buys you two things — the budget constraint binds with equality, and indifference curves slope downward (give up some and you must be compensated with some to stay indifferent).
Convexity. Averages are at least as good as extremes: if , then the mixture is at least as good as either. This is the assumption that makes moderate bundles attractive — it is why Nadia buys some coffee and some pastries rather than going all-in on one. It is also, as we will prove below, the assumption that turns a point where calculus says "stationary" into a point where economics says "best."
Now represent the ranking by a utility function chosen so that exactly when . Crucially, only the ordering is meaningful. If represents Nadia's preferences then so does , or , or — any strictly increasing transformation, because it reorders nothing. There is no unit of utility, no "utils per pastry" you could measure with an instrument. Anything we derive that depends on the level of is an artifact; anything that survives every monotonic transformation is real economics. We will use this fact twice, and get caught by it once.
For Nadia, take
An indifference curve is a level set of — the collection of bundles she rates equally. Setting gives , a hyperbola. Her observed bundle sits on . The bundle sits on , and on . Higher curves are better, by monotonicity, and no two curves cross — if they did, transitivity would fail on the spot, since the crossing bundle would be indifferent to points on both curves while those points are not indifferent to each other.
The marginal rate of substitution
The slope of an indifference curve is the single most important derivative in consumer theory, and it deserves to be derived rather than asserted. Take the defining equation of one curve,
and totally differentiate both sides. The right side is a constant, so its differential is zero:
Solve for the slope:
The marginal rate of substitution is defined as the magnitude of that slope:
Read it as a willingness, not a technology: is the number of pastries Nadia would hand over for one more coffee and feel exactly as well off. It is her personal exchange rate, in the same units as the market's exchange rate , which is what will let us set them equal in a moment.
Notice immediately that the survives monotonic transformation. Replace by with ; the chain rule gives and likewise for , and the common factor cancels in the ratio. The is real. The number itself is not.
For the partials are and , so
Evaluate it along the curve , where , so :
The falls as she moves right along the curve. This is diminishing marginal rate of substitution, and it is convexity in derivative form: when she has 6 coffees and 25 pastries, one more coffee is worth over four pastries to her; when she already has 25 coffees and 6 pastries, one more coffee is worth barely a quarter of a pastry. The good she is short of is the good she values at the margin.
The connection to convexity is exact rather than rhetorical. Differentiate the indifference curve twice: and . A curve with lies above every one of its chords, which is precisely the statement that the average of two indifferent bundles is weakly preferred. Convex preferences, diminishing , and indifference curves bowed toward the origin are three descriptions of one fact.
The optimum, three ways
Now put the two halves together. Nadia wants to reach the highest indifference curve that the budget set allows.
First, geometrically. Suppose she is at an interior bundle on the budget line where — say . Her indifference curve through that point is steeper than the budget line, so the two curves cross rather than touch, which means part of the budget line pokes above her indifference curve. Any point on that part is affordable and strictly better. The same argument runs in reverse if . So at an interior optimum, crossing is impossible, and the only remaining possibility is tangency:
In words, and this is the whole idea: the rate at which she is willing to trade equals the rate at which the market lets her trade. Whenever those two rates differ, there is a trade she wants that the market will give her.
Second, by arbitrage, with numbers. Take the bundle , which is on the budget line — — so it is affordable and uses every dollar. Its marginal utilities are and . Ask what one dollar buys on each side:
A dollar spent on pastry delivers four times what a dollar spent on coffee delivers. So move dollars: give up 3 coffees, freeing 12 dollars, and buy 2 pastries. The new bundle is , still costing , and its utility is — up from 96, for zero extra money. Repeat the reasoning at : and , still unequal, so keep going. The process only stops when
which is the tangency condition rearranged — divide through and is back. This form is worth memorizing in its own words: the last dollar spent on each good must buy the same marginal utility. If it did not, a dollar could be moved and something gained for nothing, and that is not what an optimum looks like.
Third, by Lagrange, which is the version that generalizes. Maximize subject to . Form
and set the three partial derivatives to zero:
The first two rearrange to
which is the equal-marginal-utility-per-dollar condition, now with a name for the common value. Dividing the first two equations instead of setting them equal gives , the tangency condition. The third equation is just the budget constraint, recovered for free — which is the whole reason the multiplier is introduced this way.
Solve for Nadia. With : and . Substituting into the constraint,
and therefore and . Fifteen coffees and ten pastries — the bundle we started the topic by observing. Check the tangency: , and . ✓
What means. The multiplier is not bookkeeping; it is the marginal utility of income. Prove it here rather than quoting it. Solve the problem for general : the same algebra gives and , so the maximized utility is
Differentiate with respect to income:
So answers "how much better off is she made by one more dollar?" — 2.5 units of per dollar, at these prices and this income. (This is the envelope theorem in its smallest possible case, and it is the same structure as the shadow prices that appear all over constrained optimization.)
And here is the place we get caught by the earlier warning. Utility levels are not meaningful, so 's numerical value cannot be either. Replace by , which represents identical preferences. The first-order conditions become and , giving , and with the budget, . Same bundle — as it must be, since the preferences are the same — but , nothing like 2.5. The ratio condition is invariant; the level is measured in whatever units the chosen happens to use. Every real prediction of this theory lives in the ratios.
Second-order conditions, and where convexity earns its keep. All three routes found a stationary point. Stationary is not maximal — the same equations would be satisfied at a minimum. Do the check directly by substituting the constraint into the objective, which reduces the problem to one variable:
Then , which vanishes at ✓, and
everywhere, so the stationary point is a genuine maximum, and a global one. That negative second derivative is convexity of preferences doing its job: utility restricted to the budget line is concave precisely because the indifference curves bow the right way. Reverse the curvature — concave preferences, where extremes beat averages — and the same tangency equations would locate the worst affordable bundle on the budget line, with the true optimum at a corner. Convexity is not a technical convenience; it is what makes "set the derivative to zero" the right thing to do.
Cobb-Douglas, all the way through
One example is an anecdote. Do the whole family at once, because the general result is short and the specific one hides how much of it is an accident. Let
Nadia's is the case . Before optimizing, apply the monotonic-transformation trick to make the algebra trivial: maximize
instead. This changes no preference and therefore no optimal bundle — it only changes the units in which is reported, which we have just established is not real information. The Lagrangian is
with first-order conditions
Now the move that makes Cobb-Douglas famous. Multiply the first by and the second by :
The left sides are constants, so expenditure on each good is pinned down before the budget is even used. Add the two equations and substitute the constraint :
Put that back into and solve:
These are demand functions: quantity as a function of prices and income, which is what the whole topic was after. Check them against Nadia. With , , , : and . ✓ Same answer, from the general formula.
Three properties are worth staring at, and the third is a warning.
Constant expenditure shares. Multiply the demand by the price:
Nadia spends exactly half her budget on coffee — 60 dollars — no matter what the price of coffee is. At 4 dollars a cup she buys 15; at 6 dollars she buys 10; at 2 dollars she buys 30. Always 60 dollars.
Demand for does not depend on . The formula for contains and and nothing else. If pastries double in price, Nadia buys exactly as much coffee as before. That is a strong claim — most goods are not like that — and it is not a theorem of consumer choice. It is a property of these exponents.
Homogeneity of degree zero. Scale all prices and income by the same factor : becomes , which is again. Double every price and every wage and nothing real changes. This one is general — it holds for any preferences, since scaling by leaves the budget set literally unchanged — and it is the microeconomic statement that money is a veil.
Be honest about which of these is which. Constant shares and cross-price independence are special properties of Cobb-Douglas, chosen here because they let every step be done in closed form. Real preferences give demands where matters a great deal — coffee and pastries plausibly being complements, so that costlier pastries would reduce coffee purchases too. Cobb-Douglas sits exactly on the knife edge where the substitution and income effects of a cross-price change cancel. That is a coincidence of the functional form, not a discovery about people.
Where the demand curve actually comes from
Now collect the payoff. Fix , , , and let vary. The demand function becomes
with the companion sitting there unmoved. Tabulate it, including the expenditure so the constant-share result is visible:
That first row against the second is a demand curve. Not an assumption about how buyers behave, not a stylized fact — a locus of tangency points, each one a solved constrained-optimization problem at a different price. Slide the budget line's horizontal intercept in and out, watch where it kisses the highest reachable hyperbola, and record the -coordinate. That is all a demand curve has ever been.
This closes a loop opened at topic 3. Supply, Demand, and Market Equilibrium drew a downward-sloping line and explained it with "at higher prices, buyers want less." The explanation was true and the curve was doing real work, but nothing underneath it had been built. Here it is built: demand slopes downward because raising steepens the budget line, and a steeper budget line touches the indifference map at a point further to the left. And to get market demand you add individual demands horizontally — 500 consumers like Nadia give — exactly as 500 bakeries were summed into a market supply curve in The Costs of Production. The two sides of the crossing now have the same kind of foundation underneath them.
One more result falls out for free, and it settles a question left standing in Elasticity and Its Applications. Compute the price elasticity of this demand curve directly from the definition:
at every price, exactly. Cobb-Douglas demand is unit elastic everywhere — and that is the same fact as constant expenditure shares, seen from the other side. The elasticity topic proved that total revenue is unchanged by a price move precisely when demand is unit elastic; here the "revenue" is Nadia's spending on coffee, and it is stuck at 60 dollars whatever happens to . Two results derived in different topics from different starting points, agreeing on the nose.
Which also tells you something the last section warned about. The linear demand curve from topic 3 has an elasticity that varies along its length — near-zero at low prices, unboundedly elastic near the choke price. A hyperbola has elasticity throughout. So linear demand cannot come from Cobb-Douglas preferences; it comes from other preferences. Both are demand curves; neither is the demand curve. What is general is the machinery that produces them, not any particular shape.
When tangency fails: corners and perfect substitutes
Everything above assumed the optimum is interior — that Nadia buys a strictly positive amount of both goods. Cobb-Douglas guarantees this, because as : the first cup of coffee is infinitely valuable, so she never buys zero. Not all preferences are so accommodating.
Take perfect substitutes, where the two goods differ only by a fixed conversion rate:
One pastry always does the work of exactly two coffees, at every bundle. Then and , so
a constant. The indifference curves are straight lines of slope , and the budget line has slope . Two straight lines with different slopes cannot be tangent anywhere. The tangency condition has no solution, and the reason is not that the problem is ill-posed — it is that the answer is at a boundary. Compare marginal utility per dollar:
Pastries beat coffee by that measure at every bundle, and unlike the Cobb-Douglas case nothing about buying more pastries ever erodes the advantage — the ratios are constants. So she pushes all the way to the corner: , , giving . The opposite corner, , gives only , even though coffee is the cheaper good. Cheapness per unit is not the criterion; usefulness per dollar is.
The general statement replaces the equalities with inequalities. At an optimum,
and likewise for . Interior optima make both equalities bind and recover tangency; corner solutions leave one slack, meaning the good is not worth its price even at zero consumption. This is the Kuhn-Tucker form of the problem, and it is what a computer actually solves. The tangency condition is the special case where the constraints and happen not to matter — which is most of the time, and never all of the time.
Worked example
A consumer has , income dollars, and prices and . (a) Derive the optimal bundle from the Lagrangian, without quoting the Cobb-Douglas formula. (b) Verify the tangency condition and the budget constraint. (c) Find the Lagrange multiplier and confirm it equals the marginal utility of income. (d) The price of doubles to 10. Find the new bundle, and find the income that would restore the original utility level at the new prices. (click to reveal the solution)
Setting up (a) — the Lagrangian. Take logs first, since is strictly increasing and therefore represents the same preferences:
The Lagrangian is
with first-order conditions
From the first two, and . Substituting both into the budget constraint:
Back-substituting: , so ; and , so .
Step (b) — check both conditions. The budget: . ✓ And notice the expenditures split , which is — the exponent ratio, as the general result predicts.
For the tangency, use the original rather than the log version, to confirm the is transformation-proof:
At : , and . ✓ Equal, as required. (Doing the same from : , , ratio — identical, which is the invariance argument in one line.)
Step (c) — the multiplier as the marginal utility of income. For general the same algebra gives and , so
using to collect the terms. Therefore
Now do it again with the untransformed , to see the units problem concretely. Since , is proportional to , so . Numerically , giving . Cross-check against the first-order condition: . ✓ Same number by two routes — but , not . Both are correct marginal utilities of income; they differ because and measure "utility" on different scales. The bundle is the same either way, and that is the only part a consumer could act on.
Step (d) — a price change, and compensation. With the demand formulas give
Budget check: . ✓ Consumption of halved when its price doubled — exactly what constant expenditure shares require — while did not move a unit, which is the Cobb-Douglas peculiarity flagged earlier and not a general truth.
Utility fell from to . The ratio is clean in closed form: only the term changed, so
which matches . ✓
To restore the old utility at the new prices, note that Cobb-Douglas indirect utility with is proportional to , so utility scales one-for-one with income. Multiply income by the same factor:
Verify by recomputing the bundle at and : and , giving . ✓ Back to the original utility.
And now look hard at that compensated bundle: , against the original . Handing her enough money to be as well off as before does not hand her back her old shopping basket. She ends up with substantially more and less than she started with, because at the new prices is genuinely a worse deal and she rearranges around it. The price change did two separable things, and the compensation only undid one of them.
Where this leads
Start with a budget set, a preference ordering satisfying four assumptions, and one Lagrangian, and the entire demand side of every diagram in this track falls out: the tangency condition , the equal-marginal-utility-per-dollar rule that is the same condition in disguise, a multiplier that turns out to be the marginal utility of income, and — the point of the exercise — a demand function that no longer has to be assumed. The curve Supply, Demand, and Market Equilibrium drew on faith at topic 3 is now a locus of solved optimization problems, and the elasticity that Elasticity and Its Applications measured off that curve can be computed from the preferences underneath it. The market diagrams have not changed; what has changed is that both curves in them now stand on something. Demand rests on utility maximization here, exactly as supply rests on cost minimization in The Costs of Production — the same mathematics, run from the other side of the counter.
But the worked example ended on something that should not be allowed to pass. When the price of pastries doubled, Nadia's counterpart was made poorer and faced a different exchange rate, and those are not the same event. Give her back exactly enough income to reach her old indifference curve and she does not return to her old bundle — she lands somewhere else entirely, holding more of the good that got relatively cheaper. So a price change is really two changes superimposed: the budget line pivots (goods trade against each other at a new rate) and the budget set shrinks (she can reach less overall). Nothing so far has separated them.
That separation matters more than it sounds, because the two effects need not point the same way. A price rise always makes the good relatively less attractive — that direction is guaranteed. But it also makes the buyer poorer, and if the good is one people buy more of when they get poorer, that second push runs backwards. Push it far enough and you can construct a good whose demand curve slopes upward, which would be a genuine counterexample to the law of demand rather than a curiosity. Whether such a thing can really exist, and what has to be true of preferences for it to, is the subject of Income and Substitution Effects.
There is a second loose end, larger and further off. This entire topic took prices as given — a number on a sign, arriving from outside. Nadia optimizes against 4 and 6 without ever influencing them. But every one of those prices is the outcome of a market whose demand side is made of people doing precisely this calculation, and whose supply side is made of firms doing its mirror image. What happens when you solve everyone's problem simultaneously, and require every market to clear at once? The answer is a system where the prices are unknowns rather than data, and it comes with two theorems about whether the resulting allocation is any good: General Equilibrium and the Welfare Theorems.