Lagrange Multipliers

A farmer has exactly 200 meters of fencing. She wants to enclose the largest possible rectangular field. This is not an unconstrained optimization problem. The farmer cannot simply make both sides infinite. She must maximize area subject to a fixed perimeter. This simple restriction changes the entire character of the problem. Ordinary calculus locates extrema by setting a gradient to zero. But that method assumes every direction of movement is available. When a constraint carves out a curve or surface, only motions along that constraint are legal. The naive gradient condition no longer applies. The method of Lagrange multipliers repairs this by asking a sharper geometric question. At an extreme point of a constrained problem, how must the objective function's gradient relate to the constraint's gradient? The answer is that the two gradients must be parallel. This converts a constrained problem into an unconstrained system of equations. The cost is introducing one new auxiliary variable per constraint. This trade is remarkably efficient. It is one of the most-used computational tools in all of applied mathematics. The idea reaches far beyond fencing. Economists use it to characterize utility-maximizing consumption under a budget constraint. Physicists use it to derive equations of motion for constrained mechanical systems. Statisticians use it to derive maximum-entropy distributions. Engineers use it in optimal design under resource limits. The multiplier itself is not a mere bookkeeping device. It has an interpretation as a shadow price. It measures the sensitivity of the optimal value to a relaxation of the constraint. This article builds the method from the ground up. It gives a precise definition of constrained critical points. It offers a full geometric and analytic proof of the multiplier theorem. Careful attention is paid to the regularity hypothesis that makes it work. The article extends the method to multiple simultaneous constraints. It includes worked examples with genuinely asymmetric data. It also gives a counterexample showing exactly what fails when the key hypothesis is dropped. The technique here is also a first step toward the The Implicit Function Theorem. That theorem supplies the rigorous machinery for parametrizing constraint sets.

Key takeaways
  • Constrained extrema of ff subject to g=cg = c occur where ∇f\nabla f is parallel to ∇g\nabla g, provided ∇g≠0\nabla g \neq 0.
  • The proportionality constant λ\lambda (the multiplier) turns the constrained problem into solving ∇f=λ∇g\nabla f = \lambda \nabla g together with g=cg = c.
  • With kk constraints g1=c1,…,gk=ckg_1 = c_1, \dots, g_k = c_k, the condition becomes ∇f=λ1∇g1+⋯+λk∇gk\nabla f = \lambda_1 \nabla g_1 + \cdots + \lambda_k \nabla g_k.
  • The proof rests on parametrizing the constraint curve/surface near the extremum and applying single-variable calculus to the composite function.
  • Lagrange multipliers find candidates only — a second step (boundary analysis, comparison of values, or second-order tests) is needed to classify them.
  • Key idea: at a constrained extremum, the objective's gradient has no component tangent to the constraint set, so it must lie entirely along the constraint's normal direction.

Where this lives today

In economics, consumer theory maximizes a utility function U(x1,…,xn)U(x_1,\dots,x_n) subject to a budget constraint ∑pixi=I\sum p_i x_i = I; the resulting multiplier λ\lambda is the marginal utility of income, and the ratios ∇U/λ\nabla U / \lambda recover the classical result that marginal-utility-per-dollar is equalized across goods at the optimum. In statistics, the derivation of the maximum-entropy distribution subject to known moment constraints (mean, variance) is a direct multiple-constraint Lagrange problem, yielding the exponential family of distributions including the Gaussian. In classical mechanics, Lagrange's own original motivation persists: constrained motion (a bead on a wire, a pendulum) is handled by introducing multipliers for the constraint forces, later generalized into the full Lagrangian and Hamiltonian formalisms of physics. In machine learning and optimization, the Karush–Kuhn–Tucker conditions extend Lagrange multipliers to inequality constraints, forming the backbone of support vector machines, convex programming, and duality theory. In computer graphics and engineering design, multiplier methods (often as "penalty" or "augmented Lagrangian" numerical schemes) enforce physical constraints — rigid rods, incompressibility, contact — in simulation. The geometric heart of the method, tangency of level sets, reappears whenever the The Implicit Function Theorem is used to locally straighten out a constraint manifold, which is the standard next step toward manifolds and constrained optimization in higher generality.

Ask the tutor: How does the bordered Hessian test decide whether a Lagrange candidate is a max, min, or saddle?

DefinitionConstrained extrema and the Lagrange condition

Let U⊆RnU \subseteq \mathbb{R}^n be open, and let f:U→Rf: U \to \mathbb{R} and g:U→Rg: U \to \mathbb{R} be C1C^1 functions. Fix c∈Rc \in \mathbb{R} and define the constraint set

S={x∈U:g(x)=c}.S = \{\mathbf{x} \in U : g(\mathbf{x}) = c\}.

A point x0∈S\mathbf{x}_0 \in S is a local constrained maximum (resp. minimum) of ff on SS if there is an open ball B(x0,r)⊆UB(\mathbf{x}_0, r) \subseteq U such that

f(x)≤f(x0)(resp. f(x)≥f(x0))for all x∈S∩B(x0,r).f(\mathbf{x}) \le f(\mathbf{x}_0) \quad \text{(resp. } f(\mathbf{x}) \ge f(\mathbf{x}_0)\text{)} \quad \text{for all } \mathbf{x} \in S \cap B(\mathbf{x}_0, r).

The point x0∈S\mathbf{x}_0 \in S is regular if ∇g(x0)≠0\nabla g(\mathbf{x}_0) \neq \mathbf{0}. A point x0∈S\mathbf{x}_0 \in S satisfies the Lagrange condition if it is regular and there exists a scalar λ∈R\lambda \in \mathbb{R}, called a Lagrange multiplier, with

∇f(x0)=λ ∇g(x0).\nabla f(\mathbf{x}_0) = \lambda \, \nabla g(\mathbf{x}_0).

More generally, for k<nk < n constraints g1(x)=c1,…,gk(x)=ckg_1(\mathbf{x}) = c_1, \dots, g_k(\mathbf{x}) = c_k, a point x0\mathbf{x}_0 in the common constraint set is regular if the gradients ∇g1(x0),…,∇gk(x0)\nabla g_1(\mathbf{x}_0), \dots, \nabla g_k(\mathbf{x}_0) are linearly independent, and the Lagrange condition becomes the existence of scalars λ1,…,λk\lambda_1, \dots, \lambda_k with

∇f(x0)=∑i=1kλi ∇gi(x0).\nabla f(\mathbf{x}_0) = \sum_{i=1}^{k} \lambda_i \, \nabla g_i(\mathbf{x}_0).

Intuition

Picture the constraint set S={g=c}S = \{g = c\} as a curve threading through the plane (for n=2n=2) and think of ff as elevation on a landscape. The level curves of ff — the sets {f=v}\{f = v\} — sweep across the plane as vv varies, like contour lines on a topographic map. As you walk along SS, the value ff takes changes continuously, rising and falling. At a point where f∣Sf|_S attains a local maximum, walking a little further in either direction along SS must decrease ff (or keep it the same to first order). This means SS must be tangent, at that point, to the level curve of ff through that point — if SS crossed the level curve transversally, values of ff on one side of the crossing would exceed f(x0)f(\mathbf{x}_0). Since ∇f\nabla f is always perpendicular to the level curves of ff, and ∇g\nabla g is always perpendicular to SS (because SS is itself a level curve of gg), tangency of the two curves at x0\mathbf{x}_0 forces their normal directions to agree — that is, ∇f(x0)\nabla f(\mathbf{x}_0) and ∇g(x0)\nabla g(\mathbf{x}_0) must be parallel. This is the entire geometric content of the theorem; the algebra of multipliers is just a convenient way of writing down "parallel vectors."

Figure
Level curves of ff tangent to the constraint curve g=cg=c at the extremum
g(x,y) = c f increasing x₀ ∇f(x₀) ∇g(x₀) = λ⁻¹∇f(x₀)

Theorem

TheoremLagrange Multiplier Theorem

Let U⊆RnU \subseteq \mathbb{R}^n be open and let f,g:U→Rf, g : U \to \mathbb{R} be C1C^1 functions. Let c∈Rc \in \mathbb{R} and let S={x∈U:g(x)=c}S = \{\mathbf{x} \in U : g(\mathbf{x}) = c\}. Suppose x0∈S\mathbf{x}_0 \in S is a local extremum (maximum or minimum) of ff restricted to SS, and suppose x0\mathbf{x}_0 is regular, meaning ∇g(x0)≠0\nabla g(\mathbf{x}_0) \neq \mathbf{0}. Then there exists λ∈R\lambda \in \mathbb{R} such that

∇f(x0)=λ ∇g(x0).\nabla f(\mathbf{x}_0) = \lambda \, \nabla g(\mathbf{x}_0).
LemmaTangent vectors to a regular level set lie in the kernel of the gradient

Let g:U→Rg: U \to \mathbb{R} be C1C^1 on open U⊆RnU \subseteq \mathbb{R}^n, let S={g=c}S = \{g = c\}, and let x0∈S\mathbf{x}_0 \in S be regular. If γ:(−ε,ε)→S\boldsymbol{\gamma} : (-\varepsilon, \varepsilon) \to S is differentiable with γ(0)=x0\boldsymbol{\gamma}(0) = \mathbf{x}_0, then

∇g(x0)⋅γ′(0)=0.\nabla g(\mathbf{x}_0) \cdot \boldsymbol{\gamma}'(0) = 0.
Proof

Define h(t)=g(γ(t))h(t) = g(\boldsymbol{\gamma}(t)) for t∈(−ε,ε)t \in (-\varepsilon, \varepsilon). Since γ(t)∈S\boldsymbol{\gamma}(t) \in S for all tt, we have h(t)=ch(t) = c identically, so h′(t)=0h'(t) = 0 for all tt in particular at t=0t=0. By the multivariable chain rule (a direct consequence of differentiability of gg, assumed known from The Gradient and Directional Derivatives),

h′(0)=∇g(γ(0))⋅γ′(0)=∇g(x0)⋅γ′(0).h'(0) = \nabla g(\boldsymbol{\gamma}(0)) \cdot \boldsymbol{\gamma}'(0) = \nabla g(\mathbf{x}_0) \cdot \boldsymbol{\gamma}'(0).

Since h′(0)=0h'(0) = 0, the claim follows. ■\blacksquare

∎

Now we prove the main theorem, using the Implicit Function Theorem to produce an explicit local parametrization of SS near the regular point x0\mathbf{x}_0 — this is the standard route and foreshadows the deeper role that theorem plays throughout analysis.

Proof

Setup. Since ∇g(x0)≠0\nabla g(\mathbf{x}_0) \ne \mathbf{0}, some partial derivative is nonzero; after relabeling coordinates, assume ∂g/∂xn(x0)≠0\partial g/\partial x_n(\mathbf{x}_0) \neq 0. Write x=(y,xn)\mathbf{x} = (\mathbf{y}, x_n) with y=(x1,…,xn−1)\mathbf{y} = (x_1,\dots,x_{n-1}), and write x0=(y0,t0)\mathbf{x}_0 = (\mathbf{y}_0, t_0).

Step 1: Parametrize SS near x0\mathbf{x}_0. The Implicit Function Theorem (whose statement we invoke here as a known analytic tool, and whose proof this very construction motivates) guarantees: since gg is C1C^1, g(y0,t0)=cg(\mathbf{y}_0, t_0) = c, and ∂g/∂xn(x0)≠0\partial g/\partial x_n(\mathbf{x}_0) \neq 0, there exist an open neighborhood VV of y0\mathbf{y}_0 in Rn−1\mathbb{R}^{n-1}, an open interval II around t0t_0, and a C1C^1 function φ:V→I\varphi: V \to I with φ(y0)=t0\varphi(\mathbf{y}_0) = t_0, such that for (y,xn)∈V×I(\mathbf{y}, x_n) \in V \times I,

g(y,xn)=c  ⟺  xn=φ(y).g(\mathbf{y}, x_n) = c \iff x_n = \varphi(\mathbf{y}).

Thus near x0\mathbf{x}_0, the constraint set SS is exactly the graph of φ\varphi: define

γ(y)=(y,φ(y)),y∈V,\boldsymbol{\gamma}(\mathbf{y}) = (\mathbf{y}, \varphi(\mathbf{y})), \qquad \mathbf{y} \in V,

a C1C^1 map with γ(y0)=x0\boldsymbol{\gamma}(\mathbf{y}_0) = \mathbf{x}_0 and image lying in S∩(V×I)S \cap (V \times I).

Step 2: Reduce to an unconstrained critical point. Define F:V→RF : V \to \mathbb{R} by

F(y)=f(γ(y))=f(y,φ(y)).F(\mathbf{y}) = f(\boldsymbol{\gamma}(\mathbf{y})) = f(\mathbf{y}, \varphi(\mathbf{y})).

Because x0\mathbf{x}_0 is a local extremum of ff on SS, and γ\boldsymbol{\gamma} is a bijection from a neighborhood of y0\mathbf{y}_0 onto a neighborhood of x0\mathbf{x}_0 in SS (this is part of the Implicit Function Theorem's conclusion), y0\mathbf{y}_0 is a local extremum of FF on VV, an unconstrained extremum since VV is open in Rn−1\mathbb{R}^{n-1}. As FF is C1C^1 (a composite of C1C^1 maps, using the chain rule from The Gradient and Directional Derivatives), the theory of Critical Points and Extrema applies directly: at an interior local extremum of a differentiable function, all partial derivatives vanish. Hence

∇F(y0)=0.\nabla F(\mathbf{y}_0) = \mathbf{0}.

Step 3: Translate back via the chain rule. For each j=1,…,n−1j = 1, \dots, n-1, let ej\mathbf{e}_j denote the jj-th standard basis vector in Rn−1\mathbb{R}^{n-1}, and consider the curve γ(y0+tej)\boldsymbol{\gamma}(\mathbf{y}_0 + t\mathbf{e}_j) through x0\mathbf{x}_0. Differentiating F(y)=f(γ(y))F(\mathbf{y}) = f(\boldsymbol{\gamma}(\mathbf{y})) in the jj-th coordinate direction at y0\mathbf{y}_0 gives, by the chain rule,

0=∂F∂yj(y0)=∇f(x0)⋅∂γ∂yj(y0),j=1,…,n−1.0 = \frac{\partial F}{\partial y_j}(\mathbf{y}_0) = \nabla f(\mathbf{x}_0) \cdot \frac{\partial \boldsymbol{\gamma}}{\partial y_j}(\mathbf{y}_0), \qquad j = 1, \dots, n-1.

The vectors ∂γ∂yj(y0)=(ej,∂φ∂yj(y0))\dfrac{\partial \boldsymbol{\gamma}}{\partial y_j}(\mathbf{y}_0) = \left(\mathbf{e}_j, \dfrac{\partial \varphi}{\partial y_j}(\mathbf{y}_0)\right) for j=1,…,n−1j=1,\dots,n-1 are linearly independent (their first n−1n-1 coordinates form the identity matrix), and by the Lemma each lies in the tangent space

T={v∈Rn:∇g(x0)⋅v=0},T = \{\mathbf{v} \in \mathbb{R}^n : \nabla g(\mathbf{x}_0)\cdot \mathbf{v} = 0\},

which is an (n−1)(n-1)-dimensional subspace since ∇g(x0)≠0\nabla g(\mathbf{x}_0) \neq \mathbf{0}. Being n−1n-1 linearly independent vectors inside an (n−1)(n-1)-dimensional space, they in fact span TT.

Step 4: Conclude parallelism. We have shown ∇f(x0)⋅v=0\nabla f(\mathbf{x}_0) \cdot \mathbf{v} = 0 for every v\mathbf{v} in a spanning set of TT, hence for every v∈T\mathbf{v} \in T. That is, ∇f(x0)\nabla f(\mathbf{x}_0) is orthogonal to the entire hyperplane T={v:∇g(x0)⋅v=0}T = \{\mathbf{v} : \nabla g(\mathbf{x}_0) \cdot \mathbf{v} = 0\}. But the orthogonal complement of a hyperplane {v:n⋅v=0}\{\mathbf{v} : \mathbf{n}\cdot \mathbf{v} = 0\} (for n≠0\mathbf{n} \ne \mathbf{0}) in Rn\mathbb{R}^n is exactly the one-dimensional line spanned by n\mathbf{n} itself: if w⋅v=0\mathbf{w}\cdot\mathbf{v}=0 for all v\mathbf{v} with n⋅v=0\mathbf{n}\cdot\mathbf{v}=0, decompose w=αn+w⊥\mathbf{w} = \alpha\mathbf{n} + \mathbf{w}^\perp with w⊥∈T\mathbf{w}^\perp \in T; then 0=w⋅w⊥=∣w⊥∣20 = \mathbf{w}\cdot\mathbf{w}^\perp = |\mathbf{w}^\perp|^2 forces w⊥=0\mathbf{w}^\perp = \mathbf{0}, so w=αn\mathbf{w} = \alpha\mathbf{n}. Applying this with w=∇f(x0)\mathbf{w} = \nabla f(\mathbf{x}_0) and n=∇g(x0)\mathbf{n} = \nabla g(\mathbf{x}_0), we conclude there exists λ∈R\lambda \in \mathbb{R} with

∇f(x0)=λ ∇g(x0).■\nabla f(\mathbf{x}_0) = \lambda\, \nabla g(\mathbf{x}_0). \qquad \blacksquare
∎
CorollaryMultiple constraints

Let U⊆RnU \subseteq \mathbb{R}^n be open, let f,g1,…,gk:U→Rf, g_1, \dots, g_k : U \to \mathbb{R} be C1C^1 with k<nk < n, and let

S={x∈U:g1(x)=c1,…,gk(x)=ck}.S = \{\mathbf{x} \in U : g_1(\mathbf{x}) = c_1, \dots, g_k(\mathbf{x}) = c_k\}.

If x0∈S\mathbf{x}_0 \in S is a local extremum of f∣Sf|_S and the gradients ∇g1(x0),…,∇gk(x0)\nabla g_1(\mathbf{x}_0), \dots, \nabla g_k(\mathbf{x}_0) are linearly independent, then there exist λ1,…,λk∈R\lambda_1, \dots, \lambda_k \in \mathbb{R} with

∇f(x0)=∑i=1kλi∇gi(x0).\nabla f(\mathbf{x}_0) = \sum_{i=1}^k \lambda_i \nabla g_i(\mathbf{x}_0).

Sketch of proof. The same construction applies with the Implicit Function Theorem now solving kk equations for kk of the coordinates in terms of the remaining n−kn-k, producing a local C1C^1 parametrization γ:V⊆Rn−k→S\boldsymbol{\gamma}: V \subseteq \mathbb{R}^{n-k} \to S. The tangent space TT at x0\mathbf{x}_0 becomes the (n−k)(n-k)-dimensional intersection ⋂i{v:∇gi(x0)⋅v=0}\bigcap_i \{\mathbf{v}: \nabla g_i(\mathbf{x}_0)\cdot\mathbf{v}=0\}, spanned by the n−kn-k partial derivatives of γ\boldsymbol{\gamma}, and one shows exactly as above that ∇f(x0)\nabla f(\mathbf{x}_0) annihilates TT. Linear algebra (orthogonal complement of an intersection of kk independent hyperplanes is the span of their kk normals) then yields ∇f(x0)∈span⁡{∇g1(x0),…,∇gk(x0)}\nabla f(\mathbf{x}_0) \in \operatorname{span}\{\nabla g_1(\mathbf{x}_0), \dots, \nabla g_k(\mathbf{x}_0)\}, which is exactly the stated conclusion. ■\blacksquare

Worked examples

Example 1 — asymmetric fencing problem. A rectangular pen of width xx and height yy is to be built with 200200 meters of fencing, but one side of length xx borders an existing wall and needs no fence. Maximize area f(x,y)=xyf(x,y) = xy subject to the fencing constraint

g(x,y)=x+2y=200,x,y>0.g(x,y) = x + 2y = 200, \qquad x, y > 0.

The gradients are ∇f=(y,x)\nabla f = (y, x) and ∇g=(1,2)\nabla g = (1, 2). The Lagrange condition ∇f=λ∇g\nabla f = \lambda \nabla g gives

y=λ,x=2λ.y = \lambda, \qquad x = 2\lambda.

So x=2yx = 2y. Substituting into the constraint: 2y+2y=200⇒y=502y + 2y = 200 \Rightarrow y = 50, hence x=100x = 100, λ=50\lambda = 50. Check regularity: ∇g=(1,2)≠0\nabla g = (1,2) \ne \mathbf{0} everywhere, so the point is automatically regular. The area is f(100,50)=5000f(100, 50) = 5000 square meters. To confirm this is a maximum rather than merely a candidate, substitute the constraint directly: y=(200−x)/2y = (200-x)/2, so f(x)=x(200−x)/2f(x) = x(200-x)/2 for 0<x<2000 < x < 200, a downward parabola maximized at x=100x = 100 (where f′(x)=(200−2x)/2=0f'(x) = (200-2x)/2 = 0), matching the multiplier computation exactly and confirming it is the global maximum on the open interval — and since f→0f\to 0 at both endpoints x→0+,x→200−x\to 0^+, x\to 200^-, the interior critical point is indeed the maximum.

Example 2 — two constraints in R3\mathbb{R}^3 (asymmetric numbers). Minimize f(x,y,z)=x2+y2+z2f(x,y,z) = x^2 + y^2 + z^2 (squared distance to the origin) subject to

g1(x,y,z)=x+y+z=6,g2(x,y,z)=x−y+2z=3.g_1(x,y,z) = x + y + z = 6, \qquad g_2(x,y,z) = x - y + 2z = 3.

This finds the point on the line of intersection of the two planes closest to the origin. Gradients: ∇f=(2x,2y,2z)\nabla f = (2x, 2y, 2z), ∇g1=(1,1,1)\nabla g_1 = (1,1,1), ∇g2=(1,−1,2)\nabla g_2 = (1,-1,2). These two constraint gradients are linearly independent (neither is a scalar multiple of the other — check: (1,1,1)=t(1,−1,2)(1,1,1) = t(1,-1,2) forces t=1t=1 from the first coordinate but then second coordinate gives 1=−11=-1, contradiction), so every point of the intersection line is regular. The Lagrange condition:

2x=λ1+λ2,2y=λ1−λ2,2z=λ1+2λ2.2x = \lambda_1 + \lambda_2, \qquad 2y = \lambda_1 - \lambda_2, \qquad 2z = \lambda_1 + 2\lambda_2.

Together with x+y+z=6x+y+z=6 and x−y+2z=3x-y+2z=3, this is a linear system in x,y,z,λ1,λ2x,y,z,\lambda_1,\lambda_2. From the first three equations,

x=λ1+λ22,y=λ1−λ22,z=λ1+2λ22.x = \frac{\lambda_1+\lambda_2}{2}, \quad y = \frac{\lambda_1 - \lambda_2}{2}, \quad z = \frac{\lambda_1+2\lambda_2}{2}.

Substitute into x+y+z=6x + y + z = 6:

λ1+λ22+λ1−λ22+λ1+2λ22=6  ⟹  3λ1+2λ22=6  ⟹  3λ1+2λ2=12.\frac{\lambda_1+\lambda_2}{2} + \frac{\lambda_1-\lambda_2}{2} + \frac{\lambda_1+2\lambda_2}{2} = 6 \implies \frac{3\lambda_1 + 2\lambda_2}{2} = 6 \implies 3\lambda_1 + 2\lambda_2 = 12.

Substitute into x−y+2z=3x - y + 2z = 3:

λ1+λ22−λ1−λ22+2⋅λ1+2λ22=3  ⟹  λ2+λ1+2λ2=3  ⟹  λ1+3λ2=3.\frac{\lambda_1+\lambda_2}{2} - \frac{\lambda_1-\lambda_2}{2} + 2\cdot\frac{\lambda_1+2\lambda_2}{2} = 3 \implies \lambda_2 + \lambda_1 + 2\lambda_2 = 3 \implies \lambda_1 + 3\lambda_2 = 3.

Solve the pair 3λ1+2λ2=123\lambda_1 + 2\lambda_2 = 12, λ1+3λ2=3\lambda_1 + 3\lambda_2 = 3. From the second, λ1=3−3λ2\lambda_1 = 3 - 3\lambda_2. Substitute:

3(3−3λ2)+2λ2=12  ⟹  9−9λ2+2λ2=12  ⟹  −7λ2=3  ⟹  λ2=−37.3(3-3\lambda_2) + 2\lambda_2 = 12 \implies 9 - 9\lambda_2 + 2\lambda_2 = 12 \implies -7\lambda_2 = 3 \implies \lambda_2 = -\tfrac{3}{7}.

Then λ1=3−3(−37)=3+97=307\lambda_1 = 3 - 3(-\tfrac37) = 3 + \tfrac97 = \tfrac{30}{7}. Now

x=λ1+λ22=307−372=27/72=2714,x = \frac{\lambda_1+\lambda_2}{2} = \frac{\frac{30}{7} - \frac37}{2} = \frac{27/7}{2} = \frac{27}{14},
y=λ1−λ22=307+372=33/72=3314,y = \frac{\lambda_1-\lambda_2}{2} = \frac{\frac{30}{7}+\frac37}{2} = \frac{33/7}{2} = \frac{33}{14},
z=λ1+2λ22=307−672=24/72=127=2414.z = \frac{\lambda_1+2\lambda_2}{2} = \frac{\frac{30}{7} - \frac67}{2} = \frac{24/7}{2} = \frac{12}{7} = \frac{24}{14}.

Check constraint 1: 27+33+2414=8414=6\frac{27+33+24}{14} = \frac{84}{14} = 6. ✓. Check constraint 2: x−y+2z=2714−3314+4814=4214=3x - y + 2z = \frac{27}{14} - \frac{33}{14} + \frac{48}{14} = \frac{42}{14} = 3. ✓. Since ff is a strictly convex function (sum of squares) and the constraint set is an affine line (unbounded and closed), the unique critical point found by the multiplier method must be the global minimum — an unconstrained convex minimization over an affine subspace has at most one critical point, which is automatically the minimizer. The minimal squared distance is

f=(2714)2+(3314)2+(2414)2=729+1089+576196=2394196=119798=17114.f = \left(\frac{27}{14}\right)^2 + \left(\frac{33}{14}\right)^2 + \left(\frac{24}{14}\right)^2 = \frac{729 + 1089 + 576}{196} = \frac{2394}{196} = \frac{1197}{98} = \frac{171}{14}.
CounterexampleDropping the regularity hypothesis

The regularity hypothesis ∇g(x0)≠0\nabla g(\mathbf{x}_0) \neq \mathbf{0} is not a technicality — without it the conclusion can fail outright. Consider

f(x,y)=x,g(x,y)=y2−x3,S={(x,y):g(x,y)=0}.f(x,y) = x, \qquad g(x,y) = y^2 - x^3, \qquad S = \{(x,y) : g(x,y) = 0\}.

The set SS is the classical semicubical parabola y2=x3y^2 = x^3, which has a cusp at the origin. Compute ∇g(x,y)=(−3x2,2y)\nabla g(x,y) = (-3x^2, 2y), so ∇g(0,0)=(0,0)\nabla g(0,0) = (0,0): the origin is a non-regular point of SS. Parametrize SS (for x≥0x \ge 0) by x=t2,y=t3x = t^2, y = t^3, t∈Rt \in \mathbb{R}, which traces the full cusp curve as tt ranges over R\mathbb{R} (note x=t2≥0x=t^2\geq0 always, matching y2=t6=x3y^2 = t^6 = x^3). Then ff restricted to SS is f(t2,t3)=t2f(t^2, t^3) = t^2, which has a strict local (indeed global) minimum at t=0t = 0, i.e., at the origin (0,0)∈S(0,0) \in S. So (0,0)(0,0) genuinely is a constrained minimum of ff on SS. But is there a λ\lambda with ∇f(0,0)=λ∇g(0,0)\nabla f(0,0) = \lambda \nabla g(0,0)? We have ∇f(0,0)=(1,0)\nabla f(0,0) = (1,0) and ∇g(0,0)=(0,0)\nabla g(0,0) = (0,0), so the equation reads

(1,0)=λ(0,0)=(0,0),(1,0) = \lambda(0,0) = (0,0),

which is false for every λ∈R\lambda \in \mathbb{R}. The Lagrange condition fails to hold at a genuine constrained extremum, precisely because the regularity hypothesis ∇g≠0\nabla g \neq \mathbf 0 was violated: the cusp point has no well-defined tangent line, so the entire tangent-space argument in the proof (which needed TT to be an honest hyperplane) collapses.

Scope, edge cases & common traps

SituationWhat to do
Constraint set unbounded or non-compactLagrange gives candidates only; check behavior at infinity separately (as in Example 2, convexity substituted for compactness)
Constraint set compact (closed & bounded)Extreme Value Theorem guarantees a global max/min exists among the Lagrange candidates — compare values directly
Multiple critical points foundMust compare ff-values at all candidates; the method does not rank them
Non-regular point on SSTheorem's conclusion may fail (see counterexample); check such points by hand
Boundary of UU itself, or SS with boundaryLagrange applies to interior regular points of SS; boundary points of SS (if SS is a manifold-with-boundary) need separate treatment
k≥nk \ge n constraintsMethod as stated requires k<nk < n so that SS has positive dimension; k=nk=n generically forces isolated points, no optimization needed

The mathematician behind it

Origins · 1 minJoseph-Louis Lagrange and how this was discovered
JL
Joseph-Louis Lagrange
1736–1813 · Turin, Berlin, Paris

Lagrange was one of the towering figures of 18th-century mathematics, contributing foundational work across analysis, number theory, and mechanics. Born in Turin, he was largely self-taught in mathematics, and by age nineteen was appointed professor at the Royal Artillery School there. He later succeeded Euler as director of mathematics at the Prussian Academy of Sciences in Berlin, and eventually settled in Paris, where he survived the Revolution and helped found the metric system. His monumental treatise Mécanique Analytique (1788) recast all of mechanics in terms of generalized coordinates and variational principles, introducing the multiplier technique as a way to handle constrained motion — a mechanical system confined to a surface or curve is exactly a constrained optimization problem in the calculus of variations, and Lagrange's method for eliminating constraint forces via auxiliary multipliers became the seed of the general technique used today in pure optimization.

History
- 1755–1756: Young Lagrange corresponds with Euler on the calculus of variations, developing the δ\delta-notation still used today.
- 1764–1766: Lagrange wins prizes from the Paris Academy for work on the librations of the Moon and moons of Jupiter, using constrained-motion techniques.
- 1788: Publication of Mécanique Analytique, systematizing generalized coordinates and multipliers for constrained mechanical systems.
- 1797: Lagrange publishes Théorie des fonctions analytiques, part of his broader push to found calculus on algebraic, rigorous grounds.
- 1813: Lagrange dies in Paris; his multiplier method, originally mechanical, is by the 20th century a standard tool across all of constrained optimization.
Why introduce a new variable λ\lambda instead of just substituting the constraint directly?

Substitution works when the constraint can be solved explicitly for one variable in terms of the others, as in single-constraint problems in two variables. But with several constraints, implicit constraint functions, or constraints that cannot be inverted in closed form, explicit substitution becomes impossible or extremely messy. The multiplier method sidesteps this by working directly with gradients, requiring only that the constraint gradients be linearly independent at the point in question — a condition verified locally without ever solving for one variable globally. It also generalizes uniformly to any number of constraints, unlike ad hoc substitution.

Does the multiplier λ\lambda itself mean anything, or is it just an algebraic trick?

It has a genuine interpretation as a shadow price or sensitivity coefficient. If V(c)V(c) denotes the optimal value of ff on {g=c}\{g=c\} as a function of the constraint level cc, then under suitable smoothness V′(c)=λV'(c) = \lambda, the multiplier found at the optimum. This means λ\lambda measures how much the optimal value would change per unit relaxation of the constraint — in economics this is literally the marginal utility of an extra unit of budget, and in engineering it is the marginal benefit of loosening a resource limit.

What happens if I have more constraints than variables, or the constraint gradients are dependent?

If the number of constraints kk equals or exceeds the number of variables nn, the constraint set generically consists of isolated points (or is empty), so there is no continuum to optimize over and the method is moot. If k<nk < n but the gradients ∇g1,…,∇gk\nabla g_1,\dots,\nabla g_k fail to be linearly independent at a point, that point is non-regular: the tangent space argument in the proof breaks down, and the Lagrange condition need not hold there even if the point is a genuine extremum, exactly as in the cusp counterexample.

How do I handle inequality constraints like g(x)≤cg(\mathbf{x}) \le c instead of equality?

Equality-constraint Lagrange multipliers extend to inequality constraints via the Karush–Kuhn–Tucker (KKT) conditions. The key addition is a sign condition: the multiplier for an inequality constraint must have a definite sign (nonnegative, with the convention that the constraint is active) reflecting that the constraint only "pushes" the optimum in one direction. At points where the inequality is strict (not tight), the corresponding multiplier is simply zero and the constraint is ignored, recovering an unconstrained condition locally.

Can this method fail to find a solution even when a maximum obviously exists?

The method finds only candidates satisfying the gradient condition at regular points. If the true maximum occurs at a non-regular point of the constraint set (as in the cusp example) or the constraint set is not compact and the supremum is approached only in a limit (never attained), then solving the Lagrange system may miss the answer entirely or return no finite solution. Always check regularity and existence (e.g., via compactness or convexity arguments) alongside solving the algebraic system.

Is there a second-derivative test analogous to the Hessian test for unconstrained extrema?

Yes — the bordered Hessian test. One forms a Hessian-like matrix incorporating the constraint gradients as "border" rows and columns, then examines the signs of its leading principal minors (of appropriate order) to classify a Lagrange candidate as a local max, min, or saddle, generalizing the second-derivative test from Critical Points and Extrema. This is more delicate than the unconstrained case because only directions tangent to the constraint set matter.

Before this

Where this leads