To optimize f(x, y) subject to g(x, y) = 0, solve ∇f = λ∇g along with the constraint. The Lagrange multiplier λ represents the sensitivity of the optimum to relaxing the constraint.
Recall from single-variable calculus that finding the maximum of a function on a closed interval requires checking critical points (where f′ = 0) and boundary points separately. In multivariable calculus, optimizing f(x, y) subject to a constraint g(x, y) = 0 is the analog of that boundary problem: you want the best value of f, but only among points that satisfy the constraint curve.
The key geometric insight is this: at a constrained optimum, the constraint curve g = 0 must be tangent to a level curve of f. If the two curves crossed instead of touching, you could slide along the constraint to reach a higher (or lower) value of f — contradicting optimality. Because gradient vectors are always perpendicular to their level curves, tangency of the curves means the gradients must be parallel. Parallel vectors are scalar multiples of each other, so there exists some λ such that ∇f = λ∇g. That scalar λ is the Lagrange multiplier.
In practice, you solve the system: ∂f/∂x = λ·∂g/∂x, ∂f/∂y = λ·∂g/∂y, and g(x, y) = 0. That is three equations in three unknowns (x, y, λ). The solutions are constrained critical point candidates. You then evaluate f at each candidate to determine which is the maximum and which is the minimum (or compare to boundary behavior if the constraint is bounded).
The Lagrange multiplier λ has an important economic interpretation: it measures the rate of change of the optimal value of f with respect to a small relaxation of the constraint. If you are maximizing profit subject to a budget constraint, λ tells you how much additional profit you would gain per additional dollar of budget. This is why λ is often called the "shadow price" in optimization and economics.
One common error is forgetting to also solve the constraint equation g(x, y) = 0. The condition ∇f = λ∇g alone is not enough — it identifies the direction of the optimum but not where on the constraint it lies. All three equations must be solved simultaneously. Another pitfall: the method finds critical points, not guaranteed optima; always check whether you have found a maximum, a minimum, or a saddle point relative to the constraint.