We often need to find the maximum or minimum of a function f(x,y) when the point (x,y) has to stay on a curve g(x,y)=c.
1
Tangency and the Lagrange Multiplier
When a constraint equation g(x,y)=c is complicated, solving it for y and plugging that into f(x,y) leads to messy square roots, and setting ∇f=⟨0,0⟩ doesn't work because the surface doesn't have to be flat at the highest point of a path. Instead, we look at where the constraint curve meets the level curves of f(x,y).
Tangency and the Lagrange Multiplier
At the highest or lowest point along the constraint curve g(x,y)=c, the constraint curve is tangent to a level curve of f(x,y), which means their perpendicular gradient vectors lie on the same line:
∇f=Lagrange multiplierλ∇g,g(x,y)=c
Wherever the path g(x,y)=c crosses the contour lines of f(x,y), the gradient ∇f angles forward or backward along the path toward higher values of f; at the exact points where f(x,y) reaches a peak or a low point along the path, the contour line is tangent to the path and ∇f and ∇g line up along the same line.
Along the trail, you hit a high or low point right where the contour line just touches the trail and the two gradients line up.
2
Optimizing on a Curve
Let's find the maximum and minimum values of f(x,y)=xy on the ellipse x2+4y2=8.
Optimizing on a Curve
Text solution
1. Match the components of ∇f=λ∇g and include the constraintComputing ∇f=⟨y,x⟩ and ∇g=⟨2x,8y⟩ gives three equations for the three unknowns x,y, and λ:
yxx2+4y2=2λx=8λy=8
2. Eliminate λ to find how x and y are relatedBecause x=0 makes y=0,y=0 makes x=0, and (0,0) is not on the ellipse, neither coordinate is zero, so we solve both gradient equations for λ and set them equal:
λλ2xy8y2x2=2xy=8yx=8yx=2x2=4y2
3. Substitute x2=4y2 into the constraint equationReplacing x2 with 4y2 in the ellipse equation gives the x- and y-coordinates of all four tangent points:
4y2+4y28y2y2yx2x=8=8=1=1 or y=−1=4(1)=4=2 or x=−2
4. Evaluate f(x,y) at all four candidate pointsPlugging each sign combination (2,1),(−2,−1),(2,−1), and (−2,1) into f(x,y)=xy tells us which points give the maximum and which give the minimum:
So on the ellipse x2+4y2=8,f(x,y)=xy reaches a maximum of 2 at (2,1) and (−2,−1), and a minimum of −2 at (2,−1) and (−2,1).
3
Optimizing in Three Variables
For a function of three variables f(x,y,z) restricted to a constraint surface g(x,y,z)=c, each constant value f(x,y,z)=k gives a level surface in 3D space, and the maximum and minimum values still happen where a level surface of f is tangent to the constraint surface g.
Now let's find the maximum and minimum values of f(x,y,z)=x+2y+3z on the sphere x2+y2+z2=14.
Optimizing in Three Variables
Text solution
1. Set the 3D gradients parallel and include the sphere equationMatching ∇f=⟨1,2,3⟩ with λ∇g=λ⟨2x,2y,2z⟩ gives a system of four equations:
123x2+y2+z2=2λx=2λy=2λz=14
2. Write y and z in terms of x using λSince λ=0 would make 1=0, we can divide by 2λ to express y and z in terms of x:
xyz=2λ1=2λ2=2x=2λ3=3x
3. Substitute y=2x and z=3x into the sphere equationWriting the whole constraint equation in terms of x gives the two tangent points on the sphere:
So on the sphere x2+y2+z2=14,f(x,y,z)=x+2y+3z has a maximum of 14 at (1,2,3) and a minimum of −14 at (−1,−2,−3).
The level plane x+2y+3z=k slices through the sphere x2+y2+z2=14 whenever their normal vectors ∇f=⟨1,2,3⟩ and ∇g=⟨2x,2y,2z⟩ point in different directions, and is tangent to the sphere only at (1,2,3) and (−1,−2,−3) where ∇f and ∇g are parallel.
The level plane slices through the sphere everywhere except at the two spots where their normal arrows are parallel.
4
Optimizing on a Closed Region
When the constraint is an inequality g(x,y)≤c, we want the absolute maximum and minimum of f(x,y) over an entire region: both its interior g(x,y)<c and its boundary curve g(x,y)=c. Inside the region, you can step freely in any direction, so a peak or valley can only happen at a flat critical point where ∇f=⟨0,0⟩; along the boundary curve, maximums and minimums happen where ∇f=λ∇g.
Let's find the absolute maximum and minimum values of f(x,y)=2x2+y2−2y on the closed disk x2+y2≤4.
Optimizing on a Closed Region
Text solution
1. Set ∇f=⟨0,0⟩ to find critical points inside the disk x2+y2<4Setting both partial derivatives to zero gives one critical point, which we check in the inequality to make sure it actually lies inside the disk:
∇f=⟨4x,2y−2⟩4x2y−202+12=⟨0,0⟩=0⟹x=0=0⟹y=1=1<4(inside the disk)
2. Set ∇f=λ∇g on the boundary circle x2+y2=4 and factorInstead of dividing 4x=2λx by x (which would lose any boundary solution where x=0), we move everything to one side and factor:
4x4x−2λx2x(2−λ)2y−2x2+y2=2λx=0=0=2λy=4
3. Solve the x=0 case and the λ=2 case for the boundary pointsPlugging each factor of 2x(2−λ)=0 into the remaining equations gives four boundary candidates:
If x=0:02+y2yIf λ=2:2y−22y−2−2yx2+(−1)2x2x=4=±2⟹(0,2),(0,−2)=2(2y)=4y=2y=−1=4=3=±3⟹(3,−1),(−3,−1)
4. Evaluate f(x,y) at the interior point and all four boundary pointsComparing the values of f(x,y)=2x2+y2−2y at all five candidates gives the highest and lowest values on the disk:
So on the closed disk x2+y2≤4,f(x,y)=2x2+y2−2y has an absolute minimum of −1 at (0,1) inside the disk and an absolute maximum of 9 at (3,−1) and (−3,−1) on the boundary.
Inside the disk x2+y2≤4, the minimum at (0,1) happens where ∇f=⟨0,0⟩, while along the boundary circle x2+y2=4 the gradient ∇f is never zero and the maximums and minimums happen at the four points where ∇f lines up with ∇g.
Inside the disk, the low point sits where the uphill arrow shrinks to nothing, while on the rim, high and low points happen where the uphill arrow lines up with the wall's outward arrow.
5
What the Multiplier Means
The Lagrange multiplier λ tells you how fast the maximum or minimum value of f changes when you change the constant c in the constraint g(x,y)=c.
What the Multiplier Means
When g(x,y)=c represents a budget or resource limit, increasing that limit from c to c+1 increases the maximum value of f by approximately λ:
Δfmax≈λ(when c increases by 1)
Summary
When a constraint g(x,y)=c is easy to solve for one variable (such as a line y=2x+1), substitute it straight into f(x,y) and take a regular derivative. Use Lagrange multipliers when solving the constraint brings in square roots (like an ellipse or circle) or when there are three variables.
On a curve or surface (g=c)
Maximums and minimums happen where the level curve or level surface of f is tangent to the constraint g=c, so their gradients are parallel:
∇f=λ∇g,g=c
Eliminate λ to relate the coordinates. For f(x,y)=xy on x2+4y2=8, matching λ=2xy=8yx gives x2=4y2; for f(x,y,z)=x+2y+3z on x2+y2+z2=14, writing x=2λ1,y=2λ2,z=2λ3 gives y=2x and z=3x. If a variable appears on both sides of a gradient equation, such as 4x=2λx, move terms to one side and factor as 2x(2−λ)=0 rather than dividing by x.
On a closed region (g≤c)
Make one list of candidate points combining the interior critical points where ∇f=⟨0,0⟩ (leaving out any point where g(x,y)≥c) and the boundary points on g=c where ∇f=λ∇g, then compare f at every candidate.
Sensitivity to the constraint (λ)
Evaluating λ at the maximum or minimum point tells you approximately how much the maximum or minimum value of f changes when the resource limit c in g=c increases by 1 unit.
6
Practice
1
Find the maximum and minimum values of f(x,y)=xy on the ellipse x2+9y2=18, and the points where they occur.
Watch out: substituting x=9y instead of x2=9y2 gives 90y2=18 and a wrong maximum of 59.
Set ∇f=λ∇g and solve both gradient equations for λ: how is x2 related to y2?
Matching ∇f=⟨y,x⟩ with λ∇g=λ⟨2x,18y⟩ gives the system:
yxx2+9y2=2λx=18λy=18
Since neither x nor y can be 0 at the maximum or minimum, solve for λ in both equations and cross-multiply:
λ=2xy18y2x2=18yx=2x2=9y2
Substitute x2=9y2 into the ellipse equation:
9y2+9y218y2y2x2=18=18=1⟹y=±1=9(1)=9⟹x=±3
(Watch out: taking only the positive roots x=3,y=1 misses (−3,−1) and misses the minimum −3 altogether; likewise, substituting x=9y instead of x2=9y2 gives 90y2=18 and a wrong maximum of 59.)
Evaluating f(x,y)=xy at all four sign combinations gives a maximum of 3 at (3,1) and (−3,−1), and a minimum of −3 at (3,−1) and (−3,1).
2
Find the maximum and minimum values of f(x,y,z)=x+2y+4z on the ellipsoid x2+2y2+4z2=28, and the points where they occur.
Write ∇f=λ∇g for each coordinate and solve for x,y, and z in terms of λ: how do the three coordinates compare?
Matching ∇f=⟨1,2,4⟩ with λ∇g=λ⟨2x,4y,8z⟩ gives:
124x2+2y2+4z2=2λx=4λy=8λz=28
(Watch out: if you treat the ellipsoid like a sphere and write ∇g=⟨2x,2y,2z⟩, you get y=2x and z=4x, leading to 73x2=28 instead of equal coordinates.)
Divide each gradient equation by the number in front of x,y, or z along with λ:
xyz=2λ1=4λ2=2λ1=x=8λ4=2λ1=x
Substitute y=x and z=x into the ellipsoid equation:
x2+2(x)2+4(x)27x2x2x=28=28=4=±2⟹(2,2,2) and (−2,−2,−2)
Plugging both points into f(x,y,z)=x+2y+4z gives a maximum of 14 at (2,2,2) and a minimum of −14 at (−2,−2,−2).
3
Find the absolute maximum and minimum values of f(x,y)=x2+2y2−2x on the closed disk x2+y2≤4, and the points where they occur.
After finding the interior critical point where ∇f=⟨0,0⟩, look at the y-equation on the boundary (4y=2λy): how do you solve it without dividing by y?
First check the interior x2+y2<4 by setting ∇f=⟨2x−2,4y⟩=⟨0,0⟩:
2x−24y12+02=0⟹x=1=0⟹y=0=1<4⟹(1,0) is inside
(Watch out: skipping the interior check ∇f=⟨0,0⟩ leaves only the boundary points and gives a wrong absolute minimum of 0 at (2,0) instead of −1 at (1,0).)
Next check the boundary x2+y2=4 with ∇f=λ∇g:
2x−24yx2+y2=2λx=2λy⟹2y(2−λ)=0=4
(Watch out: dividing 4y=2λy by 2y loses the y=0 case, (2,0) and (−2,0).)
Plug both cases into the boundary equation:
If y=0:x2+02If λ=2:2x−2(−1)2+y2=4⟹x=±2⟹(2,0),(−2,0)=4x⟹x=−1=4⟹y2=3⟹y=±3⟹(−1,3),(−1,−3)
Compare f(x,y)=x2+2y2−2x at all five points:
f(1,0)f(2,0)f(−2,0)f(−1,±3)=−1=0=8=9
Absolute maximum 9 at (−1,3) and (−1,−3); absolute minimum −1 at (1,0).
4
Find the absolute maximum and minimum values of f(x,y)=x2+y2−12x−16y on the closed disk x2+y2≤25, and the points where they occur.
Find the point where ∇f=⟨0,0⟩ first, then plug its coordinates into x2+y2: does it belong on your candidate list?
Check for interior critical points where ∇f=⟨2x−12,2y−16⟩=⟨0,0⟩:
2x−122y−1662+82=0⟹x=6=0⟹y=8=100>25(outside the disk, discard)
(Watch out: forgetting to check whether (6,8) lies inside x2+y2≤25 and plugging it into f(x,y) gives f(6,8)=−100, the most common wrong answer for the absolute minimum.)
On the boundary x2+y2=25, set ∇f=λ∇g:
2x−122y−16=2λx⟹2x(1−λ)=12=2λy⟹2y(1−λ)=16
Dividing the second equation by the first cancels 1−λ:
Evaluate f(x,y)=x2+y2−12x−16y at both boundary points:
f(−3,−4)f(3,4)=9+16+36+64=125=9+16−36−64=−75
Absolute maximum 125 at (−3,−4); absolute minimum −75 at (3,4).
5
Maximizing output f(x,y)=xy subject to the resource constraint x+2y=100 gives a maximum of 1250 at (50,25). Find the Lagrange multiplier λ at this point, and state approximately how much the maximum output increases if the resource limit is increased from 100 to 101.
Watch out: swapping the partial derivatives in ∇f=⟨y,x⟩ and writing ⟨50,25⟩ gives the wrong multiplier λ=50.
Plug (x,y)=(50,25) into ∇f=λ∇g: what value of λ makes the vectors equal?
Compute ∇f=⟨y,x⟩ and ∇g=⟨1,2⟩ at (50,25) and set ∇f=λ∇g:
⟨y,x⟩⟨25,50⟩λ=λ⟨1,2⟩=λ⟨1,2⟩=25
(Watch out: swapping the partial derivatives in ∇f=⟨y,x⟩ and writing ⟨50,25⟩ gives the wrong multiplier λ=50.)
λ=25; the maximum output increases by approximately 25 units.