01 / 21

Constrained
Optimization

Learn to find extreme values of multivariable functions subject to constraints using Lagrange multipliers.

Multivariable Calculus

What Is Constrained Optimization?

In many real-world problems, we want to maximize or minimize a function \( f(x, y) \) but we aren't free to choose any \( (x, y) \). We must satisfy a constraint \( g(x, y) = k \).

Objective
The function \( f(x,y) \) you want to optimize: maximize profit, minimize cost, etc.
Constraint
A condition \( g(x,y) = k \) that restricts your choices: a budget, a boundary, a fixed resource.

The Geometric Intuition

The constraint \( g(x,y) = k \) defines a curve in the \( xy \)-plane. The objective \( f(x,y) = c \) defines level curves. We seek the level curve of \( f \) that just touches the constraint curve: they are tangent.

tangent pt level curves of f constraint g(x,y) = k \( \nabla f \) \( \nabla g \)

Why Gradients Must Be Parallel

If \( \nabla f \) had any component along the constraint curve, you could move along the constraint to increase (or decrease) \( f \). At an extremum, the only way \( f \) stops changing along the constraint is if \( \nabla f \) is perpendicular to the constraint curve.

But \( \nabla g \) is also perpendicular to the constraint curve (gradients are normal to level curves). So at the extremum:

The Method of Lagrange Multipliers

To find extrema of \( f(x,y) \) subject to \( g(x,y) = k \), solve the system:

In component form for two variables:

1
\( f_x = \lambda \, g_x \)
2
\( f_y = \lambda \, g_y \)
3
\( g(x,y) = k \) (the constraint itself)

The Lagrangian Function

An equivalent (and elegant) way to state the method is to define the Lagrangian:

Then the necessary conditions are simply that all partial derivatives of \( \mathcal{L} \) vanish:

1
\( \dfrac{\partial \mathcal{L}}{\partial x} = f_x - \lambda g_x = 0 \)
2
\( \dfrac{\partial \mathcal{L}}{\partial y} = f_y - \lambda g_y = 0 \)
3
\( \dfrac{\partial \mathcal{L}}{\partial \lambda} = -(g(x,y) - k) = 0 \)

Unconstrained vs. Constrained

Unconstrained Constrained (Lagrange)
Condition \( \nabla f = \mathbf{0} \) \( \nabla f = \lambda \nabla g \)
Search domain All of \( \mathbb{R}^n \) The level set \( g = k \)
Unknowns \( n \) variables \( n + 1 \) (includes \( \lambda \))
Second-order test Hessian of \( f \) Bordered Hessian
Typical result Interior critical point Point on the constraint curve

Interpreting \( \lambda \): the Multiplier

The value \( \lambda \) is not just an algebraic trick. It has a powerful economic interpretation:

\( \lambda > 0 \)
Increasing \( k \) (loosening the constraint) increases the optimal \( f \).
\( \lambda < 0 \)
Increasing \( k \) decreases the optimal \( f \): the constraint "helps" at the current level.

Step-by-Step Method

1
Identify the objective \( f(x,y) \) and constraint \( g(x,y) = k \).
2
Compute gradients \( \nabla f \) and \( \nabla g \).
3
Set up the system \( \nabla f = \lambda \nabla g \) and \( g(x,y) = k \).
4
Solve the system for \( x, y, \lambda \). Often: divide equations to eliminate \( \lambda \), then substitute into the constraint.
5
Evaluate \( f \) at each candidate and compare values to identify the max and min.
6
Interpret \( \lambda \): how sensitive is the optimum to changes in the constraint?

Example 1: Rectangle on a Circle

Problem: Maximize \( f(x,y) = xy \) subject to \( g(x,y) = x^2 + y^2 = 1 \).

\( (\tfrac{1}{\sqrt{2}}, \tfrac{1}{\sqrt{2}}) \) x y \( x^2 + y^2 = 1 \)

Example 1: Solution

1
From \( y = 2\lambda x \) and \( x = 2\lambda y \), divide: \( \dfrac{y}{x} = \dfrac{2\lambda x}{2\lambda y} \implies y^2 = x^2 \implies y = \pm x \).
2
Substitute into constraint: \( x^2 + x^2 = 1 \implies x = \pm \dfrac{1}{\sqrt{2}} \).
3
Candidates: \( \left(\tfrac{1}{\sqrt{2}}, \tfrac{1}{\sqrt{2}}\right) \), \( \left(-\tfrac{1}{\sqrt{2}}, -\tfrac{1}{\sqrt{2}}\right) \), \( \left(\tfrac{1}{\sqrt{2}}, -\tfrac{1}{\sqrt{2}}\right) \), \( \left(-\tfrac{1}{\sqrt{2}}, \tfrac{1}{\sqrt{2}}\right) \).
4
Evaluate: \( f = \tfrac{1}{2} \) at the first two, \( f = -\tfrac{1}{2} \) at the last two.

Example 2: Cost Minimization

Problem: Minimize \( f(x,y) = x^2 + 2y^2 \) subject to \( g(x,y) = x + y = 3 \).

(2, 1) x y \( x + y = 3 \) level curves of f

Example 2: Solution

1
From equations 1 and 2: \( 2x = \lambda \) and \( 4y = \lambda \), so \( 2x = 4y \implies x = 2y \).
2
Substitute into constraint: \( 2y + y = 3 \implies y = 1 \), \( x = 2 \).
3
Evaluate: \( f(2, 1) = 4 + 2 = 6 \). Also: \( \lambda = 2(2) = 4 \).

Example 3: Three Variables

Problem: Find the point on the plane \( x + 2y + 3z = 6 \) closest to the origin. Equivalently, minimize \( f = x^2 + y^2 + z^2 \) subject to \( g = x + 2y + 3z = 6 \).

1
\( \nabla f = \langle 2x, 2y, 2z \rangle \), \( \nabla g = \langle 1, 2, 3 \rangle \).
2
System: \( 2x = \lambda \), \( 2y = 2\lambda \), \( 2z = 3\lambda \). So \( x = \tfrac{\lambda}{2} \), \( y = \lambda \), \( z = \tfrac{3\lambda}{2} \).
3
Constraint: \( \tfrac{\lambda}{2} + 2\lambda + \tfrac{9\lambda}{2} = 6 \implies 7\lambda = 6 \implies \lambda = \tfrac{6}{7} \).
4
Solution: The point is \( \left(\tfrac{3}{7}, \tfrac{6}{7}, \tfrac{9}{7}\right) \). The distance is \( \sqrt{f} = \sqrt{\tfrac{126}{49}} = \tfrac{3\sqrt{14}}{7} \).

Common Mistakes

✕ Forgetting the Constraint
Setting \( \nabla f = \mathbf{0} \) instead of \( \nabla f = \lambda \nabla g \). The unconstrained critical point is usually not on the constraint.
✕ Dropping Solutions
Dividing by a variable that could be zero. Always check the case where \( x = 0 \) or \( y = 0 \) separately.
✕ Not Comparing Values
Finding one candidate and assuming it's the answer. You must evaluate \( f \) at all candidates and compare to determine max vs. min.

Summary and Quick Reference

Concept Key Formula / Idea
Lagrange Condition \( \nabla f = \lambda \nabla g \)
Lagrangian \( \mathcal{L} = f - \lambda(g - k) \)
Number of Equations \( n + 1 \) (for \( n \) variables, 1 constraint)
Meaning of \( \lambda \) Sensitivity: \( \Delta f^* \approx \lambda \Delta k \)
Max or Min? Compare \( f \) at all candidates
Multiple Constraints \( \nabla f = \lambda_1 \nabla g_1 + \lambda_2 \nabla g_2 + \cdots \)

Question 1 of 5

To find extrema of \( f(x,y) \) subject to \( g(x,y) = k \) using Lagrange multipliers, which condition must hold at the optimum?

Question 2 of 5

Maximize \( f(x,y) = 3x + 4y \) subject to \( x^2 + y^2 = 1 \). What is the maximum value?

Question 3 of 5

If the Lagrange multiplier is \( \lambda = 4 \) and the constraint \( g(x,y) = k \) is changed from \( k = 10 \) to \( k = 10.5 \), approximately how much does the optimal value of \( f \) change?

Question 4 of 5

When minimizing \( f(x,y) = x^2 + y^2 \) subject to \( x + y = 4 \), what are the values of \( x \) and \( y \) at the minimum?

Question 5 of 5

The Lagrangian for optimizing \( f(x,y) \) subject to \( g(x,y) = k \) is defined as: