Wichita State University Logo

Math 344: Calculus III

14.8 Lagrange Multipliers


14.8.1 Optimizing Under a Constraint

A common problem that arises in applications is the need to optimize a function under a constraint. This means wanting to do something like find which dimensions of a cylindrical aluminum can has the least surface area (and thus requires the least amount of material to produce) for a given volume.

Two cylinders with the same volume but different heights and radii. The left cylinder is short and wide and the right cylinder is tall and narrow. $$ \def\ihat{\mathbf{\hat{\mmlToken{mi}[mathvariant="bold"]{ı}}}} \def\jhat{\mathbf{\hat{\mmlToken{mi}[mathvariant="bold"]{ȷ}}}} \def\khat{\mathbf{\hat{k}}} \newcommand{\pzi}[2][]{\dfrac{\partial #1}{\partial #2}} $$ These two cylinders have the same volume, but if you are a company producing many cans, you would want to know which of these shapes requires the least amount of material to make for a given volume. Ideally, you want to know which shape of can is the most cost effective. We can find this using calculus, specifically the method of Lagrange multipliers .

The method of Lagrange multipliers has two requirements:

  1. a function to be optimized
  2. a constraint under which to optimize the function

Let the function to be optimized be $f$ and the constraint be $g$. Our constraint is given by $g(\mathbf{x}) = k$ for some fixed value $k$. What we want to find is a level curve of the function $f$ which gives the largest (or smallest) possible value when it intersects $g(\mathbf{x})=k$. That is find the largest (or smallest) $c$ for which $f(\mathbf{x}) = c$ intersects $g(\mathbf{x})=k$. This intersection will occur when the tangent lines of both of these level curves at a point are parallel, and so this tells us that their gradients must be parallel. Taking advantage of this requirement that the gradients must be parallel, we can define the following method of optimization:

Method of Lagrange Multipliers

The minimum and maximum values of a function $f(\mathbf{x})$ under the constraint $g(\mathbf{x})=k$ for some $k\in\mathbb{R}$ (assuming that the extrema exist and $\nabla g\neq \mathbf{0}$ on $g(\mathbf{x})=k$) may be found by the following procedure:

  1. Determine all values of $x_1$, $x_2$,... $x_n$, and $\lambda$ which satisfy in the conditions

    $$ \begin{align*} \nabla f(\mathbf{x}) &= \lambda\nabla g(\mathbf{x}) \\ \\ g(\mathbf{x}) &= k \end{align*} $$
  2. Evaluate $f$ at all points $\mathbf{x}$ found in the first step. The greatest value of $f$ is the maximum and the smallest value of $f$ is the minimum.

14.8.2 A First Example

In the aluminum can example, we optimize for minimal surface area under a fixed volume.

Example 14.8.1

Suppose a soda company is making cylindrical aluminum cans and these cans are designed to hold 355 mL of soda. What is the height and radius of a cylindrical can that holds 355 mL with the minimum surface area?

Solution

The surface area of a cylinder is

$$ A(h,r) = 2\pi r^2 + 2\pi rh $$
and our volume constraint is

$$ V(h,r) = \pi r^2 h = 355 $$
The Lagrange multiplier method says that we need to use the relationship

$$ \nabla A(h,r) = \lambda \nabla V(h,r) $$
We interpret the gradient here as the derivative with respect to all independent variables, so we will have equations for both $\pzi{h}$ and $\pzi{r}$:

$$ \begin{align*} \color{#307fe2}{A_h = 2\pi r} &= \color{#ec008c}{\lambda\pi r^2 = \lambda V_h} \\ \\ \color{#307fe2}{A_r = 4\pi r + 2\pi h} &= \color{#ec008c}{2\lambda\pi rh = \lambda V_r} \end{align*} $$
This gives us two equations and three unknowns. For the third equation, we use the constraint. This gives the following system of three equations and three unknowns.

$$ \begin{align*} 2\pi r &= \lambda\pi r^2 \\ \\ 4\pi r + 2\pi h &= 2\lambda\pi rh \\ \\ \pi r^2 h &= 355 \end{align*} $$

Two notes as we get started:

  1. For solving systems that arise from Lagrange multipliers, there is no consistent approach that works. Every problem requires examining the resulting system and puzzling out the best way to find the solution.
  2. The Lagrange multiplier $\lambda$ is here to help you solve the problem, but you don't always need to find a specific value for it. Sometimes you'll see that is must be one of a couple of specific values and other times you won't need to know anything particular about it. This is something that comes naturally from the system once it is formed. If you can find all of the solutions (all $(h,r)$ in this example) without determining $\lambda$, that is OK.

Taking the first equation, we can see that a factor of $\pi r$ divides out and we see that $\lambda = \frac{2}{r}$. Plugging this into the second equation,

$$ \begin{align*} 4\pi r + 2\pi h &= 2\left(\frac{2}{r}\right)\pi rh = 4\pi h \\ \\ 4\pi r &= 2\pi h \\ \\ 2r &= h \end{align*} $$
This gives us a relationship between our two independent variables, so we can use the constraint equation to help us solve the system.

$$ \begin{align*} \pi r^2 h &= 355 \\ \\ \pi r^2 (2r) &= 355 \\ \\ 2\pi r^3 &= 355 \\ \\ r &= \left(\frac{355}{2\pi}\right)^\frac{1}{3} \approx 3.84\text{ cm} \end{align*} $$
We know that $h = 2r \approx 7.67\text{ cm}$, which gives us the dimensions for our can. Does this match up with a standard can of soda? Measure one to see how close or far away this result is from what you see in practice.

14.8.3 A Geometric Notion of Lagrange Multipliers

It is not possible to always draw pictures that fully represent the optimization process for Lagrange multipliers, but it can be done in simpler cases. Take the following example of the function $f(x,y) = e^{-2(x^2 + y^2)}$ and the constraint $g(x,y) = (x-1)^2 + (y-1)^2 = 0.25$. Plotting both of these surfaces and examining the intersection, we have

The intersection between two surfaces. The larger surface is a 'bump' function and the smaller one is a vertical cylinder. The intersection between the surfaces is plotted, showing a warped loop that is taller closer to the origin.

Since one of these surfaces may be represented in the form $g(x,y) = k$, their intersection shows the set of candidate points for optimizing $f$. Geometrically, we can see that the value of $f$ under the constraint are larger nearer the origin.

Example 14.8.2

Use Lagrange multipliers to find the maximum and minimum values of

$$ f(x,y) = e^{-2(x^2 + y^2)} $$
under the constraint

$$ g(x,y) = (x-1)^2 + (y-1)^2 = \frac{1}{4} $$

Solution

We begin by setting $\nabla f = \lambda\nabla g$ and using our constraint to find the system

$$ \begin{align*} \color{#307fe2}{f_x = -4xe^{-2(x^2 + y^2)}} &= \color{#ec008c}{2\lambda (x-1) = \lambda g_x} \\ \\ \color{#307fe2}{f_y = -4ye^{-2(x^2 + y^2)}} &= \color{#ec008c}{2\lambda (y-1) = \lambda g_y} \\ \\ (x-1)^2 + (y-1)^2 &= \frac{1}{4} \end{align*} $$
These expressions look a bit daunting at first, but we notice that the first two equations are very similar and seek to exploit that. If we assume that $x$ and $y$ are not equal to $1$ (which they cannot be since that is the center of the cylinder), then we can divide by the factors $x-1$ and $y-1$ to get $2\lambda$ by itself on one side of each of those equations. This gives us

$$ \begin{align*} \color{#307fe2}{2\lambda = } \dfrac{-4x}{x-1}e^{-2(x^2 + y^2)} &= \dfrac{-4y}{y-1}e^{-2(x^2 + y^2)} \\ \\ \dfrac{x}{x-1} &= \dfrac{y}{y-1} \\ \\ xy - x &= yx -y \\ \\ x &= y \end{align*} $$
Now we use the constraint equation to find the potential values for $x$ and $y$.

$$ \begin{align*} 2(x-1)^2 &= \frac{1}{4} \\ \\ (x-1)^2 &= \frac{1}{8} \\ \\ x &= 1 \pm \frac{1}{2\sqrt{2}} \end{align*} $$
Our two candidate points are $\left(1\pm \frac{1}{2\sqrt{2}},1\pm \frac{1}{2\sqrt{2}}\right)$. Evaluating $f$ at these values we see

$$ \begin{align*} f\left(1+ \frac{1}{2\sqrt{2}},1+ \frac{1}{2\sqrt{2}}\right) &\approx 6.56\times 10^{-4} \\ \\ f\left(1- \frac{1}{2\sqrt{2}},1- \frac{1}{2\sqrt{2}}\right) &\approx 0.188 \end{align*} $$
are our minimum and maximum, respectively. The intersection between two surfaces. The larger surface is a 'bump' function and the smaller one is a vertical cylinder. The intersection between the surfaces is plotted, showing a warped loop that is taller closer to the origin. The points representing the minimum and maximum values under the constraint are plotted.

Our previous image is repeated with the extrema we just found plotted so that we may visually verify our result.

Exercise 14.8.1

Find the optimal values of $f(x,y,z) = e^{xyz}$ under the constraint $2x^2 + y^2 + z^2 = 24$.

Check Your Work The maximum and minimum values are $e^{16}$ and $e^{-16}$ respectively.

Video Solution

14.8.4 Multiple Constraints

Optimization problems may also be presented with multiple constraints. In these cases, gradient of the function to be optimized is set equal to a linear combination of the constraint functions. To optimize $f(\mathbf{x})$ under the constraints $g(\mathbf{x}) = k$ and $h(\mathbf{x}) = c$ we use the system

$$ \begin{align*} \nabla f(\mathbf{x}) &= \lambda\nabla g(\mathbf{x}) + \mu\nabla h(\mathbf{x}) \\ \\ g(\mathbf{x}) &= k \\ \\ h(\mathbf{x}) &= c \end{align*} $$

Example 14.8.3

Find the maximum and minimum volumes of a rectangular box whose surface area is $1500\text{ cm}^2$ and whose total edge length is $200\text{ cm}$.

Solution

The volume of a rectangular box is $V = lwh$, its surface area is $A = 2lw + 2wh + 2lh$, and its total edge length is $L = 4l + 4w + 4h$. Our expression using Lagrange multipliers looks like

$$ \nabla V = \lambda\nabla A + \mu\nabla L $$
and adding our constraints results is the system

$$ \begin{align*} \color{#307fe2}{V_l = wh} &= \color{#ec008c}{2\lambda (w+h) + 4\mu = \lambda A_l + \mu L_l} \\ \\ \color{#307fe2}{V_w = lh} &= \color{#ec008c}{2\lambda (l+h) + 4\mu = \lambda A_l + \mu L_w} \\ \\ \color{#307fe2}{V_k = lw} &= \color{#ec008c}{2\lambda (l+w) + 4\mu = \lambda A_l + \mu L_h} \\ \\ 2lw + 2wh + 2lh &= 1500 \\ \\ 4l + 4w + 4h &= 200 \end{align*} $$
Cleaning this up a bit with basic simplifications:

$$ \begin{align*} wh &= 2\lambda (w+h) + 4\mu \\ \\ lh &= 2\lambda (l+h) + 4\mu \\ \\ lw &= 2\lambda (l+w) + 4\mu \\ \\ lw + wh + lh &= 750 \\ \\ l + w + h &= 50 \end{align*} $$
For problems such as these, one thing to check is if the result has symmetry. If $l = w = h$, we could easily verify if that is a minimum or maximum. However, if we assume $l = w = h = \frac{50}{3}$ we see that

$$ lw + wh + lh = 3\left(\frac{50}{3}\right)^2 = \frac{2500}{3} \neq 750 $$
a violation of the constraint. This means that at least one side must have a length that is distinct from the other values, so we assume that $l\neq w$ and $l\neq h$ and proceed.

Taking the difference of the first two equations in our system

$$ \begin{align*} wh - lh &= 2\lambda (w+h) + 4\mu - \left(2\lambda (l+h) + 4\mu\right) \\ \\ (w-l)h &= 2\lambda (w-l) \\ \\ h &= 2\lambda \end{align*} $$
We may divide by $w-l$ because we know that this value is not zero. Similarly, we can find that $w = 2\lambda$ by subtracting the first and third equations, so $w = h$. We may use the fifth equation to find an expression for $l$

$$ \begin{align*} l + w + h &= 50 \\ \\ l + (2\lambda) + (2\lambda) &= 50 \\ \\ l &= 50 - 4\lambda \end{align*} $$
Substituting this into the other constraint equation gives

$$ \begin{align*} lw + wh + lh &= 750 \\ \\ (50 - 4\lambda)(2\lambda) + (2\lambda)^2 + (50 - 4\lambda)(2\lambda) &= 750 \\ \\ 200\lambda - 12\lambda^2 &= 750 \\ \\ 6\lambda^2 - 100\lambda + 375 &= 0 \\ \\ \lambda &= \dfrac{100 \pm \sqrt{100^2 - 4(6)(375)}}{2(6)} \\ \\ \lambda &= \dfrac{50 \pm 5\sqrt{10}}{6} \\ \end{align*} $$
This expression for $\lambda$ allows us to find our $(l,h,w)$ candidate points

$$ \left(\dfrac{50 \mp 10\sqrt{10}}{3},\dfrac{50 \pm 5\sqrt{10}}{3},\dfrac{50 \pm 5\sqrt{10}}{3}\right) $$
where

$$ l = 50 - 4\lambda = 50 - 4\dfrac{50 \pm 5\sqrt{10}}{6} = \left(50 -50\frac{2}{3}\right) \mp \dfrac{20\sqrt{10}}{6} = \dfrac{50 \mp 10\sqrt{10}}{3} $$
Evaluating the function at these values, we see that

$$ \begin{align*} V\left(\dfrac{50 - 10\sqrt{10}}{3},\dfrac{50 + 5\sqrt{10}}{3},\dfrac{50 + 5\sqrt{10}}{3}\right) &= \dfrac{87,500 - 2500\sqrt{10}}{27} \\ \\ V\left(\dfrac{50 + 10\sqrt{10}}{3},\dfrac{50 - 5\sqrt{10}}{3},\dfrac{50 - 5\sqrt{10}}{3}\right) &= \dfrac{87,500 + 2500\sqrt{10}}{27} \end{align*} $$
are the minimum and maximum values of $V$ under the constraints, respectively.

Two boxes side by side. These are the solutions to Example 3, where the box on the left has the minimal volume under the given constraints and the box on the right has the maximal volume under these conditions.

By symmetry, this would work if we took either $w$ or $h$ to be the side with a distinct length.

Creative Commons Logo - White


Your use of this self-initiated mediated course material is subject to our Creative Commons License .


Creative Commons Attribution-NonCommercial-ShareAlike 4.0

Creative Commons Logo - Black
Attribution
You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

Creative Commons Logo - Black
Noncommercial
You may not use the material for commercial purposes.

Creative Commons Logo - Black
Share Alike
You are free to share, copy and redistribute the material in any medium or format. If you adapt, remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.