← Chapter 4 §4.8 Lagrange Multipliers 拉格朗日乘数法 · Chapter 4 · Differentiation of Functions of Several Variables

Calculus Volume 3 · Chapter 4 · Section 4.8

Lagrange Multipliers

Maximize or minimize a function when you are only allowed to move along a curve or a surface.

Colour key ∇f ∇g constraint level curve through the point key idea · page links open the textbook

Level 1 · see itThe best point you are allowed to reachbefore any equations

The best point on a budget line

A golf-ball maker's profit, in thousands of dollars, is f(x,y)=48x+96yx22xy9y2f(x,y)=48x+96y-x^2-2xy-9y^2 for xx thousand balls and yy hours of advertising (p406).

With no limits the best is f(21,3)=648f(21,3)=648. But the budget is 20x+4y=21620x+4y=216, that is 5x+y=545x+y=54, and (21,3)(21,3) would cost 521+3=1085\cdot21+3=108.

Slide along the budget line: the profit rises until the line just touches a level curve, then falls. The touch is at (10,4)(10,4), profit 540 (Example 4.43).

Level curves f=300,400,480,540,600f=300,400,480,540,600 around the unreachable best, the budget line, and the best point on it.

Lab 1 · walk the constraint

  1. On the constraint g(x,y)=cg(x,y)=c you can only move along the curve.
  2. Where a level curve of ff crosses the constraint, one direction raises ff: not the best.
  3. At the best point the level curve touches. Both gradients are perpendicular to the same tangent, so f=λg\nabla f=\lambda\nabla g (Theorem 4.20).
problem
Arrows show directions only: ∇f and ∇g are drawn the same length.

Try: walk slowly through a candidate — the green level curve stops crossing and touches, and the two arrows line up. Ex 365 has two maxima and two minima. Ex 361 has six places where the arrows line up; only two of them are the answers.

One picture

Example 4.42: at (5,1)(5,1), f=8,16\nabla f=\langle 8,16\rangle (drawn at ¼ length) =81,2=8g=8\,\langle 1,2\rangle=8\,\nabla g. The minimum on the line is f(5,1)=27f(5,1)=27.

At the best point on a constraint, the gradients are parallel: ∇f = λ∇g.

Level 2 · compute itThe equations, the examples, more variablesand three labs

The method

Theorem 4.20 · p404 f(x0,y0)=λg(x0,y0),g(x0,y0)=0 \nabla f(x_0,y_0)=\lambda\,\nabla g(x_0,y_0),\qquad g(x_0,y_0)=0

at a constrained extremum where g(x0,y0)0\nabla g(x_0,y_0)\neq\mathbf 0. λ\lambda is the Lagrange multiplier.

Steps · p404
  1. Name ff and write the constraint as g=0g=0.
  2. Write f=λg\nabla f=\lambda\nabla g component by component, plus g=0g=0.
  3. Solve for x0,y0x_0,y_0 (and λ\lambda).
  4. Evaluate ff at every solution: the largest is the maximum, the smallest the minimum.

Unknowns x,y,λx,y,\lambda; equations: two components plus the constraint. Three and three.

Examples 4.42–4.45

Examplegivenresult
4.42 · p405minimize x2+4y22x+8yx^2+4y^2-2x+8y on x+2y=7x+2y=7f(5,1)=27f(5,1)=27, λ=8\lambda=8
4.43 · p406maximize 48x+96yx22xy9y248x+96y-x^2-2xy-9y^2 on 5x+y=545x+y=54f(10,4)=540f(10,4)=540, i.e. $540,000; λ=4\lambda=4
4.44 · p407minimize x2+y2+z2x^2+y^2+z^2 on x+y+z=1x+y+z=1f(13,13,13)=13f\big(\tfrac13,\tfrac13,\tfrac13\big)=\tfrac13
4.45 · p408x2+y2+z2x^2+y^2+z^2 on z2=x2+y2z^2=x^2+y^2 and x+yz+1=0x+y-z+1=06426\mp4\sqrt2 at (1±22,1±22,1±2)\big(-1\pm\tfrac{\sqrt2}{2},-1\pm\tfrac{\sqrt2}{2},-1\pm\sqrt2\big)

The section's opening estimate from Figure 4.60, a profit of about 395 near x,y5x,y\approx5 (p404), does not match the budget line; Example 4.43's exact maximum is 540 at (10,4)(10,4).

Lab 2 · solve the system

problem

Every problem goes the same way: gradients, the system, eliminate λ\lambda, substitute into the constraint, evaluate. Eliminating λ\lambda first turns "parallel" into one equation in xx and yy.

Three variables, one constraint

Same method · p407 f(x0,y0,z0)=λg(x0,y0,z0)g(x0,y0,z0)=0 \begin{aligned}\nabla f(x_0,y_0,z_0)&=\lambda\,\nabla g(x_0,y_0,z_0)\\ g(x_0,y_0,z_0)&=0\end{aligned}

Four equations in x,y,z,λx,y,z,\lambda.

Example 4.44: 2x,2y,2z=λ1,1,1\langle 2x,2y,2z\rangle=\lambda\langle1,1,1\rangle forces x=y=zx=y=z; the plane gives 13\tfrac13 each, and f=13f=\tfrac13.

The level surfaces of x2+y2+z2x^2+y^2+z^2 are spheres; the smallest one that reaches the plane touches it.

Checkpoint 4.39 turns it round: x+y+zx+y+z on the sphere x2+y2+z2=1x^2+y^2+z^2=1 ranges from 3-\sqrt3 to 3\sqrt3.

The sphere f=13f=\tfrac13 (radius 1/30.5771/\sqrt3\approx0.577) touches the plane at (13,13,13)\big(\tfrac13,\tfrac13,\tfrac13\big). Drag to turn.

Lab 3 · two constraints

Two constraints · p408 f=λ1g+λ2h,g=0,h=0 \nabla f=\lambda_1\nabla g+\lambda_2\nabla h,\qquad g=0,\quad h=0

Five equations in x,y,z,λ1,λ2x,y,z,\lambda_1,\lambda_2.

Example 4.45: the cone z2=x2+y2z^2=x^2+y^2 and the plane z=x+y+1z=x+y+1 meet in a curve. f=x2+y2+z2f=x^2+y^2+z^2 is the squared distance from the origin, so the question is: where is the curve nearest?

branch

The plane cuts both halves of the cone, so the curve has two branches, (x+1)(y+1)=12(x+1)(y+1)=\tfrac12 seen from above. Each branch has one nearest point: 6420.346-4\sqrt2\approx0.34 on the upper, 6+4211.666+4\sqrt2\approx11.66 on the lower.

Common mistakes

MistakeResultFix
Solving f=λg\nabla f=\lambda\nabla g without g=0g=0two equations, three unknowns: no single answerthe constraint is always one of the equations
Stopping at the first solutionEx 361: f(0,1)=1f(0,1)=1 reported, but the maximum is 2\sqrt2find every solution, evaluate ff at each
Dividing by an expression that can be 0Ex 4.45: 2z0(y0x0)=02z_0(y_0-x_0)=0 loses z0=0z_0=0 uncheckedsplit into cases
Calling a candidate a maximum on an unbounded constraintEx 4.42 has a minimum on the line, no maximumcompare with other points on the constraint
Reporting λ\lambda as the answer"the minimum is 8" in Ex 4.42the answer is f(x0,y0)=27f(x_0,y_0)=27
Using the inequality 20x+4y21620x+4y\le216 as if it were an equation everywheremissing the interior best point when it is affordablecheck f=0\nabla f=\mathbf 0 inside first (§4.7)

Practice and answers

Exercises from p411; the book's key: p864, p871p872.

Checkpoints 4.37–4.40
#taskanswer
4.37maximize 9x2+36xy4y218x8y9x^2+36xy-4y^2-18x-8y on 3x+4y=323x+4y=32f(8,2)=976f(8,2)=976 (λ=66\lambda=66)
4.38maximize 2.5x0.45y0.552.5x^{0.45}y^{0.55} on 40x+50y=500,00040x+50y=500{,}000about 13,890 at x=5625x=5625 labor hours, y=5500y=5500 capital
4.39minimize x+y+zx+y+z on x2+y2+z2=1x^2+y^2+z^2=13-\sqrt3 at (33,33,33)-\big(\tfrac{\sqrt3}{3},\tfrac{\sqrt3}{3},\tfrac{\sqrt3}{3}\big); max 3\sqrt3
4.40minimize x2+y2+z2x^2+y^2+z^2 on 2x+y+2z=92x+y+2z=9, 5x+5y+7z=295x+5y+7z=29f(2,1,2)=9f(2,1,2)=9
Exercises
#taskanswer
359xyzxyz on x2+2y2+3z2=6x^2+2y^2+3z^2=6max 233\tfrac{2\sqrt3}{3}, min 233-\tfrac{2\sqrt3}{3}
3614x3+y24x^3+y^2 on 2x2+y2=12x^2+y^2=1max 2\sqrt2 at (22,0)\big(\tfrac{\sqrt2}{2},0\big), min 2-\sqrt2 at (22,0)\big(-\tfrac{\sqrt2}{2},0\big)
363yz+xyyz+xy on xy=1xy=1, y2+z2=1y^2+z^2=1max 32\tfrac32, min 12\tfrac12
3654xy4xy on x29+y216=1\tfrac{x^2}{9}+\tfrac{y^2}{16}=1max 24 at ±(322,22)\pm\big(\tfrac{3\sqrt2}{2},2\sqrt2\big), min 24-24 at ±(322,22)\pm\big(-\tfrac{3\sqrt2}{2},2\sqrt2\big)
367x+3yzx+3y-z on x2+y2+z2=4x^2+y^2+z^2=4±211\pm2\sqrt{11} at ±1112,6,2\pm\tfrac{1}{\sqrt{11}}\langle 2,6,-2\rangle
369minimize x2+y2x^2+y^2 on xy=1xy=12
371maximize 2x+3y+5z2x+3y+5z on x2+y2+z2=19x^2+y^2+z^2=1919219\sqrt2
373on x3y3=1x^3-y^3=1, farthest from y=xy=x(123,123)\big(\tfrac{1}{\sqrt[3]2},-\tfrac{1}{\sqrt[3]2}\big)
375minimize x2+y2x^2+y^2, x+2y5=0x+2y-5=0f(1,2)=5f(1,2)=5
377minimize x2+y2+z2x^2+y^2+z^2, x+y+z=1x+y+z=113\tfrac13
379minimize x2+y2+z2x^2+y^2+z^2, x+y+z=9x+y+z=9, x+2y+3z=20x+2y+3z=20f(2,3,4)=29f(2,3,4)=29
381topless box from 12 ft² (p411)4 ft³, 2×2×12\times2\times1 ft
383on x22xy+y2x+y=0x^2-2xy+y^2-x+y=0, nearest (1,2,3)(1,2,-3) (p412)(32,32,3)\big(\tfrac32,\tfrac32,-3\big)
385distance from (0,1)(0,1) to x2=4yx^2=4y1
387distance from x+y+z=1x+y+z=1 to (2,1,1)(2,1,1)3\sqrt3
389on y=2x+3y=2x+3, nearest (4,2)(4,2)(25,195)\big(\tfrac25,\tfrac{19}{5}\big)
391maximize sinxsiny\sin x\sin y, x+y=π2x+y=\tfrac\pi212\tfrac12
39350x0.4y0.650x^{0.4}y^{0.6} on 100x+200y=20,000100x+200y=20{,}000about 3365 watches at (80,60)(80,60)
Level 3 · why it worksWhy the gradients line up, and what λ isshort arguments

Why the gradients line up

The book's proof (p404): walk the constraint by arc length, x=x(s)x=x(s), y=y(s)y=y(s), with the extremum at s=0s=0.

ddsf(x(s),y(s))=fT=0at s=0 \frac{d}{ds}f\big(x(s),y(s)\big)=\nabla f\cdot\mathbf T=0\quad\text{at } s=0

So f\nabla f is perpendicular to the tangent T\mathbf T. The constraint is a level curve of gg, so g\nabla g is perpendicular to T\mathbf T too. In the plane, two vectors perpendicular to the same nonzero T\mathbf T are parallel: f=λg\nabla f=\lambda\nabla g, provided g0\nabla g\neq\mathbf 0.

On a surface

f\nabla f is perpendicular to every curve in g=0g=0 through the point, so it points along the surface's normal g\nabla g.

Two constraints

The curve g=h=0g=h=0 has tangent g×h\nabla g\times\nabla h. f\nabla f\perp that tangent puts f\nabla f in the plane of g\nabla g and h\nabla h: λ1g+λ2h\lambda_1\nabla g+\lambda_2\nabla h.

"The derivative along the only allowed direction is zero" — the one-variable rule, in the one direction you may move.

What λ measures

Let the constraint be g=cg=c and write M(c)M(c) for the best value of ff. Then M(c)=λM'(c)=\lambda: λ\lambda is how much the best value improves per unit of extra constraint, the "shadow price".

Example 4.43, budget 54 → 55

Eliminating λ\lambda still gives x=5411yx=54-11y; with 5x+y=555x+y=55, y=21554y=\tfrac{215}{54}, x10.20x\approx10.20, and the best profit is 543.96\approx543.96.

A rise of 3.96 for one unit of 5x+y5x+y, next to λ=4\lambda=4. (λ itself drifts from 4 to about 3.93 along the way.)

Candidates, not answers

The equations find every point where the gradients line up, whatever the kind. Exercise 361, 4x3+y24x^3+y^2 on the ellipse 2x2+y2=12x^2+y^2=1:

candidateffalong the ellipse
(22,0)\big(\tfrac{\sqrt2}{2},0\big)21.41\sqrt2\approx1.41maximum
(0,±1)(0,\pm1)1local maxima
(13,±73)\big(\tfrac13,\pm\tfrac{\sqrt7}{3}\big)25270.93\tfrac{25}{27}\approx0.93local minima
(22,0)\big(-\tfrac{\sqrt2}{2},0\big)2-\sqrt2minimum
Closed and bounded

On an ellipse or a sphere, ff has a maximum and a minimum, and both are among the candidates: compare the values.

Unbounded

On a line or a hyperbola there may be no maximum (Ex 369, x2+y2x^2+y^2 on xy=1xy=1). In Example 4.45 both candidates are minima along their own branch — that is why the book says "local extreme values".