yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Finishing the intro lagrange multiplier example


5m read
·Nov 11, 2024

So, in the last two videos, we were talking about this constrained optimization problem where we want to maximize a certain function on a certain set: the set of all points ( x, y ) where ( x^2 + y^2 = 1 ).

We ended up working out, through some nice geometrical reasoning, that we need to solve this system of equations. So, there's nothing left to do but to just solve the system of equations.

We'll start with this first one at the top and see what we can simplify. We notice there's an ( x ) term in each one, so we'll go ahead and cancel those out, which is basically a way of saying we're assuming that ( x ) is not zero. We can kind of return to that to see if ( x = 0 ) could be a solution. So maybe we'll kind of write that down: we're assuming ( x \neq 0 ) in order to cancel out.

From this, we can simplify to get ( 2y = \lambda \cdot 2 ). The ( 2 )s can cancel out—no worries about ( 2 ) equaling ( 0 ). We know that ( y = \lambda ), so that's a nice simplified form for this equation.

For the next equation, we can use what we just found—that ( y = \lambda )—to replace the ( \lambda ) that we see. Instead, if I replace this with ( y ), what I'm going to get is that ( x^2 = y \cdot 2 \cdot y ), so that's ( 2y^2 ). I’ll leave it in that form because I see that in the next equation I see an ( x^2 ) and I see ( y^2 ). So it might be nice to be able to plug this guy right into it.

In that next equation, ( x^2 ), I'm going to go ahead and replace that with ( y^2 ), so that's ( 2y^2 + y^2 = 1 ). Then, from there, it simplifies to ( 3y^2 = 1 ), which in turn means ( y^2 = \frac{1}{3} ). So, ( y = \pm \sqrt{\frac{1}{3}} ). Great! This gives us ( y ), and I’ll go ahead and put a box around that—we have found what ( y ) must be.

Now, if ( y^2 = \frac{1}{3} ), then when we look up here and we say ( 2y^2 ), that's going to be the same thing as ( 2 \cdot \frac{1}{3} ). So, if ( x^2 = \frac{2}{3} ), what that implies is that ( x = \pm \sqrt{\frac{2}{3}} ). And there we go, that's another one of the solutions.

I could write down what ( \lambda ) is, right? I mean, in this case, it's easy because ( y = \lambda ). But all we really want in their final form are ( x ) and ( y ) since that's going to give us the answer to the original constraint problem.

So, this gives us what we want. We just have that pesky little possibility that ( x = 0 ) to address. For that, we can take a look and say if ( x = 0 ), let’s go through the possibility that maybe that’s one of the constrained solutions.

Well, in this equation, that would make sense since ( 2 \cdot 0 ) would equal ( 0 ). In this equation, that would mean that we’re setting ( 0 = \lambda \cdot 2y ). Well, since ( \lambda = y ), that would mean that for this side to equal zero, ( y ) would have to equal ( 0 ).

So, evidently, you know, if it was the case that ( x = 0 ), that would have to imply from the second equation that ( y = 0 ). However, if ( x ) and ( y ) both equal ( 0 ), this constraint can't be satisfied. So none of this is possible. We never even had to worry about this to start with, but it's something you do need to check just every time you're dividing by a variable; you're basically assuming that it's not equal to zero.

This right here gives us four possible solutions, four possible values for ( x ) and ( y ) that satisfy this constraint and which potentially maximize this. And remember, when I say potentially maximize, the whole idea of this Lagrange multiplier is that we're looking for where there's a point of tangency between the contour lines.

Just to make it explicit, the four points that we're dealing with here: I’ll write them all here.

So ( x ) could be ( \sqrt{\frac{2}{3}} ), and ( y ) could be the positive ( \sqrt{\frac{1}{3}} ). Then we can basically just toggle. You know, maybe ( x ) is the negative ( \sqrt{\frac{2}{3}} ) and ( y ) is still the positive ( \sqrt{\frac{1}{3}} ). Or maybe ( x ) is the positive ( \sqrt{\frac{2}{3}} ) and ( y ) is the negative ( \sqrt{\frac{1}{3}} ).

Kind of monotonous, but just getting all of the different possibilities on the table here: ( x = -\sqrt{\frac{2}{3}} ) and then ( y = \sqrt{\frac{1}{3}} ) or ( y = -\sqrt{\frac{1}{3}} ). So these are the four points where the contour lines are tangent.

To find which one of these maximizes our function here, let's go ahead and write down our function again. It gets easy to forget. The whole thing we’re doing is maximizing ( f(x, y) = x^2 \cdot y ). So let me just put that down again: we're looking at ( f(x, y) = x^2 \cdot y ).

We could just plug these values in and see which one of them is actually greatest. The first thing to observe is ( x^2 ) is always going to be positive. So if I plug in a negative value for ( y )—if I plug in either this guy here or this guy here where the value for ( y ) is negative—the entire function would be negative.

So I’m just going to say that neither of these can be the maximum because it'll be some positive number, some ( x^2 ) times a negative, whereas I know that these guys are going to produce a positive number. Specifically, if we plug in ( f ) of, let’s say, this top one: ( \sqrt{\frac{2}{3}} ), ( \sqrt{\frac{1}{3}} ). Well, ( x^2 ) is going to be ( \frac{2}{3} ), and then ( y ) is ( \sqrt{\frac{1}{3}} ).

In fact, that's going to be the same as what we get plugging in this other value. So either one of these maximizes the function. It's got two different maximizing points, and each one of them has a maximum value of ( \frac{2}{3} \cdot \sqrt{\frac{1}{3}} ), and that's the final answer.

But I do want to emphasize that the takeaway here is not the specific algebra that you work out going towards the end, but it's the whole idea of this Lagrange multiplier technique. To find the gradient of one function, find the gradient of the constraining function, and then set them proportional to each other. That’s the key takeaway.

Then the rest of it is just, you know, making sure that we check our work and go through the minute details, which is important—it has its place. Coming up, I’ll go through a few more examples.

More Articles

View All
Identifying Unknown Soldiers | Ghosts of Pearl Harbor
[music playing] NARRATOR: Of the 429 men who died on the battleship “USS Oklahoma,” only 35 were identified in the years immediately following the attack. The rest were buried in graves marked “Unknown.” But almost 75 years later, one of these unknown me…
15 Steps to Reinvent Yourself and Start Over
Life is too short to be stuck in a life you don’t like. So, what is your best option? By the end of this video, you’ll have the game plan you’ve been looking for. Hello elixers, we’re so glad to have you with us for a very special Sunday motivational vid…
Productive Day in My Life in Japan 🇯🇵 |Med School Diaries #2 📚🧫
Hi, it’s me Rudy. Welcome to my channel! You’re currently watching Chill Productive Day Vlog. I woke up at 5:00 AM, and I decided to study until 7:00 AM because 7 A.M. is a time for breakfast at my grandparents’ house. I firstly started studying with a he…
Sine and Cosine come from circles
Now I’m going to clear off the screen here, and we’re going to talk about the shape of the sign function. Let’s do that. This is a plot of the sign function, where the angle Theta—this is the Theta axis in this plot—where Theta has been plotted out on a s…
Good Explanations Are Hard to Vary
Brett, would you say that a scientific theory is a subset of a good explanation? Yes, they’re the testable kinds of good explanations. Falsifiable theories are actually a dime a dozen. This doesn’t tell you anything about the quality of the explanation yo…
Space Archaeology: A New Frontier of Exploration | National Geographic
(light ethereal music) We are the detectives of the past. And we have to figure out what happened. That is what is fascinating about archaeology. Peru is super special archaeologically because this is one of the cradles of civilization. It’s where civili…