01 / 21

Lagrange
Multipliers

Master constrained optimization by learning how gradients reveal extrema along curves and surfaces.

Calculus 3

What Is Constrained Optimization?

In many real problems we want to maximize or minimize a function \( f(x, y) \) but we are not free to choose any point in the plane. Instead, we must stay on a curve defined by a constraint \( g(x, y) = k \).

Objective
The function \( f \) you want to optimize: maximize or minimize.
Constraint
The equation \( g(x,y)=k \) that restricts which points are allowed.

The Geometric Idea

Level curves of \( f \) are curves where \( f \) is constant. The constraint \( g(x,y)=k \) is another curve. An extremum of \( f \) on the constraint occurs where a level curve of \( f \) is tangent to the constraint curve.

\(\nabla f\) \(\nabla g\) tangent point \(g = k\) \(f = c\)

Why Gradients Must Be Parallel

If \(\nabla f\) had a component along the constraint curve, you could still increase \( f \) by moving in that direction while staying on the constraint. At an extremum, any such tangential component must vanish.

1
\(\nabla g\) is perpendicular to the constraint curve \( g = k \) at every point.
2
At an extremum on the constraint, \(\nabla f\) must also be perpendicular to the curve (no tangential component).
3
Both gradients perpendicular to the same curve means \(\nabla f = \lambda\,\nabla g\) for some scalar \(\lambda\).

The Lagrange Condition

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

In component form for two variables, this gives three equations in three unknowns \((x, y, \lambda)\):

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

Extension to Three Variables

For \( f(x,y,z) \) subject to \( g(x,y,z) = k \), the same principle gives four equations in four unknowns \((x,y,z,\lambda)\):

For two constraints \( g = k \) and \( h = c \), introduce a second multiplier \(\mu\):

Unconstrained vs Constrained

Unconstrained Constrained (Lagrange)
Condition \(\nabla f = \vec{0}\) \(\nabla f = \lambda\,\nabla g\)
Variables \(x, y\) only \(x, y, \lambda\)
Tests Second derivative test Bordered Hessian or evaluate candidates
Domain All of \(\mathbb{R}^n\) Only points on \(g = k\)
Typical result Interior critical points Boundary extrema on constraint

How to Apply the Method

1
Identify the objective \( f \) and constraint \( g(x,y) = k \).
2
Compute partial derivatives: \( f_x, f_y, g_x, g_y \).
3
Set up the system: \( f_x = \lambda g_x \), \( f_y = \lambda g_y \), \( g = k \).
4
Solve for \( x, y, \lambda \). Often eliminate \(\lambda\) first.
5
Evaluate \( f \) at all candidate points to determine max and min.

Example 1: Circle Constraint

Find the extrema of \( f(x,y) = x + y \) subject to \( x^2 + y^2 = 1 \).

1
Partials: \( f_x = 1,\; f_y = 1,\; g_x = 2x,\; g_y = 2y \).
2
System: \( 1 = 2\lambda x \), \( 1 = 2\lambda y \), \( x^2+y^2 = 1 \).
3
From equations 1 and 2: \( 2\lambda x = 2\lambda y \;\Rightarrow\; x = y \). (Note: \(\lambda \neq 0\), otherwise the first equation becomes \(1=0\), which is impossible).
4
Substitute: \( 2x^2 = 1 \;\Rightarrow\; x = \pm\tfrac{1}{\sqrt{2}} \).

Example 1: Visualized

x y Max Min \(x^2+y^2=1\) \(x+y=c\)

Example 2: Ellipse Constraint

Find the extrema of \( f(x,y) = xy \) subject to \( \tfrac{x^2}{4} + y^2 = 1 \).

1
Partials: \( f_x = y,\; f_y = x,\; g_x = \tfrac{x}{2},\; g_y = 2y \).
2
System: \( y = \tfrac{\lambda x}{2} \), \( x = 2\lambda y \), \( \tfrac{x^2}{4}+y^2=1 \).
3
Solve for \(\lambda\): Substitute \(y\) from eq. 1 into eq. 2: \( x = 2\lambda (\tfrac{\lambda x}{2}) = \lambda^2 x \). This implies \( x(1-\lambda^2) = 0 \).
4
Cases: If \(x=0\), constraint gives \(y=\pm 1\), so \(f=0\). If \(\lambda = \pm 1\), then \(x^2=4y^2\). Constraint gives \(2y^2=1\), so \(y=\pm\tfrac{1}{\sqrt{2}}\) and \(x=\pm\sqrt{2}\).

Example 3: Three Variables

Find the minimum of \( f(x,y,z) = x^2 + y^2 + z^2 \) subject to \( x + y + z = 3 \).

1
System: \( 2x = \lambda \), \( 2y = \lambda \), \( 2z = \lambda \), \( x+y+z=3 \).
2
Immediate result: \( x = y = z \) from the first three equations.
3
Substitute: \( 3x = 3 \;\Rightarrow\; x = y = z = 1 \), \(\lambda = 2\).

What Does \(\lambda\) Mean?

The multiplier \(\lambda\) has a powerful interpretation: it measures the sensitivity of the optimal value of \(f\) to changes in the constraint constant \(k\).

\(\lambda > 0\)
Increasing \(k\) increases the optimal \(f\). The constraint is "helping."
\(\lambda < 0\)
Increasing \(k\) decreases the optimal \(f\). The constraint is "hurting."
\(\lambda = 0\)
The constraint passes through an unconstrained critical point. Locally irrelevant.

The Lagrangian Function

We can package the entire method into a single function called the Lagrangian:

Setting all partial derivatives of \(\mathcal{L}\) to zero recovers exactly the Lagrange conditions:

1
\(\mathcal{L}_x = f_x - \lambda g_x = 0\) gives \(f_x = \lambda g_x\).
2
\(\mathcal{L}_y = f_y - \lambda g_y = 0\) gives \(f_y = \lambda g_y\).
3
\(\mathcal{L}_\lambda = -(g(x,y) - k) = 0\) gives \(g(x,y) = k\).

Common Mistakes

✕ Forgetting the Constraint
Solving \(f_x = \lambda g_x\) and \(f_y = \lambda g_y\) but never substituting back into \(g(x,y) = k\).
✕ Dividing by Zero
Dividing equations to eliminate \(\lambda\) without checking if the denominator could be zero. Always handle that case separately.
✕ Assuming \(\lambda > 0\)
\(\lambda\) can be negative or zero. Never discard solutions because \(\lambda\) is not positive.
✕ Not Classifying Extrema
Finding candidate points but failing to evaluate \(f\) at all of them to determine which is max and which is min.

Summary Table

Aspect Detail
Core equation \(\nabla f = \lambda\,\nabla g\)
Geometric meaning Gradients are parallel at extremum
Variables solved \(n\) coordinates + one \(\lambda\) per constraint
\(\lambda\) interpretation Rate of change of optimal \(f\) w.r.t. \(k\)
Lagrangian \(\mathcal{L} = f - \lambda(g - k)\)
Classify extrema Evaluate \(f\) at all candidates

Question 1 of 5

The Lagrange condition \(\nabla f = \lambda\,\nabla g\) geometrically means:

Question 2 of 5

To optimize \( f(x,y) \) subject to \( g(x,y) = k \), how many equations does the Lagrange system produce?

Question 3 of 5

Find the maximum of \( f(x,y) = x + y \) on the circle \( x^2 + y^2 = 1 \).

Question 4 of 5

Find the minimum of \( f(x,y,z) = x^2 + y^2 + z^2 \) subject to \( x + y + z = 3 \).

Question 5 of 5

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