## Section 7.7 Lagrange Multipliers

¶Many applied max/min problems take the following form: we want to find an extreme value of a function, like \(V=xyz\text{,}\) subject to a constraint, like \(\ds1=\sqrt{x^2+y^2+z^2}\text{.}\) Often this can be done, as we have, by explicitly combining the equations and then finding critical points. There is another approach that is often convenient, the method of Lagrange multipliers.

It is somewhat easier to understand two variable problems, so we begin with one as an example. Suppose the perimeter of a rectangle is to be 100 units. Find the rectangle with largest area. This is a fairly straightforward problem from single variable calculus. We write down the two equations: \(A=xy\text{,}\) \(P=100=2x+2y\text{,}\) solve the second of these for \(y\) (or \(x\)), substitute into the first, and end up with a one-variable maximization problem. Let's now think of it differently: the equation \(A=xy\) defines a surface, and the equation \(100=2x+2y\) defines a curve (a line, in this case) in the \(x\)-\(y\)-plane. If we graph both of these in the three-dimensional coordinate system, we can phrase the problem like this: what is the highest point on the surface above the line? The solution we already understand effectively produces the equation of the cross-section of the surface above the line and then treats it as a single variable problem. Instead, imagine that we draw the level curves (the contour lines) for the surface in the \(x\)-\(y\)-plane, along with the line.

Imagine that the line represents a hiking trail and the contour lines are, as on a topographic map, the lines of constant altitude. How could you estimate, based on the graph, the high (or low) points on the path? As the path crosses contour lines, you know the path must be increasing or decreasing in elevation. At some point you will see the path just touch a contour line (tangent to it), and then begin to cross contours in the opposite order—that point of tangency must be a maximum or minimum point. If we can identify all such points, we can then check them to see which gives the maximum and which the minimum value. As usual, we also need to check boundary points; in this problem, we know that \(x\) and \(y\) are positive, so we are interested in just the portion of the line in the first quadrant, as shown. The endpoints of the path, the two points on the axes, are not points of tangency, but they are the two places that the function \(xy\) is a minimum in the first quadrant.

How can we actually make use of this? At the points of tangency that we seek, the constraint curve (in this case the line) and the level curve have the same slope—their tangent lines are parallel. This also means that the constraint curve is perpendicular to the gradient vector of the function; going a bit further, if we can express the constraint curve itself as a level curve, then we seek the points at which the two level curves have parallel gradients. The curve \(100=2x+2y\) can be thought of as a level curve of the function \(2x+2y\text{;}\) Figure 7.10 shows both sets of level curves on a single graph. We are interested in those points where two level curves are tangent—but there are many such points, in fact an infinite number, as we've only shown a few of the level curves. All along the line \(y=x\) are points at which two level curves are tangent. While this might seem to be a show-stopper, it is not.

The gradient of \(2x+2y\) is \(\langle 2,2\rangle\text{,}\) and the gradient of \(xy\) is \(\langle y,x\rangle\text{.}\) They are parallel when \(\langle 2,2\rangle=\lambda\langle y,x\rangle\text{,}\) that is, when \(2=\lambda y\) and \(2=\lambda x\text{.}\) We have two equations in three unknowns, which typically results in many solutions (as we expected). A third equation will reduce the number of solutions; the third equation is the original constraint, \(100=2x+2y\text{.}\) So we have the following system to solve:

In the first two equations, \(\lambda\) can't be 0, so we may divide by it to get \(x=y=2/\lambda\text{.}\) Substituting into the third equation we get

so \(x=y=25\text{.}\) Note that we are not really interested in the value of \(\lambda\)—it is a clever tool, the Lagrange multiplier, introduced to solve the problem. In many cases, as here, it is easier to find \(\lambda\) than to find everything else without using \(\lambda\text{.}\)

The same method works for functions of three variables, except of course everything is one dimension higher: the function to be optimized is a function of three variables and the constraint represents a surface—for example, the function may represent temperature, and we may be interested in the maximum temperature on some surface, like a sphere. The points we seek are those at which the constraint surface is tangent to a level surface of the function. Once again, we consider the constraint surface to be a level surface of some function, and we look for points at which the two gradients are parallel, giving us three equations in four unknowns. The constraint provides a fourth equation.

###### Example 7.56. Optimization with Constraints.

Maximize the function \(xyz\) given the constraint \(\ds 1=\sqrt{x^2+y^2+z^2}\text{.}\)

The constraint is \(\ds 1=\sqrt{x^2+y^2+z^2}\text{,}\) which is the same as \(1=x^2+y^2+z^2\text{.}\) The function to maximize is \(xyz\text{.}\) The two gradient vectors are \(\langle 2x,2y,2z\rangle\) and \(\langle yz,xz,xy\rangle\text{,}\) so the equations to be solved are

If \(\lambda=0\) then at least two of \(x\text{,}\) \(y\text{,}\) \(z\) must be 0, giving a volume of 0, which will not be the maximum. If we multiply the first two equations by \(x\) and \(y\) respectively, we get

so \(2x^2\lambda=2y^2\lambda\) or \(x^2=y^2\text{;}\) in the same way we can show \(x^2=z^2\text{.}\) Hence the fourth equation becomes \(1=x^2+x^2+x^2\) or \(x=1/\sqrt3\text{,}\) and so \(x=y=z=1/\sqrt3\) gives the maximum volume. This is of course the same answer we obtained previously.

Another possibility is that we have a function of three variables, and we want to find a maximum or minimum value not on a surface but on a curve; often the curve is the intersection of two surfaces, so that we really have two constraint equations, say \(g(x,y,z)=c_1\) and \(h(x,y,z)=c_2\text{.}\) It turns out that at points on the intersection of the surfaces where \(f\) has a maximum or minimum value,

As before, this gives us three equations, one for each component of the vectors, but now in five unknowns, \(x\text{,}\) \(y\text{,}\) \(z\text{,}\) \(\lambda\text{,}\) and \(\mu\text{.}\) Since there are two constraint functions, we have a total of five equations in five unknowns, and so can usually find the solutions we need.

###### Example 7.57. Intersection of a Plane with a Cylinder.

The plane \(x+y-z=1\) intersects the cylinder \(x^2+y^2=1\) in an ellipse. Find the points on the ellipse closest to and farthest from the origin.

We want the extreme values of \(f=\sqrt{x^2+y^2+z^2}\) subject to the constraints \(g=x^2+y^2=1\) and \(h=x+y-z=1\text{.}\) To simplify the algebra, we may use instead \(f=x^2+y^2+z^2\text{,}\) since this has a maximum or minimum value at exactly the points at which \(\sqrt{x^2+y^2+z^2}\) does. The gradients are

so the equations we need to solve are

Subtracting the first two we get \(2y-2x=\lambda(2y-2x)\text{,}\) so either \(\lambda=1\) or \(x=y\text{.}\) If \(\lambda=1\) then \(\mu=0\text{,}\) so \(z=0\) and the last two equations are

Solving these gives \(x=1\text{,}\) \(y=0\text{,}\) or \(x=0\text{,}\) \(y=1\text{,}\) so the points of interest are \((1,0,0)\) and \((0,1,0)\text{,}\) which are both distance 1 from the origin. If \(x=y\text{,}\) the fourth equation is \(2x^2=1\text{,}\) giving \(x=y=\pm1/\sqrt2\text{,}\) and from the fifth equation we get \(z=-1\pm\sqrt2\text{.}\) The distance from the origin to \((1/\sqrt2,1/\sqrt2,-1+\sqrt2)\) is \(\sqrt{4-2\sqrt2}\approx 1.08\) and the distance from the origin to \((-1/\sqrt2,-1/\sqrt2,-1-\sqrt2)\) is \(\sqrt{4+2\sqrt2}\approx 2.6\text{.}\) Thus, the points \((1,0,0)\) and \((0,1,0)\) are closest to the origin and \((-1/\sqrt2,-1/\sqrt2,-1-\sqrt2)\) is farthest from the origin.

##### Exercises for Section 7.7.

###### Exercise 7.7.1.

A six-sided rectangular box is to hold \(1/2\) cubic meter; what shape should the box be to minimize surface area?

Answera cube, \(\root 3 \of {1/2}\times\root 3 \of {1/2}\times\root 3 \of {1/2}\)

###### Exercise 7.7.2.

The post office will accept packages whose combined length and girth are at most 130 inches (girth is the maximum distance around the package perpendicular to the length). What is the largest volume that can be sent in a rectangular box?

Answer\(65/3\cdot 65/3\cdot 130/3=2\cdot 65^3/27\)

###### Exercise 7.7.3.

The bottom of a rectangular box costs twice as much per unit area as the sides and top. Find the shape for a given volume that will minimize cost.

AnswerIt has a square base, and is one and one half times as tall as wide. If the volume is \(V\) the dimensions are \(\root 3 \of {2V/3}\times \root 3 \of {2V/3}\times \root 3\of {9V/4}\text{.}\)

###### Exercise 7.7.4.

Using Lagrange multipliers, find the shortest distance from the point \((x_0,y_0,z_0)\) to the plane \(ax+by+cz=d\text{.}\)

Answer\(|ax_0+by_0+cz_0-d|/\sqrt{a^2+b^2+c^2}\)

###### Exercise 7.7.5.

Find all points on the surface \(xy-z^2+1=0\) that are closest to the origin.

Answer\((0,0,1)\text{,}\) \((0,0,-1)\)

###### Exercise 7.7.6.

The material for the bottom of an aquarium costs half as much as the high strength glass for the four sides. Find the shape of the cheapest aquarium that holds a given volume \(V\text{.}\)

Answer\(\root 3\of{4V}\times\root 3\of{4V}\times\root 3\of{V/16}\)

###### Exercise 7.7.7.

The plane \(x-y+z=2\) intersects the cylinder \(x^2+y^2=4\) in an ellipse. Find the points on the ellipse closest to and farthest from the origin.

AnswerFarthest: \((-\sqrt2,\sqrt2,2+2\sqrt2)\text{;}\) closest: \((2,0,0)\text{,}\) \((0,-2,0)\)

###### Exercise 7.7.8.

Find three positive numbers whose sum is 48 and whose product is as large as possible.

Answer\(x=y=z=16\)

###### Exercise 7.7.9.

Find all points on the plane \(x+y+z = 5\) in the first octant at which \(\ds f(x,y,z) = xy^2z^2\) has a maximum value.

Answer\((1,2,2)\)

###### Exercise 7.7.10.

Find the points on the surface \(x^2 -yz = 5\) that are closest to the origin.

Answer\(\ds (\sqrt{5},0,0)\text{,}\) \(\ds (-\sqrt{5},0,0)\)

###### Exercise 7.7.11.

A manufacturer makes two models of an item, standard and deluxe. It costs $40 to manufacture the standard model and $60 for the deluxe. A market research firm estimates that if the standard model is priced at \(x\) dollars and the deluxe at \(y\) dollars, then the manufacturer will sell \(500(y-x)\) of the standard items and \(45,000+500(x-2y)\) of the deluxe each year. How should the items be priced to maximize profit?

Answerstandard $65, deluxe $75

###### Exercise 7.7.12.

A length of sheet metal is to be made into a water trough by bending up two sides. Find \(x\) and \(\phi\) so that the trapezoid–shaped cross section has maximum area, when the width of the metal sheet is 27 inches (that is, \(2x+y=27\)).

Answer\(x=9\text{,}\) \(\phi=\pi/3\)

###### Exercise 7.7.13.

Find the maximum and minimum values of \(f(x,y,z)=6x+3y+2z\) subject to the constraint \(\ds g(x,y,z) = 4x^2+2y^2 + z^2 - 70 = 0\text{.}\)

Answer\(35\text{,}\) \(-35\)

###### Exercise 7.7.14.

Find the maximum and minimum values of \(f(x,y)=e^{xy}\) subject to the constraint \(g(x,y) = x^3+y^3 - 16 = 0\text{.}\)

Answermaximum \(e^4\text{,}\) no minimum

###### Exercise 7.7.15.

Find the maximum and minimum values of \(\ds f(x,y) = xy + \sqrt{9-x^2-y^2}\) when \(\ds x^2+y^2 \leq 9\text{.}\)

Answer\(5\text{,}\) \(-9/2\)

###### Exercise 7.7.16.

Find three real numbers whose sum is 9 and the sum of whose squares is a small as possible.

Answer\(3\text{,}\) \(3\text{,}\) \(3\)

###### Exercise 7.7.17.

Find the dimensions of the closed rectangular box with maximum volume that can be inscribed in the unit sphere.

Answera cube of side length \(\ds 2/\sqrt{3}\)