Lagrange multipliers
Optimize with a constraint: ∇f = λ∇g.
To find the max or min of f(x, y) subject to a constraint g(x, y) = c, solve ∇f = λ∇g together with the constraint. At the best point the level curve of f just touches the constraint curve, so their gradients are parallel.
Example: Maximize f = xy subject to x + y = 10
- ⟨y, x⟩ = λ⟨1, 1⟩ — So x = y
- x + y = 10 gives x = y = 5
- f = 25 — Maximum
Why it works: At the best point on the constraint, the function’s level curve just touches the constraint, so their gradients point the same way.
Tip: Check every solution of the system; compare their f-values to pick the max and min.