MATH 250 · Mathematics for Economics II

Constrained Optimization and Lagrange Multipliers

Choose the best basket you can afford with a budget line, and learn what the multiplier says about an extra dollar.

Key takeaways

  • A constrained optimization problem maximizes (or minimizes) an objective while obeying a limit such as a budget.
  • At the best point, the budget line just touches the highest reachable level curve, so their slopes match.
  • The Lagrangian combines the objective and the constraint with a multiplier λ, and the first-order conditions give the answer.
  • The multiplier λ measures how much the best value rises if the limit is loosened by one unit.
  • Equal "bang per buck" across goods is the economic meaning of the solution.

Dara has $12 in her pocket, and the cafe sells cupcakes at $2 and coffees at $3. She would love ten of each. She cannot have them. Her happiness depends on both goods, but her wallet draws a fence around what she can buy. The question is no longer "what is the best basket?" It is "what is the best basket I can afford?"

Almost every real choice is like this. A firm has a budget for inputs. A country has limited workers. A student has twenty-four hours. This lesson shows the standard method for such problems, named for Joseph-Louis Lagrange, an eighteenth-century mathematician who was born in Turin and worked in Berlin and Paris. It also reveals a bonus: a number that prices the fence itself.

The picture first

Recall Dara's happiness U = x × y from the first lesson, with x cupcakes and y coffees. The budget says 2x + 3y = 12. Solving for y gives y = 4 − (2/3)x, a straight line from 4 coffees (no cupcakes) to 6 cupcakes (no coffee).

Now lay the budget line over her level curves. Some curves lie far out and cost too much. Some lie nearby but are low, since she could do better. The best affordable basket is on the highest level curve that touches the line. At that point, the line just kisses the curve and does not cross it. Two curves that touch without crossing share the same slope there.

The best basket sits where the line kisses a level curve
Cups of coffee (y) 3 2 Budget: 2x + 3y = 12 U = 6 U = 12 (too costly) Best Cupcakes (x) Cups of coffee (y) 3 2 Budget: 2x + 3y = 12 U = 6 U = 12 (too costly) Best Cupcakes (x)

The U = 6 curve touches the budget line at (3, 2). The U = 12 curve never reaches it.

Check the picture with arithmetic. The basket (3, 2) costs 2 × 3 + 3 × 2 = 6 + 6 = $12, so it uses the whole budget. Its utility is 3 × 2 = 6. Another affordable basket, such as (2, 8/3) costing 4 + 8 = $12, has U = 2 × 2.667 = 5.33, lower. And (4, 4/3) costs 8 + 4 = $12 with U = 5.33, also lower. So (3, 2) beats its neighbors on the line.

The Lagrange method

Drawing works for two goods. Algebra works for any number. Here is the method, step by step.

Step 1. Write the constraint as "something equals zero": 12 − 2x − 3y = 0.

Step 2. Build the Lagrangian. It is the objective plus λ (the Greek letter lambda) times the constraint:

ℒ = x × y + λ × (12 − 2x − 3y)

Step 3. Treat λ as a third unknown and set all three partial derivatives to zero, as in unconstrained optimization:

ℒ_x = y − 2λ = 0       so y = 2λ
ℒ_y = x − 3λ = 0       so x = 3λ
ℒ_λ = 12 − 2x − 3y = 0   (the budget itself)

Step 4. Solve. Put x = 3λ and y = 2λ into the budget: 2 × 3λ + 3 × 2λ = 12λ = 12, so λ = 1. Then x = 3 and y = 2. This matches the picture. Utility is 6.

Why does this work? The third equation just restates the constraint, so any solution obeys it. The first two say that at the best point, the gradient of the objective is a multiple of the gradient of the constraint. In picture terms, the level curve and the budget line share a slope. The multiplier λ is the scaling factor between them.

The Lagrange recipe
1 Write the constraint as zero Move everything to one side: 12 − 2x − 3y = 0. 2 Build ℒ Objective plus λ times the constraint. 3 Differentiate Set ℒ_x, ℒ_y and ℒ_λ equal to zero. 4 Solve and check Find x, y and λ. Confirm the budget holds. Write the constraint as zero Move everything to one side: 12 − 2x − 3y = 0. 1 Build ℒ Objective plus λ times the constraint. 2 Differentiate Set ℒ_x, ℒ_y and ℒ_λ equal to zero. 3 Solve and check Find x, y and λ. Confirm the budget holds. 4

What the multiplier means

Here is the best part. The number λ = 1 is not a leftover. It tells you how much utility Dara gains from one more dollar. Test it: raise the budget from $12 to $13. The new problem has 12λ becoming 13, so λ = 13/12, x = 3λ = 3.25 and y = 2λ = 2.167. Utility is 3.25 × 2.167 = 7.04. The gain over the old 6 is 1.04, which is very close to λ = 1.

It is close, not exact, because λ is a rate for a tiny change, and a full dollar is not tiny. In general utility at budget M is U = M²/24 (since x = M/4 and y = M/6, their product is M²/24), which gives dU/dM = M/12 = λ exactly. At M = 12 that is 1.

Economists call this the shadow price of the constraint: the value of loosening the fence by one unit. It is the most valuable output of the method. If a boss asks "should we pay $50 to raise the budget?", λ answers it: a dollar of budget is worth λ units of utility at the margin. We will see in the envelope theorem why this always works.

The Lagrangian
ℒ = x × y + λ × (12 − 2x − 3y) ℒ = Lagrangian The combined function to differentiate. x × y = Objective What we want to make large: utility. λ × (12 − 2x − 3y) = Multiplier times constraint Zero when the budget is spent exactly; λ is the shadow price. ℒ = x × y + λ × (12 − 2x − 3y) ℒ = Lagrangian The combined function to differentiate. x × y = Objective What we want to make large: utility. λ × (12 − 2x − 3y) = Multiplier times constraint Zero when the budget is spent exactly; λ is the shadow price.

The multiplier prices the constraint.

Bang per buck

Look at the first two conditions again. They say y = 2λ and x = 3λ. Divide each by its price: y ÷ 2 = λ and x ÷ 3 = λ. Now y is the marginal utility of cupcakes (the partial U_x = y) and x is the marginal utility of coffee (U_y = x). So the conditions read:

(marginal utility of cupcakes) ÷ (price of cupcakes) = λ
(marginal utility of coffee) ÷ (price of coffee) = λ

Both goods give the same extra happiness per dollar, and that common number is λ. If cupcakes gave more bang per buck than coffee, Dara would shift a dollar from coffee to cupcakes and gain. She stops shifting when the two ratios are equal. At (3, 2): y ÷ 2 = 1 and x ÷ 3 = 1. Both equal 1.

This idea is the heart of consumer theory. It also works for firms: a manager minimizing cost spends so that each input yields the same extra output per dollar.

A cross-check: substitute the constraint

You may ask why we need a new method at all. With two goods, you can simply use the budget to remove one variable. From 2x + 3y = 12, y = (12 − 2x) ÷ 3. Put that into U = xy:

U = x × (12 − 2x) ÷ 3 = (12x − 2x²) ÷ 3
dU/dx = (12 − 4x) ÷ 3 = 0   so x = 3

Then y = (12 − 6) ÷ 3 = 2. The same answer. The one-variable problem is easy, and for simple budgets this shortcut is perfectly good. The Lagrange method earns its keep in three situations. First, when the constraint is curved and cannot be solved neatly for one variable. Second, when there are many goods, because the algebra stays tidy. Third, whenever you want the shadow price, which substitution hides. Practicing on the simple case, where you can check the answer two ways, is how you learn to trust the machine for the hard cases.

Why the slopes must match

Let's see why the touching point is the answer, using the slope idea from the differentials lesson. Along a level curve, the slope is −U_x ÷ U_y. For Dara that is −y ÷ x. Along the budget line, the slope is −(price of x) ÷ (price of y) = −2 ÷ 3. Setting them equal:

y ÷ x = 2 ÷ 3     so   3y = 2x

Combine with the budget 2x + 3y = 12: since 3y = 2x, the budget becomes 2x + 2x = 12, so x = 3, then y = 2 × 3 ÷ 3 = 2. Same basket, third method.

Why would the slopes have to match? Suppose they did not. Say the level curve were steeper than the budget line at some affordable basket. Then Dara could trade along the budget line to a spot just above that level curve and be happier at no extra cost. Only when the slopes agree is there no such free improvement. The Lagrange conditions are this "no free improvement" statement in algebra.

The slope of the level curve has a name: the marginal rate of substitution (the amount of coffee Dara will swap for one cupcake). The slope of the budget line is the market's rate of exchange. A consumer is at her best when her personal rate equals the market's rate. At (3, 2), her rate is 2 ÷ 3 of a coffee per cupcake, and the market swaps a $2 cupcake for 2 ÷ 3 of a $3 coffee. They agree.

Does the solution give a maximum?

The first-order conditions give a candidate, and as with any optimization, you must make sure it is a maximum and not something else. For this lesson, the picture does the work: the level curves of U = xy bow toward the corner, so the region above any curve is "rounded," and the budget line touches the highest curve once. The substitution check settles it too: U = (12x − 2x²) ÷ 3 has a negative second derivative, −4 ÷ 3, so x = 3 is a peak. Formal tests for larger problems use a determinant called the bordered Hessian, which belongs to a later course. Here, knowing the logic of curvature from the last lesson is enough.

A second example: the cheapest way to make output

Flip the problem. A shop must produce output KL = 16 (a made-up scale) with machines K at $8 each and labor L at $2 each. Minimize cost C = 8K + 2L subject to KL = 16. The Lagrangian:

ℒ = 8K + 2L + λ × (16 − K × L)
ℒ_K = 8 − λL = 0     so λ = 8 ÷ L
ℒ_L = 2 − λK = 0     so λ = 2 ÷ K
ℒ_λ = 16 − KL = 0

Equate the two expressions for λ: 8 ÷ L = 2 ÷ K, so 8K = 2L, so L = 4K. Then KL = 4K² = 16, so K = 2 and L = 8. Cost is 8 × 2 + 2 × 8 = 16 + 16 = $32. And λ = 8 ÷ 8 = 1. The multiplier is the marginal cost of output: to raise the output target by one unit would cost about $1 more at this scale. Check: for target Q the cheapest cost works out to 8√Q, and its slope at Q = 16 is 4 ÷ √16 = 1. It matches.

A common mistake

A frequent error is dropping the constraint equation. Students set ℒ_x = 0 and ℒ_y = 0, get a ratio such as y = (2/3)x, and stop. That tells you the right mix but not the right amount. The third condition, the budget, pins down the scale. You need all three.

Another is a sign slip with λ. If you write the constraint as 2x + 3y − 12 instead, the signs of λ flip, and your λ comes out as −1. The final x and y are the same, but the shadow price reads backwards. Pick one form and stay with it; with "limit minus use," a positive λ means that loosening the limit helps.

A third error is assuming the constraint always binds. If Dara could not spend all her money because the coffee shop closes, a different method is needed. That is the subject of inequality constraints and Kuhn-Tucker conditions.

Words to know

Constraint a limit on the choices, such as a budget.

Lagrangian the objective plus the multiplier times the constraint, differentiated to solve the problem.

Lagrange multiplier the number λ that measures how much the best value rises when the limit is loosened by one unit.

Shadow price another name for the multiplier, the implied price of the constraint.

Budget line all the baskets that cost exactly the budget.

Marginal utility per dollar extra happiness from one more dollar spent on a good, which the best basket equalizes across goods.

Check yourself

  1. Dara's budget is 2x + 3y = 12 and U = xy. What basket does the Lagrange method give?
  2. At the best basket, what is λ and what does it mean?
  3. If cupcakes rose to $3 each (budget 3x + 3y = 12), use the same method to find the best basket.
  4. Compute the marginal utility per dollar of each good at (3, 2) with prices $2 and $3.
  5. Why is solving only ℒ_x = 0 and ℒ_y = 0 not enough?
  6. In the cost problem, why must the best mix satisfy L = 4K?
Show the answers
  1. x = 3 cupcakes and y = 2 coffees, with U = 6 and total spending 6 + 6 = $12.
  2. λ = 1; it means one extra budget dollar raises utility by about 1 unit.
  3. ℒ_x = y − 3λ = 0 and ℒ_y = x − 3λ = 0, so x = y = 3λ; the budget gives 3 × 3λ + 3 × 3λ = 18λ = 12, so λ = 2/3 and x = y = 2, with U = 4.
  4. Cupcakes: y ÷ 2 = 2 ÷ 2 = 1; coffee: x ÷ 3 = 3 ÷ 3 = 1; both equal 1.
  5. Those two conditions give only the ratio of the goods; the budget equation fixes the actual amounts.
  6. Setting the two expressions for λ equal gives 8 ÷ L = 2 ÷ K, so 8K = 2L and L = 4K.

A free self-study program written for 4Economics with AI writing tools and not reviewed line by line by a person. It is not an accredited degree and awards no credit. Check anything you rely on against a textbook or primary source. Report an error.

In this unit: Optimization

  1. Unconstrained Optimization With Several VariablesFind the best mix of two or more choices by setting every partial derivative to zero, then reading the shape of the hill.11 min
  2. Second-Order Conditions, Concavity and ConvexitySort peaks from valleys and saddles with a short test on the second partial derivatives, and learn when a flat spot is a global best.11 min
  3. Constrained Optimization and Lagrange MultipliersChoose the best basket you can afford with a budget line, and learn what the multiplier says about an extra dollar.10 min
  4. Inequality Constraints and Kuhn-Tucker ConditionsHandle limits that may or may not bite, such as "spend at most this much" or "buy no less than zero", with complementary slackness.11 min
  5. The Envelope TheoremWhen you choose the best option, a small change in the setting moves your best payoff by just the direct effect.12 min

In the news