## Main Idea

Given a function $f$ in multiple variables, we want to maximize $f$ under a constraint $g=c$. We view $g=c$ as a level surface for the function $g$. For example, we could maximize or minimize the function $f(x,y)=2x+3y$ under the constraint $g(x,y)=x^2+y^2=2$. As I showed in class, we’re looking for points $(x,y)$ such that the contours of $f$ are parallel with the contour of $g(x,y)=x^2+y^2=10$. At these points, $\nabla f=\lambda\nabla g$ for some constant $\lambda$. (You can also insist alternatively on $\nabla f=-\lambda\nabla g$, since $\lambda$ is a constant real number.)

The $\lambda$ constant is called a Lagrange multiplier. We can generalize this situation by creating the Lagrangian function, defined as

\[

\Lambda(x,y,\lambda)=f+\lambda(g-c)

\]

where $c$ is the level curve given for $g$. Now, taking the gradient of $\Lambda$ and setting each component to zero allows us to find the points where the contours of $f$ are parallel to the contour $g=c$.

## Example 1

**Problem:** Find the maximum and minimum points of $f(x,y)=x+y$ relative to the constraint $g(x,y)=x^2+y^2=1$. (That is, find the maximum and minimum values of the function $f$ that lie above the unit circle.)

**Solution 1:** The Lagrangian in this situation (with the minus sign, as in your text) is

\[

\Lambda(x,y,\lambda)=f(x,y)-\lambda(g(x,y)-c)=x+y-\lambda(x^2+y^2-1).

\]

The gradient of the Lagrangian is then

\[

\nabla\Lambda = \left[1-2\lambda x,1-2\lambda y,-x^2-y^2-1 \right].

\]

Setting the first two components to zero implies $1-2\lambda x=1-2\lambda y=0$. Notice that the function $f(x,y)$ has no critical points (it is a plane), and so we never have to worry about the gradient being zero. Thus, we never have to worry about $\lambda$ being zero. Thus, we know that if $\nabla\Lambda=\vec{0}$ then $x=y$. We know from $x^2+y^2=1$ then that $2x^2=1$ and hence $x=\pm\frac{\sqrt{2}}{2}$. We now know that the points to consider are

\[

\left(-\frac{\sqrt{2}}{2},-\frac{\sqrt{2}}{2}\right) \qquad\text{and}\qquad\left(\frac{\sqrt{2}}{2},\frac{\sqrt{2}}{2}\right).

\]

Of course, knowing what the plane $z=f(x,y)=x+y$ looks like, we know that the first of these is the minimum and the latter is the maximum. (If we have more points to check, or if the structure of the surface $f$ isn’t obvious, then we simply plug in all of the points under consideration to $f$, keeping track of which one is a minimum and which is a maximum.)

**Solution 2:** One can do this without the Lagrangian. If we consider simply the gradient of $f$ and the gradient of $g$, setting the gradients parallel with a Lagrange multiplier as a constant gives

\[

1=\lambda 2x\qquad\text{and}\qquad 1=\lambda 2y.

\]

Again, this implies $x=y$ and then we solve the problem as in Solution 1.

## Example 2

**Problem:** Find the maximum and minimum points of $f(x,y)=x^2y+3y^2-y$ under the constraint $g(x,y)=x^2+y^2\le 10$.

**Solution:** Here’s an example of where the constraint may not actually matter. We’ll consider two problems:

- Maximize/minimize $f$ with respect to $x^2+y^2< 10$.
- Maximize/minimize $f$ with respect to $x^2+y^2=10$.

The first of these is a standard optimization problem where we simply verify that each pair of critical points under consideration satisfies $x^2+y^2<10$. The second problem is a Lagrange multiplier problem.

In terms of the first problem, we find the critical points of $f$:

\[

f_x=2xy=0\qquad f_y=x^2+6y-1=0.

\]

From the first equation, we get either $x=0$ or $y=0$. If $x=0$, from the second equation we get $6y-1=0$ and so $y=1/6$. If instead we have $y=0$ then the second equation tells us that $x=\pm 1$. We conclude that the critical points are

\[

(0,1/6),\ (1,0),\ \text{and}\ (-1,0).

\]

Notice that all of these critical points satisfy the constraint $x^2+y^2\le 10$. We keep these points in mind and start on the second problem.

The Lagrange conditions $\nabla f=\lambda\nabla g$ tell us that

\[

2xy=\lambda 2x\qquad\text{and}\qquad x^2+6y-1=\lambda 2y.

\]

From the first equation, when $x\neq 0$, we divide by $x$ and get $\lambda=x$. Substituting into the second equation, we then have

\[

x^2+6y-1=2y^2.

\]

Then using $x^2=10-y^2$ from the constraint, we get

\[

10-y^2+6y-1=2y^2.

\]

This implies that $3y^2-6y-9=0$. Factoring gives $3(y-3)(y+1)=0$. From the constraint, we get $x=\pm 1$ when $y=3$ and $x\pm 3$ when $y=-1$. If instead we have $x=0$ (where we cannot divide by $x$ in the first Lagrange equation), then from the constraint we know that $y=\pm\sqrt{10}$.

Thus, we collect all of our points that are of interest (those found previously and those found in the Lagrange multiplier version) and we have all of the following points to consider:

\[

(1,0),\ (-1,0),\ (0,1/6),\ (\pm 1,3),\ (\pm 3,-1),\ (0,\pm\sqrt{10}).

\]

The maximum value is found to be at $(0,-\sqrt{10})$ and the minimum is at $(3,-1)$ and $(-3,-1)$.

## Example 3

**Problem:** Consider a closed cylindrical container holding 100 cubic centimeters. Provide a relationship between the radius and height which will minimize the surface area for such a container.

**Solution:** The surface are is given by $S(r,h)=2\pi r^2+2\pi rh$. The constraint on this surface area equation is provided by the volume function and level surface $g(r,h)=\pi r^2h=100$. What is really sort of cool here is that we don’t need to consider the 100 component at all. Taking gradients, we find that

\[

\nabla S=\langle 4\pi r+2\pi h,2\pi r\rangle=\lambda\nabla g=\lambda\langle 2\pi rh,\pi r^2\rangle.

\]

Solving for $\lambda$ gives $\lambda=2/r$. This then implies that $4\pi r+2\pi h=4\pi h$, and we find from here that $2r=h$. That is, there is a critical point with respect to our constraint when we make the radius twice the height. How do we know that this is a minimum? You could view that in several ways. It makes sense geometrically from the definition of the surface area function. If you’re not yet convinced, you could use the second derivative test.

## no comment untill now