You appear to be on a device with a "narrow" screen width (i.e. you are probably on a mobile phone). Due to the nature of the mathematics on this site it is best views in landscape mode. If your device is not in landscape mode many of the equations will run off the side of your device (should be able to scroll to see them) and some of the menu items will be cut off due to the narrow screen width.

Section 3-5 : Lagrange Multipliers

In the previous section we optimized (i.e. found the absolute extrema) a function on a region that contained its boundary. Finding potential optimal points in the interior of the region isn’t too bad in general, all that we needed to do was find the critical points and plug them into the function. However, as we saw in the examples finding potential optimal points on the boundary was often a fairly long and messy process.

In this section we are going to take a look at another way of optimizing a function subject to given constraint(s). The constraint(s) may be the equation(s) that describe the boundary of a region although in this section we won’t concentrate on those types of problems since this method just requires a general constraint and doesn’t really care where the constraint came from.

So, let’s get things set up. We want to optimize (i.e. find the minimum and maximum value of) a function, \(f\left( {x,y,z} \right)\), subject to the constraint \(g\left( {x,y,z} \right) = k\). Again, the constraint may be the equation that describes the boundary of a region or it may not be. The process is actually fairly simple, although the work can still be a little overwhelming at times.

Method of Lagrange Multipliers

Plug in all solutions, \(\left( {x,y,z} \right)\), from the first step into \(f\left( {x,y,z} \right)\) and identify the minimum and maximum values, provided they exist and \(\nabla g \ne \vec{0}\) at the point.

The constant, \(\lambda \), is called the Lagrange Multiplier.

Notice that the system of equations from the method actually has four equations, we just wrote the system in a simpler form. To see this let’s take the first equation and put in the definition of the gradient vector to see what we get.

These three equations along with the constraint, \(g\left( {x,y,z} \right) = c\), give four equations with four unknowns \(x\), \(y\), \(z\), and \(\lambda \).

Note as well that if we only have functions of two variables then we won’t have the third component of the gradient and so will only have three equations in three unknowns \(x\), \(y\), and \(\lambda \).

As a final note we also need to be careful with the fact that in some cases minimums and maximums won’t exist even though the method will seem to imply that they do. In every problem we’ll need to make sure that minimums and maximums will exist before we start the problem.

To see a physical justification for the formulas above. Let’s consider the minimum and maximum value of \(f\left( {x,y} \right) = 8{x^2} - 2y\) subject to the constraint \({x^2} + {y^2} = 1\). In the practice problems for this section (problem #2 to be exact) we will show that minimum value of \(f\left( {x,y} \right)\) is -2 which occurs at \(\left( {0,1} \right)\) and the maximum value of \(f\left( {x,y} \right)\) is 8.125 which occurs at \(\left( { - \frac{{3\sqrt 7 }}{8}, - \frac{1}{8}} \right)\) and \(\left( {\frac{{3\sqrt 7 }}{8}, - \frac{1}{8}} \right)\).

Here is a sketch of the constraint as well as \(f\left( {x.y} \right) = k\) for various values of \(k\).

First remember that solutions to the system must be somewhere on the graph of the constraint, \({x^2} + {y^2} = 1\) in this case. Because we are looking for the minimum/maximum value of \(f\left( {x,y} \right)\) this, in turn, means that the location of the minimum/maximum value of \(f\left( {x,y} \right)\), i.e. the point \(\left( {x,y} \right)\), must occur where the graph of \(f\left( {x,y} \right) = k\) intersects the graph of the constraint when \(k\) is either the minimum or maximum value of \(f\left( {x,y} \right)\).

Now, we can see that the graph of \(f\left( {x,y} \right) = - 2\), i.e. the graph of the minimum value of \(f\left( {x,y} \right)\), just touches the graph of the constraint at \(\left( {0,1} \right)\). In fact, the two graphs at that point are tangent.

If the two graphs are tangent at that point then their normal vectors must be parallel, i.e. the two normal vectors must be scalar multiples of each other. Mathematically, this means,

for some scalar \(\lambda \) and this is exactly the first equation in the system we need to solve in the method.

Note as well that if \(k\) is smaller than the minimum value of \(f\left( {x,y} \right)\) the graph of \(f\left( {x,y} \right) = k\) doesn’t intersect the graph of the constraint and so it is not possible for the function to take that value of \(k\) at a point that will satisfy the constraint.

Likewise, if \(k\) is larger than the minimum value of \(f\left( {x,y} \right)\) the graph of \(f\left( {x,y} \right) = k\) will intersect the graph of the constraint but the two graphs are not tangent at the intersection point(s). This means that the method will not find those intersection points as we solve the system of equations.

Next, the graph below shows a different set of values of \(k\). In this case, the values of \(k\) include the maximum value of \(f\left( {x,y} \right)\) as well as a few values on either side of the maximum value.

Again, we can see that the graph of \(f\left( {x,y} \right) = 8.125\) will just touch the graph of the constraint at two points. This is a good thing as we know the solution does say that it should occur at two points. Also note that at those points again the graph of \(f\left( {x,y} \right) = 8.125\)and the constraint are tangent and so, just as with the minimum values, the normal vectors must be parallel at these points.

Likewise, for value of \(k\) greater than 8.125 the graph of \(f\left( {x,y} \right) = k\) does not intersect the graph of the constraint and so it will not be possible for \(f\left( {x,y} \right)\) to take on those larger values at points that are on the constraint.

Also, for values of \(k\) less than 8.125 the graph of \(f\left( {x,y} \right) = k\) does intersect the graph of the constraint but will not be tangent at the intersection points and so again the method will not produce these intersection points as we solve the system of equations.

So, with these graphs we’ve seen that the minimum/maximum values of \(f\left( {x,y} \right)\) will come where the graph of \(f\left( {x,y} \right) = k\) and the graph of the constraint are tangent and so their normal vectors are parallel. Also, because the point must occur on the constraint itself. In other words, the system of equations we need to solve to determine the minimum/maximum value of \(f\left( {x,y} \right)\) are exactly those given in the above when we introduced the method.

Note that the physical justification above was done for a two dimensional system but the same justification can be done in higher dimensions. The difference is that in higher dimensions we won’t be working with curves. For example, in three dimensions we would be working with surfaces. However, the same ideas will still hold. At the points that give minimum and maximum value(s) of the surfaces would be parallel and so the normal vectors would also be parallel.

Let’s work a couple of examples.

Example 1 Find the dimensions of the box with largest volume if the total surface area is 64 cm2.

Show Solution

Before we start the process here note that we also saw a way to solve this kind of problem in Calculus I, except in those problems we required a condition that related one of the sides of the box to the other sides so that we could get down to a volume and surface area function that only involved two variables. We no longer need this condition for these problems.

Now, let’s get on to solving the problem. We first need to identify the function that we’re going to optimize as well as the constraint. Let’s set the length of the box to be \(x\), the width of the box to be \(y\) and the height of the box to be \(z\). Let’s also note that because we’re dealing with the dimensions of a box it is safe to assume that \(x\), \(y\), and \(z\) are all positive quantities.

We want to find the largest volume and so the function that we want to optimize is given by,

\[f\left( {x,y,z} \right) = xyz\]

Next, we know that the surface area of the box must be a constant 64. So this is the constraint. The surface area of a box is simply the sum of the areas of each of the sides so the constraint is given by,

Note that we divided the constraint by 2 to simplify the equation a little. Also, we get the function \(g\left( {x,y,z} \right)\) from this.

\[g\left( {x,y,z} \right) = xy + xz + yz\]

The function itself, \(f\left( {x,y,z} \right) = xyz\) will clearly have neither minimums or maximums unless we put some restrictions on the variables. The only real restriction that we’ve got is that all the variables must be positive. This, of course, instantly means that the function does have a minimum, zero, even though this is a silly value as it also means we pretty much don’t have a box. It does however mean that we know minimum of \(f\left( {x,yz} \right)\) does exist.

So, let’s now see if \(f\left( {x,y,z} \right)\) will have a maximum. Clearly, hopefully, \(f\left( {x,y,z} \right)\) will not have a maximum if all the variables are allowed to increase without bound. That however, can’t happen because of the constraint,

\[xy + xz + yz = 32\]

Here we’ve got the sum of three positive numbers (remember that we \(x\), \(y\), and \(z\) are positive because we are working with a box) and the sum must equal 32. So, if one of the variables gets very large, say \(x\), then because each of the products must be less than 32 both \(y\) and \(z\) must be very small to make sure the first two terms are less than 32. So, there is no way for all the variables to increase without bound and so it should make some sense that the function, \(f\left( {x,y,z} \right) = xyz\), will have a maximum.

This is not an exact proof that \(f\left( {x,y,z} \right)\) will have a maximum but it should help to visualize that \(f\left( {x,y,z} \right)\) should have a maximum value as long as it is subject to the constraint.

There are many ways to solve this system. We’ll solve it in the following way. Let’s multiply equation \(\eqref{eq:eq1}\) by \(x\), equation \(\eqref{eq:eq2}\) by \(y\) and equation \(\eqref{eq:eq3}\) by \(z\). This gives,

However, we know that \(y\) must be positive since we are talking about the dimensions of a box. Therefore, the only solution that makes physical sense here is

\[x = y = z = \,3.266\]

So, it looks like we’ve got a cube.

We should be a little careful here. Since we’ve only got one solution we might be tempted to assume that these are the dimensions that will give the largest volume. Anytime we get a single solution we really need to verify that it is a maximum (or minimum if that is what we are looking for).

This is actually pretty simple to do. First, let’s note that the volume at our solution above is,

Now, we know that a maximum of \(f\left( {x,y,z} \right)\) will exist (“proved” that earlier in the solution) and so to verify that that this really is a maximum all we need to do if find another set of dimensions that satisfy our constraint and check the volume. If the volume of this new set of dimensions is smaller that the volume above then we know that our solution does give a maximum.

If, on the other hand, the new set of dimensions give a larger volume we have a problem. We only have a single solution and we know that a maximum exists and the method should generate that maximum. So, in this case, the likely issue is that we will have made a mistake somewhere and we’ll need to go back and find it.

So, let’s find a new set of dimensions for the box. The only thing we need to worry about is that they will satisfy the constraint. Outside of that there aren’t other constraints on the size of the dimensions. So, we can freely pick two values and then use the constraint to determine the third value.

Let’s choose \(x = y = 1\). No reason for these values other than they are “easy” to work with. Plugging these into the constraint gives,

So, the new dimensions give a smaller volume and so our solution above is, in fact, the dimensions that will give a maximum volume of the box are \(x = y = z = \,3.266\)

Notice that we never actually found values for \(\lambda \) in the above example. This is fairly standard for these kinds of problems. The value of \(\lambda \) isn’t really important to determining if the point is a maximum or a minimum so often we will not bother with finding a value for it. On occasion we will need its value to help solve the system, but even in those cases we won’t use it past finding the point.

This one is going to be a little easier than the previous one since it only has two variables. Also, note that it’s clear from the constraint that region of possible solutions lies on a disk of radius \(\sqrt {136} \) which is a closed and bounded region, \( - \sqrt {136} \le x,y \le \sqrt {136} \), and hence by the Extreme Value Theorem we know that a minimum and maximum value must exist.

Notice that, as with the last example, we can’t have \(\lambda = 0\) since that would not satisfy the first two equations. So, since we know that \(\lambda \ne 0\)we can solve the first two equations for \(x\) and \(y\) respectively. This gives,

Now, that we know \(\lambda \) we can find the points that will be potential maximums and/or minimums.

If \(\lambda = - \frac{1}{4}\) we get,

\[x = - 10\hspace{0.75in}y = 6\]

and if \(\lambda = \frac{1}{4}\) we get,

\[x = 10\hspace{0.75in}\hspace{0.25in}y = - 6\]

To determine if we have maximums or minimums we just need to plug these into the function. Also recall from the discussion at the start of this solution that we know these will be the minimum and maximums because the Extreme Value Theorem tells us that minimums and maximums will exist for this problem.

In the first two examples we’ve excluded \(\lambda = 0\) either for physical reasons or because it wouldn’t solve one or more of the equations. Do not always expect this to happen. Sometimes we will be able to automatically exclude a value of \(\lambda \) and sometimes we won’t.

First note that our constraint is a sum of three positive or zero number and it must be 1. Therefore, it is clear that our solution will fall in the range \(0 \le x,y,z \le 1\) and so the solution must lie in a closed and bounded region and so by the Extreme Value Theorem we know that a minimum and maximum value must exist.

Let’s start this solution process off by noticing that since the first three equations all have \(\lambda \) they are all equal. So, let’s start off by setting equations \(\eqref{eq:eq10}\) and \(\eqref{eq:eq11}\) equal.

So, we’ve got two possibilities here. Let’s start off with by assuming that \(z = 0\). In this case we can see from either equation \(\eqref{eq:eq10}\) or \(\eqref{eq:eq11}\) that we must then have \(\lambda = 0\). From equation \(\eqref{eq:eq12}\) we see that this means that \(xy = 0\). This in turn means that either \(x = 0\) or \(y = 0\).

So, we’ve got two possible cases to deal with there. In each case two of the variables must be zero. Once we know this we can plug into the constraint, equation \(\eqref{eq:eq13}\), to find the remaining value.

So, the next solution is \(\left( {\frac{1}{3},\frac{1}{3},\frac{1}{3}} \right)\).

We got four solutions by setting the first two equations equal.

To completely finish this problem out we should probably set equations \(\eqref{eq:eq10}\) and \(\eqref{eq:eq12}\) equal as well as setting equations \(\eqref{eq:eq11}\) and \(\eqref{eq:eq12}\) equal to see what we get. Doing this gives,

So, in this case the maximum occurs only once while the minimum occurs three times.

Note as well that we never really used the assumption that \(x,y,z \ge 0\) in the actual solution to the problem. We used it to make sure that we had a closed and bounded region to guarantee we would have absolute extrema. To see why this is important let's take a look at what might happen without this assumption Without this assumption it wouldn’t be too difficult to find points that give both larger and smaller values of the functions. For example.

With these examples you can clearly see that it’s not too hard to find points that will give larger and smaller function values. However, all of these examples required negative values of \(x\), \(y\) and/or \(z\) to make sure we satisfy the constraint. By eliminating these we will know that we’ve got minimum and maximum values by the Extreme Value Theorem.

Before we proceed we need to address a quick issue that the last example illustrates about the method of Lagrange Multipliers. We found the absolute minimum and maximum to the function. However, what we did not find is all the locations for the absolute minimum. For example, assuming \(x,y,z\ge 0\), consider the following sets of points.

Every point in this set of points will satisfy the constraint from the problem and in every case the function will evaluate to zero and so also give the absolute minimum.

So, what is going on? Recall from the previous section that we had to check both the critical points and the boundaries to make sure we had the absolute extrema. The same was true in Calculus I. We had to check both critical points and end points of the interval to make sure we had the absolute extrema.

It turns out that we really need to do the same thing here if we want to know that we’ve found all the locations of the absolute extrema. The method of Lagrange multipliers will find the absolute extrema, it just might not find all the locations of them as the method does not take the end points of variables ranges into account (note that we might luck into some of these points but we can’t guarantee that).

So, after going through the Lagrange Multiplier method we should then ask what happens at the end points of our variable ranges. For the example that means looking at what happens if \(x=0\), \(y=0\), \(z=0\), \(x=1\), \(y=1\), and \(z=1\). In the first three cases we get the points listed above that do happen to also give the absolute minimum. For the later three cases we can see that if one of the variables are 1 the other two must be zero (to meet the constraint) and those were actually found in the example. Sometimes that will happen and sometimes it won’t.

In the case of this example the end points of each of the variable ranges gave absolute extrema but there is no reason to expect that to happen every time. In Example 2 above, for example, the end points of the ranges for the variables do not give absolute extrema (we’ll let you verify this).

The moral of this is that if we want to know that we have every location of the absolute extrema for a particular problem we should also check the end points of any variable ranges that we might have. If all we are interested in is the value of the absolute extrema then there is no reason to do this.

Okay, it’s time to move on to a slightly different topic. To this point we’ve only looked at constraints that were equations. We can also have constraints that are inequalities. The process for these types of problems is nearly identical to what we’ve been doing in this section to this point. The main difference between the two types of problems is that we will also need to find all the critical points that satisfy the inequality in the constraint and check these in the function when we check the values we found using Lagrange Multipliers.

In this case, the minimum was interior to the disk and the maximum was on the boundary of the disk.

The final topic that we need to discuss in this section is what to do if we have more than one constraint. We will look only at two constraints, but we can naturally extend the work here to more than two constraints.

We want to optimize \(f\left( {x,y,z} \right)\) subject to the constraints \(g\left( {x,y,z} \right) = c\) and \(h\left( {x,y,z} \right) = k\). The system that we need to solve in this case is,

So, in this case we get two Lagrange Multipliers. Also, note that the first equation really is three equations as we saw in the previous examples. Let’s see an example of this kind of optimization problem.

Verifying that we will have a minimum and maximum value here is a little trickier. Clearly, because of the second constraint we’ve got to have \( - 1 \le x,y \le 1\). With this in mind there must also be a set of limits on \(z\) in order to make sure that the first constraint is met. If one really wanted to determine that range you could find the minimum and maximum values of \(2x - y\) subject to \({x^2} + {y^2} = 1\) and you could then use this to determine the minimum and maximum values of \(z\). We won’t do that here. The point is only to acknowledge that once again the
possible solutions must lie in a closed and bounded region and so minimum and maximum values must exist by the Extreme Value Theorem.

First, let’s notice that from equation \(\eqref{eq:eq16}\) we get \(\lambda = 2\). Plugging this into equation \(\eqref{eq:eq14}\) and equation \(\eqref{eq:eq15}\) and solving for \(x\) and \(y\) respectively gives,