Lagrange multipliers with one equality constraint

The idea

To optimize f(x, y) while staying on a curve g(x, y) = c, look for the point where a level curve of f just touches the constraint curve. There the two curves are tangent, so their gradients are parallel. The scaling factor between the gradients is the Lagrange multiplier \lambda, and it has a meaning: it is the rate at which the best value changes when c changes, the shadow price of the constraint.

The math, with a comment on each formula

\nabla f(x, y) = \lambda\, \nabla g(x, y), \qquad g(x, y) = c In words: the gradients are parallel at the optimum, and the point lies on the constraint: three equations for x, y and \lambda.

L(x, y, \lambda) = f(x, y) - \lambda\,\bigl(g(x, y) - c\bigr), \qquad \nabla L = 0 In words: the Lagrangian packs both conditions into one function; setting its three partial derivatives to zero gives the same equations.

\lambda = \frac{d f^*}{d c} In words: the multiplier is the extra optimal value per extra unit of the constraint’s right-hand side.

Worked example

A rectangular garden has sides x and y metres and p metres of fence: maximize the area A = xy subject to 2x + 2y = p. The Lagrangian is L = xy - \lambda(2x + 2y - p), and \nabla L = 0 gives x = \frac{p}{4}, \qquad y = \frac{p}{4}, \qquad \lambda = \frac{p}{8}, \qquad A^* = \frac{p^{2}}{16}. In words: the best rectangle is a square. With p = 40 m of fence: x = y = 10 m, area 100 m^2, and \lambda = 5 m^2 per metre. The shadow-price reading checks out: dA^*/dp = \frac{p}{8}, which at p = 40 is 5, the same as \lambda; one more metre of fence adds \frac{81}{16} m^2 (about 5.06), close to \lambda because the step is small.

The same with the kernel, on a convex problem so that its answer is certified: minimize x^2 + y^2 subject to x + 2y = 5.

minimize x^2 + y^2
subject to
x + 2*y = 5

By hand (SymPy): x = 1, y = 2, \lambda = 2. The kernel: x = 1, y = 2, multiplier 2, status optimal.

Why it matters for optimization

Every multiplier ProvenDecisions reports, a shadow price in a linear program or a KKT multiplier in a smooth problem, is this \lambda: what one more unit of a limit is worth. The garden problem, \max xy, is not convex, so the app would label its answer locally optimal; the second problem is convex, so its Lagrange point is the certified global optimum.