Lagrange Multipliers Intro and Example | Math Club

Using Lagrange multipliers to calculate the maximum and minimum values of a function with a constraint.

Devon Nall
5 min readOct 23, 2022

In this session of Math Club, I will demonstrate how to use Lagrange multipliers when finding the maximum and minimum values of a function subject to a constraint.

An example of a problem in which Lagrange multipliers are applied is where we need to find the dimensions of a box with a given volume that minimizes the amount of materials used.

We can only use Lagrange multipliers to maximize a function with a constraint. It does not apply when finding the maximum or minimum of an unconstrained function.

Typically, we will be given two functions or we will need to derive them from a word problem: f(x,y) and g(x,y)=k. I will only cover how to work with two variables here, but you can extend this to an n number of variables.

You could have f(x,y,z,w) and g(x,y,z,w)=k. It will be more difficult to find all the critical points, but the Lagrange multiplier method is still perfectly valid.

Once we have f(x,y) and g(x,y)=k, we take the partial derivatives with respect to x and y of each function. After finding these partial derivatives, we set the x- and y-partial derivatives of f(x,y) equal to the respective partial derivative of g(x,y) multiplied by the Lagrange multiplier constant, denoted by the Greek letter lambda, λ:

Once we have this system of equations laid out, it’s just a matter of performing algebra to find the variables x and y. There is no standard way to solve these systems of equations. Sometimes, it’s helpful to solve each equation for λ. You then could set each of those equations equal to each other.

The easiest routes to take depend on the individual problem, so it takes some ingenuity.

Let’s work out an example.

Example

Find the extreme (maximum and minimum) values of the function subject to the constraint shown below.

In this example, x²+y²=1 is g(x, y)=k. Thus, our function g(x,y) is g(x,y)=x²+y². We can now calculate the partial derivatives of each function:

We then use the Lagrange multiplier constant denoted by the Greek letter lambda, λ, to create a system of equations:

Here, we have three equations and three unknowns. Now, it’s just a matter of algebra to solve for x and y.

Consider the first equation, 2x=λ(2x). Your first instinct may be to divide both sides by 2x. You can do this, but we need to consider two cases. If x=0, then we can’t divide both sides by 2x. First, let’s consider the case in which x≠0:

Now, we can plug this into equation 2, -2y=λ(2y):

On its face, it appears that this is a contradiction, ruling out the possibility of x≠0. But this is only a contradiction when y≠0. Therefore, within the case of x≠0, we must consider a sub-case where y=0. This gives us 0=0, which isn’t a contradiction.

We still don’t know what x is, but we know that y=0 when x≠0. We can now plug y=0 into equation 3:

We should now check that these are valid x-values within our system of equations. Plugging x=±1 into equation 1 yields:

Since there are no contradictions, x=±1 are valid x-values.

We can now add (1,0) and (-1,0) to our list of critical points.

But we aren’t done yet. We haven’t considered the case when x=0. When x=0, we can’t divide each side of equation 1 by 2x, so we will move on to equation 3. When x=0, equation 3 becomes:

We can check that these are valid y-values by plugging them into equation 2 and plugging the resulting value of λ into equation 1:

No contradictions present themselves, so y=±1 are valid y-values. Because we have two y-values when x=0, we have two more critical points: (0,1), (0,-1).

We were asked for the extreme (maximum and minimum) values of f(x,y). Now we just plug each of our critical points, (0,1), (0,-1), (1,0), (-1,0), into f(x,y)=x²-y²:

Since f(0,1)=f(0,-1)=-1 and f(1,0)=f(-1,0)=1, we obtain two minimum values at (0,1) and (0,-1) and two maximum values at (1,0) and (-1,0).

💯 More Math Tutorials

This is the second article in my new Math Club series. The first one lies on my website at devonnall.com. Check out the first one if you’re having trouble with tangent planes and linear approximations here.

📧 Subscribe to my Weekly Email Newsletter

If you want to learn about random and interesting science facts I learn over the week, interesting science-related articles, videos, and podcasts, and other content like this, consider subscribing to my free email newsletter. Visit devonnall.com where you can read my entire catalog of newsletters and see if you’re interested.

--

--

Devon Nall

20-year-old computer science student who writes about whatever