## Section10.8Constrained Optimization: Lagrange Multipliers

We previously considered how to find the extreme values of functions on both unrestricted domains and on closed, bounded domains. Other types of optimization problems involve maximizing or minimizing a quantity subject to an external constraint. In these cases the extreme values frequently won't occur at the points where the gradient is zero, but rather at other points that satisfy an important geometric condition. These problems are often called constrained optimization problems and can be solved with the method of Lagrange Multipliers, which we study in this section.

###### Preview Activity10.8.1.

According to U.S. postal regulations, the girth plus the length of a parcel sent by mail may not exceed 108 inches, where by “girth” we mean the perimeter of the smallest end. Our goal is to find the largest possible volume of a rectangular parcel with a square end that can be sent by mail. (We solved this applied optimization problem in single variable Active Calculus, so it may look familiar. We take a different approach in this section, and this approach allows us to view most applied optimization problems from single variable calculus as constrained optimization problems, as well as provide us tools to solve a greater variety of optimization problems.) If we let $$x$$ be the length of the side of one square end of the package and $$y$$ the length of the package, then we want to maximize the volume $$f(x,y) = x^2y$$ of the box subject to the constraint that the girth ($$4x$$) plus the length ($$y$$) is as large as possible, or $$4x+y = 108\text{.}$$ The equation $$4x + y = 108$$ is thus an external constraint on the variables.

1. The constraint equation involves the function $$g$$ that is given by

\begin{equation*} g(x,y) = 4x+y. \end{equation*}

Explain why the constraint is a contour of $$g\text{,}$$ and is therefore a two-dimensional curve.

2. Figure 10.8.1 shows the graph of the constraint equation $$g(x,y) = 108$$ along with a few contours of the volume function $$f\text{.}$$ Since our goal is to find the maximum value of $$f$$ subject to the constraint $$g(x,y) = 108\text{,}$$ we want to find the point on our constraint curve that intersects the contours of $$f$$ at which $$f$$ has its largest value.

1. Points $$A$$ and $$B$$ in Figure 10.8.1 lie on a contour of $$f$$ and on the constraint equation $$g(x,y) = 108\text{.}$$ Explain why neither $$A$$ nor $$B$$ provides a maximum value of $$f$$ that satisfies the constraint.

2. Points $$C$$ and $$D$$ in Figure 10.8.1 lie on a contour of $$f$$ and on the constraint equation $$g(x,y) = 108\text{.}$$ Explain why neither $$C$$ nor $$D$$ provides a maximum value of $$f$$ that satisfies the constraint.

3. Based on your responses to parts i. and ii., draw the contour of $$f$$ on which you believe $$f$$ will achieve a maximum value subject to the constraint $$g(x,y) = 108\text{.}$$ Explain why you drew the contour you did.

3. Recall that $$g(x,y) = 108$$ is a contour of the function $$g\text{,}$$ and that the gradient of a function is always orthogonal to its contours. With this in mind, how should $$\nabla f$$ and $$\nabla g$$ be related at the optimal point? Explain.

### Subsection10.8.1Constrained Optimization and Lagrange Multipliers

In Preview Activity 10.8.1, we considered an optimization problem where there is an external constraint on the variables, namely that the girth plus the length of the package cannot exceed 108 inches. We saw that we can create a function $$g$$ from the constraint, specifically $$g(x,y) = 4x+y\text{.}$$ The constraint equation is then just a contour of $$g\text{,}$$ $$g(x, y) = c\text{,}$$ where $$c$$ is a constant (in our case 108). Figure 10.8.2 illustrates that the volume function $$f$$ is maximized, subject to the constraint $$g(x, y) = c\text{,}$$ when the graph of $$g(x, y) = c$$ is tangent to a contour of $$f\text{.}$$ Moreover, the value of $$f$$ on this contour is the sought maximum value.

To find this point where the graph of the constraint is tangent to a contour of $$f\text{,}$$ recall that $$\nabla f$$ is perpendicular to the contours of $$f$$ and $$\nabla g$$ is perpendicular to the contour of $$g\text{.}$$ At such a point, the vectors $$\nabla g$$ and $$\nabla f$$ are parallel, and thus we need to determine the points where this occurs. Recall that two vectors are parallel if one is a nonzero scalar multiple of the other, so we therefore look for values of a parameter $$\lambda$$ that make

$$\nabla f = \lambda \nabla g.\label{eq_10_8_Lagrange_ex1}\tag{10.8.1}$$

The constant $$\lambda$$ is called a Lagrange multiplier.

To find the values of $$\lambda$$ that satisfy (10.8.1) for the volume function in Preview Activity 10.8.1, we calculate both $$\nabla f$$ and $$\nabla g\text{.}$$ Observe that

\begin{equation*} \nabla f = 2xy \vi + x^2 \vj \ \ \ \ \text{ and } \ \ \ \ \nabla g = 4\vi + \vj, \end{equation*}

and thus we need a value of $$\lambda$$ so that

\begin{equation*} 2xy \vi + x^2 \vj = \lambda(4\vi + \vj). \end{equation*}

Equating components in the most recent equation and incorporating the original constraint, we have three equations

\begin{align} 2xy \amp = \lambda (4) \label{eq_10_8_lag_ex1}\tag{10.8.2}\\ x^2 \amp = \lambda (1) \label{eq_10_8_lag_ex2}\tag{10.8.3}\\ 4x+y \amp = 108 \label{eq_10_8_lag_ex3}\tag{10.8.4} \end{align}

in the three unknowns $$x\text{,}$$ $$y\text{,}$$ and $$\lambda\text{.}$$ First, note that if $$\lambda = 0\text{,}$$ then equation (10.8.3) shows that $$x=0\text{.}$$ From this, Equation (10.8.4) tells us that $$y = 108\text{.}$$ So the point $$(0,108)$$ is a point we need to consider. Next, provided that $$\lambda \neq 0$$ (from which it follows that $$x \neq 0$$ by Equation (10.8.3)), we may divide both sides of Equation (10.8.2) by the corresponding sides of (10.8.3) to eliminate $$\lambda\text{,}$$ and thus find that

\begin{align*} \frac{2y}{x} \amp = 4, \ \mbox{so}\\ y \amp = 2x. \end{align*}

Substituting into Equation (10.8.4) gives us

\begin{equation*} 4x+2x = 108 \end{equation*}

or

\begin{equation*} x = 18. \end{equation*}

Thus we have $$y = 2x = 36$$ and $$\lambda = x^2 = 324$$ as another point to consider. So the points at which the gradients of $$f$$ and $$g$$ are parallel, and thus at which $$f$$ may have a maximum or minimum subject to the constraint, are $$(0,108)$$ and $$(18,36)\text{.}$$ By evaluating the function $$f$$ at these points, we see that we maximize the volume when the length of the square end of the box is 18 inches and the length is 36 inches, for a maximum volume of $$f(18,36) = 11664$$ cubic inches. Since $$f(0,108) = 0\text{,}$$ we obtain a minimum value at this point.

We summarize the process of Lagrange multipliers as follows.

###### The method of Lagrange multipliers.

The general technique for optimizing a function $$f = f(x,y)$$ subject to a constraint $$g(x,y)=c$$ is to solve the system $$\nabla f = \lambda \nabla g$$ and $$g(x,y)=c$$ for $$x\text{,}$$ $$y\text{,}$$ and $$\lambda\text{.}$$ We then evaluate the function $$f$$ at each point $$(x,y)$$ that results from a solution to the system in order to find the optimum values of $$f$$ subject to the constraint.

###### Activity10.8.2.

A cylindrical soda can holds about 355 cc of liquid. In this activity, we want to find the dimensions of such a can that will minimize the surface area. For the sake of simplicity, assume the can is a perfect cylinder.

1. What are the variables in this problem? Based on the context, what restriction(s), if any, are there on these variables?

2. What quantity do we want to optimize in this problem? What equation describes the constraint? (You need to decide which of these functions plays the role of $$f$$ and which plays the role of $$g$$ in our discussion of Lagrange multipliers.)

3. Find $$\lambda$$ and the values of your variables that satisfy Equation (10.8.1) in the context of this problem.

4. Determine the dimensions of the pop can that give the desired solution to this constrained optimization problem.

The method of Lagrange multipliers also works for functions of more than two variables.

###### Activity10.8.3.

Use the method of Lagrange multipliers to find the dimensions of the least expensive packing crate with a volume of 240 cubic feet when the material for the top costs $2 per square foot, the bottom is$3 per square foot and the sides are \$1.50 per square foot.

The method of Lagrange multipliers also works for functions of three variables. That is, if we have a function $$f = f(x,y,z)$$ that we want to optimize subject to a constraint $$g(x,y,z) = k\text{,}$$ the optimal point $$(x,y,z)$$ lies on the level surface $$S$$ defined by the constraint $$g(x,y,z) = k\text{.}$$ As we did in Preview Activity 10.8.1, we can argue that the optimal value occurs at the level surface $$f(x,y,z) = c$$ that is tangent to $$S\text{.}$$ Thus, the gradients of $$f$$ and $$g$$ are parallel at this optimal point. So, just as in the two variable case, we can optimize $$f = f(x,y,z)$$ subject to the constraint $$g(x,y,z) = k$$ by finding all points $$(x,y,z)$$ that satisfy $$\nabla f = \lambda \nabla g$$ and $$g(x,y,z) = k\text{.}$$

### Subsection10.8.2Summary

• The extrema of a function $$f=f(x,y)$$ subject to a constraint $$g(x,y) = c$$ occur at points for which the contour of $$f$$ is tangent to the curve that represents the constraint equation. This occurs when

\begin{equation*} \nabla f = \lambda \nabla g. \end{equation*}
• We use the condition $$\nabla f = \lambda \nabla g$$ to generate a system of equations, together with the constraint $$g(x,y) = c\text{,}$$ that may be solved for $$x\text{,}$$ $$y\text{,}$$ and $$\lambda\text{.}$$ Once we have all the solutions, we evaluate $$f$$ at each of the $$(x,y)$$ points to determine the extrema.

### Exercises10.8.3Exercises

###### 1.

Use Lagrange multipliers to find the maximum and minimum values of $$f(x,y) = 3 x - 4 y$$ subject to the constraint $$x^2 + 3 y^2 = 129\text{,}$$ if such values exist.

maximum =

minimum =

(For either value, enter DNE if there is no such value.)

$$3\cdot 3\cdot 3+4\cdot 4$$

$$-3\cdot 3\cdot 3-4\cdot 4$$

###### 2.

Use Lagrange multipliers to find the maximum and minimum values of $$f(x,y) = x^2 y + 3 y^2 - y\text{,}$$ subject to the constraint $$x^2 + y^2 \leq 38.3333333333333$$

maximum =

minimum =

(For either value, enter DNE if there is no such value.)

$$137.926$$

$$-59.2593$$

###### 3.

Find the absolute maximum and minimum of the function $$f(x,y) = x^2 + y^2$$ subject to the constraint $$x^4 + y^4 = 6561\text{.}$$

As usual, ignore unneeded answer blanks, and list points in lexicographic order.

Absolute minimum value:

attained at (, ), (, ),

(, ), (, ).

Absolute maximum value:

attained at (, ), (, ),

(, ), (, ).

$$81$$

$$-9$$

$$0$$

$$0$$

$$-9$$

$$0$$

$$9$$

$$9$$

$$0$$

$$114.551298552221$$

$$-7.56806773728343$$

$$-7.56806773728343$$

$$-7.56806773728343$$

$$7.56806773728343$$

$$7.56806773728343$$

$$-7.56806773728343$$

$$7.56806773728343$$

$$7.56806773728343$$

###### 4.

Find the absolute maximum and minimum of the function $$f(x,y) = x^2 - y^2$$ subject to the constraint $$x^2 + y^2 = 361\text{.}$$

As usual, ignore unneeded answer blanks, and list points in lexicographic order.

Absolute minimum value:

attained at (, ) and (, ).

Absolute maximum value:

attained at (, ) and (, ).

$$-361$$

$$0$$

$$-19$$

$$0$$

$$19$$

$$361$$

$$-19$$

$$0$$

$$19$$

$$0$$

###### 5.

Find the minimum distance from the point $$(1,1,11)$$ to the paraboloid given by the equation $$z=x^2+y^2\text{.}$$

Minimum distance =

Note: If you need to find roots of a polynomial of degree $$\geq 3\text{,}$$ you may want to use a calculator of computer to do so numerically. Also be sure that you can give a geometric justification for your answer.

$$\sqrt{3.53771}$$

###### 6.

For each value of $$\lambda$$ the function $$h(x,y) = x^2 + y^2 - \lambda(2 x + 8 y - 20)$$ has a minimum value $$m(\lambda)\text{.}$$

(a) Find $$m(\lambda)$$

$$m(\lambda) =$$

(Use the letter L for $$\lambda$$ in your expression.)

(b) For which value of $$\lambda$$ is $$m(\lambda)$$ the largest, and what is that maximum value?

$$\lambda =$$

maximum $$m(\lambda) =$$

(c) Find the minimum value of $$f(x,y)=x^2+y^2$$ subject to the constraint $$2 x + 8 y = 20$$ using the method of Lagrange multipliers and evaluate $$\lambda\text{.}$$

minimum $$f$$ =

$$\lambda =$$

(How are these results related to your result in part (b)?)

$$20L-\frac{\left(2\cdot 2+8\cdot 8\right)L^{2}}{4}$$

$$\frac{2\cdot 20}{2\cdot 2+8\cdot 8}$$

$$\frac{20\cdot 20}{2\cdot 2+8\cdot 8}$$

$$\frac{20\cdot 20}{2\cdot 2+8\cdot 8}$$

$$\frac{2\cdot 20}{2\cdot 2+8\cdot 8}$$

###### 7.

The plane $$x + y + 2z = 6$$ intersects the paraboloid $$z = x^2 + y^2$$ in an ellipse. Find the points on this ellipse that are nearest to and farthest from the origin.

Point farthest away occurs at

(, ,).

Point nearest occurs at

(, ,).

$$-1.5$$

$$-1.5$$

$$4.5$$

$$1$$

$$1$$

$$2$$

###### 8.

Find the maximum and minimum values of the function $$f(x,y,z) = x^2 y^2 z^2$$ subject to the constraint $$x^2 + y^2 + z^2 = 64\text{.}$$

Maximum value is , occuring at points (positive integer or "infinitely many").

Minimum value is , occuring at points (positive integer or "infinitely many").

$$9709.03703703704$$

$$8$$

$$0$$

infinitely many

###### 9.

Find the maximum and minimum values of the function $$f(x,y,z,t) = x+y+z+t$$ subject to the constraint $$x^2 + y^2 + z^2 + t^2 = 100\text{.}$$

Maximum value is , occuring at points (positive integer or "infinitely many").

Minimum value is , occuring at points (positive integer or "infinitely many").

$$20$$

$$1$$

$$-20$$

$$1$$

###### 10.

Find the maximum and minimum volumes of a rectangular box whose surface area equals 7000 square cm and whose edge length (sum of lengths of all edges) is 440 cm.

Hint: It can be deduced that the box is not a cube, so if x, y, and z are the lengths of the sides, you may want to let x represent a side with $$x \ne y$$ and $$x \ne z\text{.}$$

Maximum value is ,

occuring at (, ,).

Minimum value is ,

occuring at (, ,).

$$34481.4814814815$$

$$63.3333333333333$$

$$23.3333333333333$$

$$23.3333333333333$$

$$25000$$

$$10$$

$$50$$

$$50$$

###### 11.

(a) If $$\sum_{i=1}^3 x_i = 4\text{,}$$ find the values of $$x_1, x_2, x_3$$ making $$\sum_{i=1}^3 {x_i}^2$$ minimum.

$$x_1, x_2, x_3 =$$

(Give your values as a comma separated list.)

(b) Generalize the result of part (a) to find the minimum value of $$\sum_{i=1}^n{x_i}^2$$ subject to $$\sum_{i=1}^n x_i=4\text{.}$$

minimum value =

$$1.33333, 1.33333, 1.33333$$

$$\frac{4\cdot 4}{n}$$

###### 12.

The Cobb-Douglas production function is used in economics to model production levels based on labor and equipment. Suppose we have a specific Cobb-Douglas function of the form

\begin{equation*} f(x, y) = 50 x^{0.4}y^{0.6}, \end{equation*}

where $$x$$ is the dollar amount spent on labor and $$y$$ the dollar amount spent on equipment. Use the method of Lagrange multipliers to determine how much should be spent on labor and how much on equipment to maximize productivity if we have a total of 1.5 million dollars to invest in labor and equipment.

###### 13.

Use the method of Lagrange multipliers to find the point on the line $$x-2y=5$$ that is closest to the point $$(1,3)\text{.}$$ To do so, respond to the following prompts.

1. Write the function $$f=f(x,y)$$ that measures the square of the distance from $$(x,y)$$ to $$(1,3)\text{.}$$ (The extrema of this function are the same as the extrema of the distance function, but $$f(x,y)$$ is simpler to work with.)

2. What is the constraint $$g(x,y) = c\text{?}$$

3. Write the equations resulting from $$\nabla f = \lambda \nabla g$$ and the constraint. Find all the points $$(x,y)$$ satisfying these equations.

4. Test all the points you found to determine the extrema.

###### 14.

Apply the Method of Lagrange Multipliers solve each of the following constrained optimization problems.

1. Determine the absolute maximum and absolute minimum values of $$f(x,y) = (x-1)^2 + (y-2)^2$$ subject to the constraint that $$x^2 + y^2 = 16\text{.}$$

2. Determine the points on the sphere $$x^2 + y^2 + z^2 = 4$$ that are closest to and farthest from the point $$(3,1,-1)\text{.}$$ (As in the preceding exercise, you may find it simpler to work with the square of the distance formula, rather than the distance formula itself.)

3. Find the absolute maximum and minimum of $$f(x,y,z) = x^2 + y^2 + z^2$$ subject to the constraint that $$(x-3)^2 + (y+2)^2 + (z-5)^2 \le 16\text{.}$$ (Hint: here the constraint is a closed, bounded region. Use the boundary of that region for applying Lagrange Multipliers, but don't forget to also test any critical values of the function that lie in the interior of the region.)

###### 15.

In this exercise we consider how to apply the Method of Lagrange Multipliers to optimize functions of three variable subject to two constraints. Suppose we want to optimize $$f = f(x,y,z)$$ subject to the constraints $$g(x,y,z) = c$$ and $$h(x,y,z) = k\text{.}$$ Also suppose that the two level surfaces $$g(x,y,z) = c$$ and $$h(x,y,z) = k$$ intersect at a curve $$C\text{.}$$ The optimum point $$P = (x_0,y_0,z_0)$$ will then lie on $$C\text{.}$$

1. Assume that $$C$$ can be represented parametrically by a vector-valued function $$\vr = \vr(t)\text{.}$$ Let $$\overrightarrow{OP} = \vr(t_0)\text{.}$$ Use the Chain Rule applied to $$f(\vr(t))\text{,}$$ $$g(\vr(t))\text{,}$$ and $$h(\vr(t))\text{,}$$ to explain why

\begin{align*} \nabla f(x_0,y_0,z_0) \cdot \vr'(t_0) \amp = 0, \\ \nabla g(x_0,y_0,z_0) \cdot \vr'(t_0) \amp = 0, \text{ and } \\ \nabla h(x_0,y_0,z_0) \cdot \vr'(t_0) \amp = 0. \end{align*}

Explain how this shows that $$\nabla f(x_0,y_0,z_0)\text{,}$$ $$\nabla g(x_0,y_0,z_0)\text{,}$$ and $$\nabla h(x_0,y_0,z_0)$$ are all orthogonal to $$C$$ at $$P\text{.}$$ This shows that $$\nabla f(x_0,y_0,z_0)\text{,}$$ $$\nabla g(x_0,y_0,z_0)\text{,}$$ and $$\nabla h(x_0,y_0,z_0)$$ all lie in the same plane.

2. Assuming that $$\nabla g(x_0,y_0,z_0)$$ and $$\nabla h(x_0,y_0,z_0)$$ are nonzero and not parallel, explain why every point in the plane determined by $$\nabla g(x_0,y_0,z_0)$$ and $$\nabla h(x_0,y_0,z_0)$$ has the form $$s\nabla g(x_0,y_0,z_0)+t\nabla h(x_0,y_0,z_0)$$ for some scalars $$s$$ and $$t\text{.}$$

3. Parts (a.) and (b.) show that there must exist scalars $$\lambda$$ and $$\mu$$ such that

\begin{equation*} \nabla f(x_0,y_0,z_0) = \lambda \nabla g(x_0,y_0,z_0)+ \mu \nabla h(x_0,y_0,z_0). \end{equation*}

So to optimize $$f = f(x,y,z)$$ subject to the constraints $$g(x,y,z) = c$$ and $$h(x,y,z) = k$$ we must solve the system of equations

\begin{align*} \nabla f(x,y,z) \amp = \lambda \nabla g(x,y,z)+ \mu \nabla h(x,y,z), \\ g(x,y,z) \amp = c, \text{ and } \\ h(x,y,z) \amp = k. \end{align*}

for $$x\text{,}$$ $$y\text{,}$$ $$z\text{,}$$ $$\lambda\text{,}$$ and $$\mu\text{.}$$

Use this idea to find the maximum and minium values of $$f(x,y,z) = x+2y$$ subject to the constraints $$y^2+z^2=8$$ and $$x+y+z = 10\text{.}$$

###### 16.

There is a useful interpretation of the Lagrange multiplier $$\lambda\text{.}$$ Assume that we want to optimize a function $$f$$ with constraint $$g(x,y)=c\text{.}$$ Recall that an optimal solution occurs at a point $$(x_0, y_0)$$ where $$\nabla f = \lambda \nabla g\text{.}$$ As the constraint changes, so does the point at which the optimal solution occurs. So we can think of the optimal point as a function of the parameter $$c\text{,}$$ that is $$x_0 = x_0(c)$$ and $$y_0=y_0(c)\text{.}$$ The optimal value of $$f$$ subject to the constraint can then be considered as a function of $$c$$ defined by $$f(x_0(c), y_0(c))\text{.}$$ The Chain Rule shows that

\begin{equation*} \frac{df}{dc} = \frac{\partial f}{\partial x_0} \frac{dx_0}{dc} + \frac{\partial f}{\partial y_0} \frac{dy_0}{dc}. \end{equation*}
1. Use the fact that $$\nabla f = \lambda \nabla g$$ at $$(x_0,y_0)$$ to explain why

\begin{equation*} \frac{df}{dc} = \lambda \frac{dg}{dc}. \end{equation*}
2. Use the fact that $$g(x,y) = c$$ to show that

\begin{equation*} \frac{df}{dc} = \lambda. \end{equation*}

Conclude that $$\lambda$$ tells us the rate of change of the function $$f$$ as the parameter $$c$$ increases (or by approximately how much the optimal value of the function $$f$$ will change if we increase the value of $$c$$ by 1 unit).

3. Suppose that $$\lambda = 324$$ at the point where the package described in Preview Activity 10.8.1 has its maximum volume. Explain in context what the value $$324$$ tells us about the package.

4. Suppose that the maximum value of a function $$f = f(x,y)$$ subject to a constraint $$g(x,y) = 100$$ is $$236\text{.}$$ When using the method of Lagrange multipliers and solving $$\nabla f = \lambda \nabla g\text{,}$$ we obtain a value of $$\lambda = 15$$ at this maximum. Find an approximation to the maximum value of $$f$$ subject to the constraint $$g(x,y) = 98\text{.}$$