Skip to main content

Section 4.8 Lagrange Multipliers

References.

Introduction.

We often wish to find the optimum value of some quantity (like designing a car of minimum weight, or maximum fuel efficiency) subject to various constraints (like sufficient strength and passenger capacity).
For example, we might wish to design a rectangular box of volume one cubic metre with minimum surface area. This involves choosing values of the three dimensions \(x\text{,}\) \(y\text{,}\) and \(z\) of the box such that
  • \(V(x,y,z)=xyz=1\) and
  • \(A(x,y,z)=2xy+2xz+2yz\) is minimized.
There is also the restriction that \(x\text{,}\) \(y\) and \(z\) must be positive, which determines the domain of functions \(A\) and \(V\text{.}\)

Topics.

Subsection 4.8.1 Finding the Extrema Values on a Curve of a Function of Two Variables

There is a geometrical approach to such problems, most easily seen in two dimensions.
The problem then is to find the maximum of minimum of function \(F(x,y)\) over points \((x,y)\) lying on a level curve of a function \(G\text{:}\) \(G(x,y)=k\text{,}\) for some given constant \(k\text{.}\) At a typical point \((x_0,y_0)\) of this level curve, the level curve \(F(x,y)=F(x_0,y_0)\) that passes through the same point crosses the level set of \(G\text{.}\)
Thus, moving along the set \(G(x,y)=k\text{,}\) one can get to either side of this level curve of \(F\text{,}\) and the two sides given higher and lower values of \(F\text{.}\)
Therefore, the value of \(F\) is not at a maximum or minimum at such a point \((x_0,y_0)\text{,}\) amongst points with \(G(x,y)=k\text{.}\)
By elimination, an extremum of \(F\) on the level curve \(G(x,y)=k\) can only occur at a point where the two level curves do not cross, but are "tangent", and this can only happen when they have the same tangent direction, and thus the same normal direction. The normal vectors are given by the gradients, so the necessary condition for an extremum of \(F\) under the constraint that \(G(x_0,y_0)=0\) is
\begin{equation} \del F(x_0,y_0) = \lambda \del G(x_0,y_0) \quad \text{ for some value of } \lambda.\tag{4.8.1} \end{equation}
The factor \(\lambda\) is the Lagrange Multiplier, which gives this method its name. The same result can be derived purely with calculus, and in a form that also works with functions of any number of variables. Note: it is typical to fold the constant \(k\) into function \(G\) so that the constraint is \(G=0\text{,}\) but it is nicer in some examples to leave in the \(k\text{,}\) so I do that.

Deriving Necessary Condition \(\del F = \lambda \del G\) from Calculus.

The necessary condition for a local extremum of \(F\) on the set \(G(x,y)=k\) can also be derived by calculus.
Suppose a local extremum occurs at point \((x_0,y_0)\) and consider the generic case that neither \(G_x(x_0,y_0)\) nor \(G_y(x_0,y_0)\) is zero there.
By the Implicit Function Theorem Theorem 4.5.5, there is a solution \(y=g(x)\) of \(G(x,y)=k\) near a point where \(F\) has a local maximum [minimum].
Points \((x,g(x))\) satisfy the constraint, so \(F(x_0,y_0)\) being a local maximum [minimum] means that \(f(x)=F(x,g(x))\) has a local maximum [minimum] at \(x_0\text{,}\) and so has a critical point.
The Chain Rule and implicit differentiation give
\begin{equation*} 0 = \frac{df}{dx} = \frac{\partial F}{\partial x}\frac{dx}{dx}+ \frac{\partial F}{\partial y}\frac{d y}{d x} = F_x + F_y \frac{-G_x}{G_y} \end{equation*}
so
\begin{equation*} F_x G_y=F_y G_x \quad \mbox{or} \quad \frac{F_x}{G_x} = \frac{F_y}{G_y} \mbox{, at } \end{equation*}
Thus at \((x_0,y_0)\text{,}\) \(\del F = \vector{F_x,F_y}\) is a multiple of \(\del G = \vector{G_x,G_y}\text{.}\) The special case where one of \(G_x(x_0,y_0)\) or \(G_y(x_0,y_0)\) is zero can also be handled: one can always get \(F_x G_y=F_y G_x\text{,}\) which says that the two vectors are parallel.

The Augmented Function \(F + \lambda (k-G)\).

For differentiable functions \(F\) and \(G\text{,}\) the above conditions \(\del F= \lambda \del G\) and \(G=k\) are exactly the conditions for a critical point of the augmented function \(H = F + \lambda (k-G)\text{;}\) that is, solutions of \(\del H(x,y,\lambda) = 0\text{.}\)
Aside: If the constraint is in form \(G=0\text{,}\) the augmented function is \(H = F - \lambda G\text{.}\)
To see this, note that the critical points of \(H\) are given by
\begin{equation*} \frac{\partial H}{\partial x} = \frac{\partial F}{\partial x} - \lambda \frac{\partial G}{\partial x} = 0, \quad \frac{\partial H}{\partial y} = \frac{\partial F}{\partial y} - \lambda \frac{\partial G}{\partial y} = 0, \end{equation*}
\begin{equation*} \frac{\partial H}{\partial y} = k-G = 0. \end{equation*}
The first two equations are equivalent to \(\del F - \lambda \del G = 0\text{;}\) the last is \(G(x,y)(x,y,z)=k\text{.}\)

The System of Equations to Solve.

Although the form \(\del [F+\lambda (k-G)] = 0\) can be easier to remember, and redefining \(G\) so that \(k=0\) gives the even simpler form
\begin{equation*} \del (F-\lambda G) = 0. \end{equation*}
In practice one can work with the component equations
\begin{equation} F_x(x,y)=\lambda G_x(x,y),\; F_y(x,y)=\lambda G_y(x,y),\; G(x,y)=k.\tag{4.8.2} \end{equation}
Since in the end only the value of \(x\) and \(y\) are needed, one approach is to eliminate \(\lambda\) by multiplying the first two equations by \(G_y(x,y)\) and \(G_x(x,y)\) respectively, getting
\begin{equation*} F_x(x,y) G_y(x,y) = \lambda G_x(x,y) G_y(x,y) = F_y(x,y) G_x(x,y) \end{equation*}
so that
\begin{equation} F_x(x,y) G_y(x,y) - F_y(x,y) G_x(x,y) = \left| \begin{array}{cc}F_x(x,y) \amp F_y(x,y) \\ G_x(x,y) \amp G_y(x,y) \end{array} \right| = 0.\tag{4.8.3} \end{equation}
This single equation involving a 2-by-2 determinant is then combined with the constraint equation \(G(x,y)=k\) to get two equations in the two relevant unknowns \(x\) and \(y\text{.}\)
Another way to see this result is to think of the gradients as the vectors \(\del F = F_x \veci + F_y \vecj\) and \(\del G = G_x \veci + G_y \vecj\) in \(\reals^3\text{;}\) then the condition of them being parallel is that they have zero cross product, and that multiplication gives
\begin{equation*} (F_x \veci + F_y \vecj) \times (G_x \veci + G_y \vecj) = \left| \begin{array}{cc}F_x(x,y) \amp F_y(x,y) \\ G_x(x,y) \amp G_y(x,y) \end{array} \right| \veck = 0. \end{equation*}

Subsection 4.8.2 Finding the Extrema Values on a Surface of a Function of Three Variables

A very similar argument using the implicit function theorem shows that for differentiable functions \(F\) and \(G\) of any number of variables, \(F\) can only have its maximum or minimum values over the set defined by equation \(G(x,y)=k\) at points where \(\del F\) and \(\del G\) are parallel, which can again be expressed as
\begin{equation} \del F = \lambda \del G\tag{4.8.4} \end{equation}

Example 4.8.1. The box of smallest area for given volume is a cube.

Consider the problem of designing a rectangular box of specified volume \(V=xyz\) and minimum surface area \(A=2xy+2xz+2yz\text{:}\)
\(F(x,y,z)=2(xy+xz+yz)\) is to be minimized under the constraint \(G(x,y,z)=xyz-V=0\text{.}\)
The conditions on the three components of the gradients are
\begin{equation*} 2(y+z)=\lambda y z,\; 2(x+z)=\lambda x z,\; 2(x+y)=\lambda x y \end{equation*}
Multiplying these by \(x\text{,}\) \(y\) and \(z\) respectively gives
\begin{equation} V = xyz = \lambda 2x(y+z) = \lambda 2y(x+z) = \lambda 2z(x+y).\tag{4.8.5} \end{equation}
Eliminating the Lagrange multiplier \(\lambda\) as soon as possible is usually a good idea, since it is not part of the final answer, and we can do that now: from (4.8.5) and the fact that \(V \neq 0\text{,}\) we see that \(\lambda \neq 0\text{,}\) giving
\begin{equation*} xy+xz = yx+yz = zx+zy. \end{equation*}
The first equality gives \(xz=yz\) and since \(z \neq 0\text{,}\) this gives \(x=y\text{;}\) similarly, \(y=z\text{,}\) so \(x=y=z\text{:}\) a cube, as claimed.
Finally, the constraint \(xyz=V\) gives the dimensions as \(x=y=z=\sqrt[3]{V}\text{,}\) and so the minimum area is \(A=2xy+2xz+2yz = 6(\sqrt[3]{V})^2=6V^{2/3}\text{.}\) This is the only possible extremum, so must give the desired minimum of area: for any size, the optimal shape is a cube.

Example 4.8.2. The open-topped box of minimum surface area for a given volume is a half cube (half as high as wide).

Consider the problem of designing a rectangular open topped box of width \(x\text{,}\) depth \(y\text{,}\) and height \(z\) that minimizes surface area \(A=xy+2xz+2yz\) while having a prescribed volume \(V=xyz\text{,}\) say \(V=4\text{:}\)
\(A=F(x,y,z)=xy+2xz+2yz\) is to be minimized under the constraint \(G(x,y,z)=xyz=V\text{,}\) \(V\) constant. The condition on the the gradients is \(\del A = \lambda \del G\text{,}\) or
\begin{equation*} y+2z= \lambda yz ,\; x+2z = \lambda xz,\; 2x+2y = \lambda xy. \end{equation*}
Multiplying these by \(x\text{,}\) \(y\text{,}\) and \(z\) respectively gives
\begin{equation} \lambda xyz = xy+2xz = xy+2yz = 2xz+2yz.\tag{4.8.6} \end{equation}
Again, eliminate the Lagrange multiplier \(\lambda\) as soon as possible; using the last two of the equations above:
\begin{align} xy+2xz \amp= xy+2yz\tag{4.8.7}\\ xy+2xz \amp= 2xz+2yz.\tag{4.8.8} \end{align}
To avoid division by zero, note that \(xyz=V>0\text{,}\) so none of \(x\text{,}\) \(y\) or \(z\) can be zero.
From Equation (4.8.7) we get \(x=y\text{:}\) the bottom is square.
Then Equation (4.8.8) becomes \(x^2+2xz = 4xz\text{,}\) so \(x=2z\text{:}\) the height is half the horizontal dimensions; a half-cube.
Finally, the volume constraint \(xyz=V=4\) becomes \(x^3/2=V=4\text{,}\) so \(x = y = \sqrt[3]{2V}=2\text{,}\) \(z=x/2=1.\)

Example 4.8.3. The open-topped box of greatest volume for a given surface area is again a half cube.

Consider now the related problem of designing a rectangular open topped box of width \(x\text{,}\) depth \(y\text{,}\) and height \(z\text{,}\) but this time specifying the value of the surface area \(A=xy+2xz+2yz\) and maximizing the volume \(V=xyz\text{:}\)
\(F(x,y,z)=V=xyz\) is to be maximized under the constraint \(G(x,y,z)=xy+2xz+2yz=A\text{,}\) \(A\) constant (say \(A=12\)).
The condition on the the gradients is \(\del V = \lambda \del G\text{,}\) or
\begin{equation*} yz = \lambda(y+2z),\; xz = \lambda(x+2z),\; xy = \lambda(2x+2y). \end{equation*}
Multiplying these by \(x\text{,}\) \(y\) and \(z\) respectively gives
\begin{equation*} V = xyz = \lambda (xy+2xz) = \lambda (xy+2yz) = \lambda (2xz+2yz). \end{equation*}
Again we can and should eliminating the Lagrange multiplier \(\lambda\) now. Division by zero is avoided because \(V \neq 0\) ensures that none of \(\lambda\text{,}\) \(x\text{,}\) \(y\text{,}\) and \(z\) is zero, so
\begin{equation*} xy+2xz = xy+2yz = 2xz+2yz, \end{equation*}
just as in Equation (4.8.6). Thus, just as in that example, we get the half-cube shape, \(x=y\text{,}\) \(z=x/2\text{.}\)
  • From \(xy+2xz = xy+2yz\) we get \(x=y\text{:}\) the bottom is square.
  • Then \(xy+2xz = 2xz+2yz\) becomes \(x^2=2xz = 4xz\text{,}\) so \(x=2z\text{:}\) the height is half the horizontal dimensions; a half-cube.
  • Finally, the area constraint \(xy+2xz+2yz=A\) becomes \(3x^2=A\text{,}\) so \(x = y= \sqrt{A/3}\text{,}\) \(z=x/2.\)

Dual Problems.

The fact that the optimum shape is the same for these two problems is not a coincidence: Swapping the function to be extremized with the constraint function and swapping between maximizing and minimizing always gives the same solutions like this, through getting the same equations once we have eliminated that Lagrage multiplier \(\lambda\text{.}\)
All that happens is that the factor \(\lambda\) moves from one gradient to the other, which is like changing \(\lambda\) to \(1/\lambda\text{.}\)
Pairs of optimization problems related in this way are called Dual Problems.
An alternate strategy for solving makes this duality even clearer, by eliminating the Lagrange multiplier \(\lambda\) from the beginning and treating the functions \(F\) and \(G\) equally. This is to note that the condition (4.8.4) is again that the two gradient vectors are parallel and so their cross product is zero:
\begin{align} \amp\del F \times \del G\notag\\ \amp= \left| \begin{array}{cc}F_y(x,y,z) \amp F_z(x,y,z) \\ G_y(x,y,z) \amp G_z(x,y,z) \end{array} \right| \veci + \left| \begin{array}{cc}F_z(x,y,z) \amp F_x(x,y,z) \\ G_z(x,y,z) \amp G_x(x,y,z) \end{array} \right| \vecj + \left| \begin{array}{cc}F_x(x,y,z) \amp F_y(x,y,z) \\ G_x(x,y,z) \amp G_y(x,y,z) \end{array} \right| \veck\notag\\ \amp= \vec{0}.\tag{4.8.9} \end{align}
This now gives three equations (each of these 2-by-2 determinants must be zero), but in fact any two holding ensures that the third one does also, so only any two need be solved; along with the constraint equation \(G(x,y,z)=k\) this gives a total of three equations in the three unknowns, as expected.

Subsection 4.8.3 Finding Extreme Values under Several Constraints

A function \(F(x,y,z)\) can have it domain restricted by two constraints, \(G(x,y,z)=k_1\text{,}\) \(H(x,y,z)=k_2\text{,}\) which generically limits the points \((x,y,z)\) to a curve in space. Arguments like those above show that extrema can only occur at solutions of
\begin{equation} \del F = \lambda \del G + \mu \del H,\tag{4.8.10} \end{equation}
where there are now two Lagrange multipliers, \(\lambda\) and \(\mu\text{.}\)
In practice, one can proceed by solving the system of five equations
\begin{equation*} F_x = \lambda G_x+ \mu H_x,\, F_y=\lambda G_y + \mu H_y,\, F_z=\lambda G_z + \mu H_z, \; \end{equation*}
\begin{equation*} G(x,y,z)=k_1,\; H(x,y,z)=k_2. \end{equation*}
As noted above, it is often best to to try to eliminate \(\lambda\) and \(\mu\) as soon as possible, since their values are unneeded.

Exercise 4.8.4.

Find the points in \(\reals^3\) of the intersection of the cylinder \(x^2+y^2=1\) with the plane \(x+y+z=1\) that are (a) closest to and (b) furthest from the origin. (This intersection is an ellipse.)
Hint.
Rather than extremizing the distance, use its square: \(F(z,y,z) = x^2 + y^2 + z^2\text{.}\)
Yet again, one strategy for eliminating the two Lagrange multipliers is to note that the condition is that the three vectors \(\del F(x,y,z)\text{,}\) \(\del G(x,y,z)\) and \(\del H(x,y,z)\) lie in a plane, and so the parallelepiped with these three vectors as its edges has zero volume, or equivalently, these vectors have zero scalar triple product, as discussed in Subsection 2.4.3. Thus the condition is
\begin{equation*} \del F(x,y,z) \cdot (\del G(x,y,z) \times \del H(x,y,z) ) = 0 \end{equation*}
which expands to the determinant equation
\begin{equation} \left| \begin{array}{ccc} F_x(x,y,z) \amp F_y(x,y,z) \amp F_z(x,y,z) \\ G_x(x,y,z) \amp G_y(x,y,z) \amp G_z(x,y,z) \\ H_x(x,y,z) \amp H_y(x,y,z) \amp H_z(x,y,z) \end{array} \right| = 0\tag{4.8.11} \end{equation}
This single equation plus the two constraint equations gives three equations in just the three relevant unknowns \(x\text{,}\) \(y\) and \(z\text{.}\)

Study Guide.

Study Section 4.8 of Calculus Volume 3
 5 
openstax.org/books/calculus-volume-3/pages/4-8-lagrange-multipliers
; in particular
  • The Problem Solving Strategy.
  • Theorem 20, and its implied extension to the case of two constraints.
  • All Examples and Checkpoints.
  • Several exercises from the range 358–368, including at least one with a function of three variables \(f(x,y,z)\text{.}\)
  • Several of the "modelling" exercises from the range 380–390.