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
Why it works
Worked examples
Worked example: Highest point on an ellipse
- $\nabla f = \langle 0, 0, 1 \rangle$, $\nabla g = \langle 2x, 2y, 0 \rangle$, $\nabla h = \langle 1, 1, 1 \rangle$.
- 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$.
- With $x^2 + y^2 = 1$: $x = y = \pm\frac{1}{\sqrt{2}}$, and $z = 2 - x - y = 2 \mp \sqrt{2}$.
- 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
- ${}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}$.
- First constraint: $\frac{3\lambda}{2} = 3$, so $\lambda = 2$. Second: $x - y = \mu = 1$.
- 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