Lagrange in three variables, and the step to KKT

The idea

With two equality constraints in three variables, the gradient of the objective at the optimum is a combination of the two constraint gradients, with one multiplier each. Replace an equality by an inequality and one more idea is needed: a constraint that is not touching (slack) has multiplier zero, and a touching one has a multiplier of a fixed sign. That is the Karush–Kuhn–Tucker (KKT) extension of Lagrange.

The math, with a comment on each formula

\nabla f = \lambda\,\nabla g_1 + \mu\,\nabla g_2, \qquad g_1 = c_1,\quad g_2 = c_2 In words: five equations for x, y, z, \lambda, \mu; each multiplier is the shadow price of its constraint.

\begin{align*} &\min f \text{ subject to } g \ge c:\\ &\nabla f = \mu\,\nabla g,\qquad \mu \ge 0,\qquad \mu\,(g - c) = 0 \end{align*} In words: the same balance, plus two rules: the multiplier of a “\ge” limit in a minimization is not negative, and it can be nonzero only when the limit is tight (complementary slackness).

Worked example

Minimize x^2 + y^2 + z^2 subject to x + y + z = 6 and x - z = 2. Setting the five partial derivatives of L = x^2 + y^2 + z^2 - \lambda(x + y + z - 6) - \mu(x - z - 2) to zero gives (x, y, z) = (3, 2, 1), \qquad \lambda = 4, \qquad \mu = 2, with value 14. The kernel agrees, multipliers included:

minimize x^2 + y^2 + z^2
subject to
x + y + z = 6
x - z = 2

(3, 2, 1), multipliers 4 and 2.

Now make the second constraint an inequality. Without it the best point is (2, 2, 2), where x - z = 0.

Why it matters for optimization

These are the KKT conditions that ProvenDecisions checks to certify a smooth answer: stationarity, feasibility, multiplier signs and complementary slackness. For a convex problem like this one, a point that passes them is the global optimum. The full checklist, with more examples, is in the KKT conditions tutorial in Learn (Optimality conditions).