4.4.15Multivariable Calculus

Lagrange multipliers — one and two constraints

1,706 words8 min readdifficulty · medium6 backlinks

WHY does this work? (Derivation from scratch)

WHAT we want: maximize/minimize f(x)f(\mathbf{x}) where x\mathbf{x} is forced to lie on the surface g(x)=0g(\mathbf{x})=0.

Step 1 — Think about moving along the constraint. Suppose r(t)\mathbf{r}(t) is any smooth curve that lies inside the constraint surface, so g(r(t))=0g(\mathbf{r}(t))=0 for all tt. At a constrained extremum point r(t0)=x\mathbf{r}(t_0)=\mathbf{x}^*, the value f(r(t))f(\mathbf{r}(t)) must have an ordinary extremum, so

ddtf(r(t))t0=0.\frac{d}{dt}f(\mathbf{r}(t))\Big|_{t_0}=0.

Why this step? On the constraint surface we are no longer free — we can only travel along curves staying in the surface. A constrained max is just an ordinary max of the restricted function.

Step 2 — Apply the chain rule.

f(x)r(t0)=0.\nabla f(\mathbf{x}^*)\cdot \mathbf{r}'(t_0)=0.

This holds for every tangent direction r(t0)\mathbf{r}'(t_0) of the surface. So f\nabla f is orthogonal to all tangent directions — i.e. f\nabla f is normal to the constraint surface.

Step 3 — But g\nabla g is also normal to the surface. Differentiate g(r(t))=0g(\mathbf{r}(t))=0: gr=0\nabla g\cdot\mathbf{r}'=0, so g\nabla g is normal too. Two vectors normal to the same surface (one-dim normal space) must be parallel:


Two constraints

Now the point must satisfy both g(x)=0g(\mathbf{x})=0 and h(x)=0h(\mathbf{x})=0. Geometrically the feasible set is the intersection curve of two surfaces.

WHY two multipliers? Along that intersection curve, the allowed tangent direction T\mathbf{T} must be perpendicular to both g\nabla g and h\nabla h. At an extremum fT=0\nabla f\cdot\mathbf{T}=0, so f\nabla f has no component along T\mathbf{T} — meaning f\nabla f lies in the plane spanned by g\nabla g and h\nabla h:


Worked Example 1 — One constraint (a classic)

Maximize f(x,y)=xyf(x,y)=xy subject to g=x2+y21=0g=x^2+y^2-1=0 (point on unit circle).

f=(y,x)\nabla f=(y,x), g=(2x,2y)\nabla g=(2x,2y). Set f=λg\nabla f=\lambda\nabla g:

  • y=2λxy=2\lambda x (why: first component)
  • x=2λyx=2\lambda y (why: second component)

Multiply: xy=4λ2xyxy=4\lambda^2 xy. If xy0xy\ne 0, then 4λ2=14\lambda^2=1, λ=±12\lambda=\pm\tfrac12. From y=2λxy=2\lambda x with λ=12\lambda=\tfrac12: y=xy=x. Plug into constraint: 2x2=12x^2=1, x=±12x=\pm\tfrac{1}{\sqrt2}.

Max value f=xy=12f=xy=\tfrac12 at (12,12)(\tfrac1{\sqrt2},\tfrac1{\sqrt2}). Why accept it: check λ=12\lambda=-\tfrac12 gives y=xy=-x, f=12f=-\tfrac12 (the min).


Worked Example 2 — Distance / shadow-price meaning

Closest point on line x+y=4x+y=4 to origin. Minimize f=x2+y2f=x^2+y^2, g=x+y4=0g=x+y-4=0.

f=(2x,2y)=λ(1,1)\nabla f=(2x,2y)=\lambda(1,1)2x=2y=λ2x=2y=\lambdax=yx=y. Constraint: 2x=42x=4, x=y=2x=y=2. f=8f^*=8. Check λ\lambda meaning: with g=x+ycg=x+y-c, f=c2/2f^*=c^2/2, so df/dc=c=4df^*/dc=c=4, and indeed λ=2x=4\lambda=2x=4. ✔ The multiplier equals the sensitivity.


Worked Example 3 — Two constraints

Maximize f=x+y+zf=x+y+z on the circle that is the intersection of plane g=x+y+z1=0g=x+y+z-1=0... wait, that's degenerate. Use: Minimize f=zf=z subject to g=x2+y2z=0g=x^2+y^2-z=0 (paraboloid) and h=x+y+z3=0h=x+y+z-3=0 (plane).

f=(0,0,1)\nabla f=(0,0,1), g=(2x,2y,1)\nabla g=(2x,2y,-1), h=(1,1,1)\nabla h=(1,1,1). f=λg+μh\nabla f=\lambda\nabla g+\mu\nabla h:

  • 0=2λx+μ0=2\lambda x+\mu
  • 0=2λy+μ0=2\lambda y+\mu
  • 1=λ+μ1=-\lambda+\mu

From first two: 2λx=2λy2\lambda x=2\lambda yx=yx=y (if λ0\lambda\ne0). Constraints: z=2x2z=2x^2 and 2x+z=32x+z=32x+2x2=32x+2x^2=32x2+2x3=02x^2+2x-3=0x=1±72x=\frac{-1\pm\sqrt7}{2}. Why two roots: the curve dips down then up; one is min, one max of zz on the curve.



Recall Feynman: explain to a 12-year-old

Imagine you're walking on a fenced hilly field and you want the highest spot while staying on the fence path. You keep walking; as long as the ground still rises in your walking direction, keep going. You stop at the high point when the slope only goes sideways across the fence, not along your path. "Sideways to the path" is exactly "f\nabla f points across the fence" = parallel to the fence's normal g\nabla g. With two fences crossing, you can only stand where they cross, and you balance the two pulls — that's the two multipliers.


Flashcards

What condition does Lagrange's method impose at a constrained extremum (one constraint)?
f=λg\nabla f=\lambda\nabla g AND g=0g=0.
Geometric meaning of f=λg\nabla f=\lambda\nabla g?
f\nabla f is normal to the constraint surface (parallel to g\nabla g); no tangential direction increases ff.
Why is g\nabla g normal to the surface g=0g=0?
Differentiating g(r(t))=0g(\mathbf r(t))=0 gives gr=0\nabla g\cdot\mathbf r'=0 for every tangent r\mathbf r'.
Interpretation of the multiplier λ\lambda?
Rate of change of optimal value w.r.t. relaxing the constraint level: λ=df/dc\lambda=df^*/dc (shadow price).
Condition with TWO constraints?
f=λg+μh\nabla f=\lambda\nabla g+\mu\nabla h, with g=0g=0 and h=0h=0.
Why two multipliers for two constraints?
f\nabla f must have no component along the intersection curve's tangent, so it lies in span{g,h}\mathrm{span}\{\nabla g,\nabla h\}.
How many equations/unknowns for f:R3f:\mathbb R^3 with two constraints?
5 equations (3 gradient + 2 constraints), 5 unknowns (x,y,z,λ,μ)(x,y,z,\lambda,\mu).
A case where Lagrange can MISS an extremum?
Where g=0\nabla g=0 (singular point) or on a boundary not captured by g=0g=0.
Max of xyxy on x2+y2=1x^2+y^2=1?
1/21/2 at (12,12)(\tfrac1{\sqrt2},\tfrac1{\sqrt2}).

Connections

Concept Map

restrict to surface

d/dt f = 0 at extremum

holds for all tangents

differentiate

both normal, parallel

both normal, parallel

scalar meaning

add second surface

feasible set is intersection curve

grad f in plane of two normals

apply to f=xy on circle

Optimize f on constraint

Move along curve r of t

Chain rule grad f dot r' = 0

grad f normal to surface

g of x = 0

grad g normal to surface

grad f = lambda grad g

lambda is shadow price df*/dc

grad f = lambda grad g + mu grad h

Two surfaces g=0 and h=0

No component along tangent T

Worked example lambda = plus/minus 1/2

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, Lagrange multipliers ka idea bahut simple hai. Tumhe kisi function ff ko maximize ya minimize karna hai, lekin tum free nahi ho — ek constraint g=0g=0 ke upar hi chalna allowed hai. Socho ek pahaadi field me fence ke raaste pe chal rahe ho aur sabse oonchi jagah dhundh rahe ho, par fence chhodna mana hai. Jab tak fence ke direction me zameen upar chadh rahi hai, chalte raho. Jahan ruk jaoge wahan ff ka slope sirf fence ke "across" rahega, fence ke "along" nahi. Matlab f\nabla f constraint surface ke perpendicular ho gaya — aur g\nabla g bhi perpendicular hota hai, to dono parallel: f=λg\nabla f=\lambda\nabla g.

Yeh λ\lambda ko Lagrange multiplier bolte hain. Iska physical matlab bhi hai: λ=df/dc\lambda=df^*/dc, yaani agar constraint ko thoda dheela karo to optimal value kitna improve hoga — "shadow price". Bada λ\lambda matlab constraint mehenga pad raha hai. Solve karte time yaad rakho: gradient wali equations ke saath constraint equation g=0g=0 ko bhi use karna zaroori hai, warna point fix nahi hoga.

Do constraints wale case me tum sirf un do surfaces ki intersection curve pe ho. Ab f\nabla f ko un dono normals g\nabla g aur h\nabla h ke combination ke barabar hona padega: f=λg+μh\nabla f=\lambda\nabla g+\mu\nabla h. Reason simple hai — curve ke tangent direction me ff change nahi hona chahiye, isliye f\nabla f ka tangent ke along koi component nahi bachna chahiye, to woh g\nabla g aur h\nabla h ke plane me hi lie karega.

Common galti: log f=0\nabla f=0 laga dete hain (woh unconstrained case ka rule hai), ya constraint equation bhool jaate hain, ya dono multipliers ki jagah ek hi laga dete hain. Inse bacho, har equation likho, count karo: R3\mathbb R^3 me two constraints ka matlab 5 equations, 5 unknowns. Bas, mehnat solve karne me hai, concept clear hai!

Go deeper — visual, from zero

Test yourself — Multivariable Calculus

Connections