Lagrange Multipliers: Optimisation with Constraints
Teaching resource for Mathematics, Sciences Po Paris.
Most economic problems are not “maximise this function”. They are “maximise this function given that you cannot spend more than you have”. The Lagrangian turns the second problem into the first. If the first-order conditions here look unfamiliar, start with Derivatives.
1. The problem
You want to maximise f(x, y) subject to a constraint g(x, y) = c. The objective is usually utility, profit or output. The constraint is a budget, a technology or a resource you cannot exceed.
The naive approach is to solve the constraint for y, substitute it into f, and maximise in one variable. That works, and for simple problems it is faster. It stops working as soon as the constraint cannot be solved cleanly for one variable, or as soon as you have three choice variables and two constraints. The Lagrangian always works, and it hands you a piece of economics for free.
2. The intuition
At the optimum, the level curve of f is tangent to the constraint. If it were not, the two curves would cross, and you could slide along the constraint onto a higher level curve.
Tangency means the two gradients point in the same direction:
That is the whole theorem. The multiplier λ is whatever number makes the two gradients match in length once they already match in direction.
3. The recipe
Write the Lagrangian:
Then set all three partial derivatives to zero:
The third condition is just the constraint, which is why you never have to remember it separately. Dividing the first condition by the second one kills λ and leaves the tangency condition:
Two equations, tangency and the constraint, and two unknowns. Solve.
4. Worked example: the consumer problem
Maximise U(x, y) = xᵃ y¹⁻ᵃ subject to pxx + pyy = m, with 0 < a < 1.
The first-order conditions in x and y:
Divide the first by the second:
The left-hand side is the marginal rate of substitution, so tangency says MRS equals the price ratio: the rate at which you are willing to trade y for x equals the rate at which the market lets you. Rearranging gives pyy = ((1−a)/a)·pxx, and substituting that into the budget constraint:
With Cobb-Douglas preferences the consumer spends a fixed share a of income on x, whatever the prices are. That is a strong prediction, and it is why this utility function turns up in every problem set.
5. What λ actually is
λ is not algebraic debris to be discarded. It is the shadow price of the constraint: the rate at which the best attainable value of the objective improves when you relax the constraint by one unit. If V(c) is the maximum of f given constraint level c, then
This is the envelope theorem, and it saves a lot of work. It says you can ignore how x* and y* themselves move when c changes, because those effects cancel at the optimum.
In the example above, put the solutions back into the utility function:
So here λ is the marginal utility of income: one more euro of budget buys λ more utils. Reading the units always tells you what λ means. In a cost-minimisation problem, where you minimise wL + rK subject to producing at least q, the multiplier comes out in euros per unit of output, and it is marginal cost.
6. Inequality constraints
Budgets are usually “no more than”, not “exactly”. For max f(x) subject to g(x) ≤ c, the Karush-Kuhn-Tucker conditions add two requirements to the same first-order conditions:
The last line is complementary slackness, and it says that one of two things must hold. Either the constraint binds, g(x) = c, and the multiplier is positive. Or the constraint is slack and λ = 0, in which case the constraint was irrelevant and you could have ignored it. A constraint that does not bind has no shadow price.
In practice: guess which constraints bind, solve, then check that your solution really satisfies the ones you assumed slack and that every λ came out non-negative. If it did not, guess again.
7. Common mistakes
- Reading the sign of λ as meaningful in itself. Writing L = f + λ(c − g) flips it. What matters is keeping one convention and interpreting the magnitude.
- Forgetting the third first-order condition. The derivative with respect to λ is the constraint. Drop it and you have two equations and three unknowns.
- Stopping at the tangency condition. MRS equal to the price ratio is only half the answer: it is a ratio, not a quantity. You still need the constraint to pin down levels.
- Assuming an interior solution. With perfect substitutes, or when one good is far too expensive, tangency has no valid solution and the optimum sits at a corner.
- Treating a critical point as a maximum. First-order conditions only produce candidates. You need a concave objective and a convex feasible set, or a second-order check.
- Rescaling the constraint and expecting λ to survive. Writing the budget as 2pxx + 2pyy = 2m halves λ, because the shadow price is defined per unit of the constraint as you wrote it.
Practice
Set each one up before opening the solution. Convention: ℒ = f − λ(g − c), so λ is the value of relaxing the constraint by one unit.
- 1.Maximise \( f(x, y) = xy \) subject to \( x + y = 10 \). Find \( x^*, y^* \) and \( \lambda \), then redo it with \( x + y = 11 \) and check that the change in the optimal value is close to \( \lambda \).
Solution
\[ y = \lambda, \qquad x = \lambda, \qquad x + y = 10 \] \[ \Longrightarrow\quad x^* = y^* = 5, \quad \lambda^* = 5, \quad f^* = 25 \]With \( x + y = 11 \): \( x^* = y^* = 5.5 \) and \( f^* = 30.25 \). The value rose by \( 5.25 \), close to \( \lambda = 5 \). The multiplier is a derivative, so it is exact only for an infinitesimal change; here \( V(c) = c^2/4 \) and \( V'(10) = 5 \) exactly.
- 2.Minimise \( x^2 + y^2 \) subject to \( x + 2y = 5 \). Interpret \( \lambda \).
Solution
\[ 2x = \lambda \] \[ 2y = 2\lambda \] \[ x + 2y = 5 \]So \( x = \lambda/2 \), \( y = \lambda \), and \( \lambda/2 + 2\lambda = 5 \) gives \( \lambda = 2 \).
\[ x^* = 1 \] \[ y^* = 2 \] \[ \lambda^* = 2 \] \[ f^* = 5 \]\( \lambda = 2 \) is how fast the minimum rises if the constant 5 is raised by one unit: the squared distance from the origin to the line \( x + 2y = c \) is \( c^2/5 \), whose derivative at \( c = 5 \) is \( 2 \).
- 3.A consumer has \( U(x, y) = \ln x + 2 \ln y \) and income \( m \) at prices \( p_x, p_y \). Find the demands and the expenditure shares.
Solution
\[ \frac{1}{x} = \lambda p_x \] \[ \frac{2}{y} = \lambda p_y \] \[ p_x x + p_y y = m \]From the first two, \( p_x x = 1/\lambda \) and \( p_y y = 2/\lambda \), so expenditure on \( y \) is twice expenditure on \( x \). The budget gives \( 3/\lambda = m \), so \( \lambda = 3/m \).
\[ x^* = \frac{m}{3p_x} \] \[ y^* = \frac{2m}{3p_y} \]Shares: one third on \( x \), two thirds on \( y \), whatever the prices. This is Cobb-Douglas in disguise: \( \ln x + 2\ln y = \ln(xy^2) \), a monotone transformation of \( x y^2 \), whose exponents \( 1 \) and \( 2 \) give shares \( 1/3 \) and \( 2/3 \).
- 4.Maximise \( U = x^{1/3} y^{2/3} \) subject to \( 4x + 2y = 60 \). Then raise income to 61 and check that utility rises by roughly \( \lambda \).
Solution
Tangency: \( \dfrac{MU_x}{MU_y} = \dfrac{y}{2x} = \dfrac{4}{2} \), so \( y = 4x \). Budget: \( 4x + 8x = 60 \).
\[ x^* = 5 \] \[ y^* = 20 \] \[ \lambda^* = \frac{MU_x}{p_x} = \frac{\tfrac13 (20/5)^{2/3}}{4} = \frac{2^{1/3}}{6} \approx 0.21 \]With income 61 the shares stay one third and two thirds: \( x = 61/12 \), \( y = 61/3 \), and \( U \) goes from \( 2000^{1/3} \approx 12.599 \) to about \( 12.809 \). The rise, \( 0.210 \), matches \( \lambda \) to three decimals.
- 5.A firm minimises \( wL + rK \) subject to \( \sqrt{LK} = q \). Find the conditional factor demands and show that \( \lambda \) is marginal cost.
Solution
\[ w = \lambda \frac{K}{2\sqrt{LK}} \] \[ r = \lambda \frac{L}{2\sqrt{LK}} \]Divide: \( w/r = K/L \), so \( K = (w/r)L \). The constraint \( \sqrt{L \cdot (w/r) L} = q \) gives \( L\sqrt{w/r} = q \).
\[ L^* = q\sqrt{\frac{r}{w}} \] \[ K^* = q\sqrt{\frac{w}{r}} \] \[ C(q) = wL^* + rK^* = 2q\sqrt{wr} \]Marginal cost is \( C'(q) = 2\sqrt{wr} \). From the first condition, \( \lambda = 2w\sqrt{LK}/K = 2w\sqrt{L/K} = 2w\sqrt{r/w} = 2\sqrt{wr} \). Same number: the multiplier on the output constraint is the marginal cost of output.
More practice
Twenty more problems in three levels, from numbers-only warm-ups to two constraints, Kuhn-Tucker and the convexity trap, all worked in full. All notes and practice sheets are on the resources page.
Found a mistake, or want another topic here? Email me.