Skip to content

18. Constrained Optimization

mike nicholas edited this page Mar 7, 2025 · 16 revisions

In an earlier lab, we created a mountain range with a hiking path:

mountain

There are two natural, distinct optimization problems here:

  1. What are the high and low points of elevation on the mountain range? Or, what are the maximum/minimum values of the surface $\large f(x,y)$?
  2. What are the high land low points along the hiking path? Or, what are the max/min of $\large f(x,y)$ subject to the constraint of $\large (x,y)$ being on the curve $\large g(x,y)=0$ (an implicitly defined curve)?

We answered the first question in our previous lecture - we find critical points and classify them with the second derivative rule. We answer the second question with the method of Lagrange multipliers.

Method of Lagrange Multipliers

We want to maximize $\large f(x,y)$ subject to a constraint $\large g(x,y)=0$. Let's start by visualizing both the surface and the constraint in the $\large xy$-plane:

Lagrange1

In the picture above, it is clear that as we walk along the path (the blue arrows along the orange path), we max out at a height of $\large f=3$. The max occurs where the constraint curve is parallel to a contour.

Now, let's add the vectors $\large \nabla f$ and $\large \nabla g$ to the same picture. Recall two key facts:

  • $\large \nabla f(x,y)$ is orthogonal to the contours of $\large f$.
  • $\large \nabla g(x,y)$ is orthogonal to the curve defined by $\large g(x,y)=0$.

Lagrange2

We see that the max of $\large f(x,y)$ subject to $\large (x,y)$ lying on the path given implicitly by $\large g(x,y)=0$ occurs where $\large \nabla g$ and $\large \nabla f$ are parallel. This gives us the equation at the heart of the method of Lagrange multipliers:

$$\large \nabla f(x,y)=\lambda\nabla g(x,y)$$

The max and min of $\large f(x,y)$ subject to the constraint $\large g(x,y)$ occur at points where the equation above is satisfied ($\large \lambda$ is called the Lagrange multiplier). The components of that equation along with the constraint give us a system of three equations and three unknowns. Here's an example of how we use the Lagrange multiplier equation to find the max/min:

The steps to solve a Lagrange Multiplier problem are:

  1. Idenfify the objective function (the function we want to optimize) $\large f(x,y)$ and the constraint $\large g(x,y)=0$.
  2. Get the set of equations: the components of $\large \nabla f=\lambda\nabla g$ and the constraint.
  3. Solve these for $\large x$ and $\large y$ (we don't need to find $\large \lambda$).
  4. Plug the solution points into the objective function $\large f(x,y)$ to see which are maxima and which are minima.

Finally, all of this extends naturally to functions of three variables $\large f(x,y,z)$ with constraints $\large g(x,y,z)=0$.

Tomorrow's class:

  • Practice with constrained optimization problems.

Section Outcomes:

I can:

  • Solve a constrained optimization problem using the method of Lagrange Multipliers

Other resources

For more on constrained optimization, see https://openstax.org/books/calculus-volume-3/pages/4-8-lagrange-multipliers.

Clone this wiki locally