Calculus 3Optimization

Lagrange Multipliers with Two Constraints

∇f = λ∇g + μ∇h.

Not started Jump to practice

Two constraints in space, $g(x, y, z) = k_1$ and $h(x, y, z) = k_2$, are two surfaces; together they usually cut out a curve, like the ellipse where a plane slices a cylinder. Optimizing on that curve extends Lagrange multipliers with a second multiplier.

Key idea

At a maximum or minimum of $f$ on the curve where $g = k_1$ and $h = k_2$ (with $\nabla g$, $\nabla h$ not parallel): $$\nabla f = \lambda\nabla g + \mu\nabla h, \qquad g = k_1, \qquad h = k_2.$$ That is five equations in $x$, $y$, $z$, $\lambda$, $\mu$. Evaluate $f$ at every solution.

Why it works

Let $\mathbf{T}$ be the tangent direction of the curve at the extreme point. As before, $\nabla f \cdot \mathbf{T} = 0$. The curve lies in both surfaces, so $\mathbf{T}$ is perpendicular to $\nabla g$ and to $\nabla h$. The vectors perpendicular to $\mathbf{T}$ form a plane, and $\nabla g$ and $\nabla h$ span it (they are not parallel). So $\nabla f$, which also lies in that plane, is a combination $\lambda\nabla g + \mu\nabla h$.
The ellipse where the cylinder $x^2 + y^2 = 1$ meets the plane $x + y + z = 2$. Move the point: the height $z$ is largest at $t = \frac{5\pi}{4}$ (about ${}3.93$), where the tangent is horizontal.

Worked examples

Worked example: Highest point on an ellipse

Find the extremes of $f = z$ on the curve $x^2 + y^2 = 1$, $x + y + z = 2$.
  1. $\nabla f = \langle 0, 0, 1 \rangle$, $\nabla g = \langle 2x, 2y, 0 \rangle$, $\nabla h = \langle 1, 1, 1 \rangle$.
  2. Components: ${}0 = 2\lambda x + \mu$, ${}0 = 2\lambda y + \mu$, ${}1 = \mu$. So ${}2\lambda x = 2\lambda y = -1$, which forces $x = y$.
  3. With $x^2 + y^2 = 1$: $x = y = \pm\frac{1}{\sqrt{2}}$, and $z = 2 - x - y = 2 \mp \sqrt{2}$.
  4. Maximum ${}2 + \sqrt{2}$ at $\left(-\frac{1}{\sqrt{2}}, -\frac{1}{\sqrt{2}}, 2 + \sqrt{2}\right)$; minimum ${}2 - \sqrt{2}$.

Answer: maximum ${}2 + \sqrt{2}$, minimum ${}2 - \sqrt{2}$

Worked example: Closest point of a line

Minimize $x^2 + y^2 + z^2$ subject to $x + y + z = 3$ and $x - y = 1$.
  1. ${}2\langle x, y, z \rangle = \lambda\langle 1, 1, 1 \rangle + \mu\langle 1, -1, 0 \rangle$: $x = \frac{\lambda + \mu}{2}$, $y = \frac{\lambda - \mu}{2}$, $z = \frac{\lambda}{2}$.
  2. First constraint: $\frac{3\lambda}{2} = 3$, so $\lambda = 2$. Second: $x - y = \mu = 1$.
  3. Point $\left(\frac{3}{2}, \frac{1}{2}, 1\right)$; the minimum is $\frac{9}{4} + \frac{1}{4} + 1 = \frac{7}{2}$.

Answer: $\frac{7}{2}$

Sometimes a constraint can simply be solved for one variable. In the first example, $z = 2 - x - y$ turns the problem into one constraint in the plane. Both routes give the same answer; Lagrange's method is the one that always works, even when solving is messy.

Common mistake

Using only one multiplier. Writing $\nabla f = \lambda\nabla g$ and ignoring $h$ finds extremes on the whole surface $g = k_1$, not on the curve. Each constraint brings its own multiplier and its own equation. Count: unknowns $x, y, z, \lambda, \mu$ (five) must match equations (three gradient components plus two constraints).

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 3 XP.

Loading practice…

Builds on

Leads to

This is one of the top rungs of Calculus 3: Multivariable Calculus.

Sources and further reading

  • OpenStax Calculus Volume 3, 4.8 Lagrange Multipliers
@teddyrookbook GitHub