 Thank you for coming despite the terrible weather. Great weather. In some sense it is a great weather because when it's sunny and warm you want to be outside but in this weather I certainly don't want to be outside. So it's a perfect time to find absolute maximum and minimum of functions. So why don't we do that? I would like to pick up where I left off last time and discuss the example of finding maximum and minimum of a function on a two-dimensional domain which is a square. And I think it's a good example to illustrate the main points and also to make a transition to the next topic which we will discuss today which is Lagrange multipliers. So we have a function, we have this function and we have this domain which I drew last time. It is a square which is of length, each side is of length 2 which is situated on the plane like this. So we need to find the absolute maximum and minimum of this function. And the way I explain this is you have to follow an algorithm. The easiest way to solve this problem is to follow an algorithm. And the first step is, the first step of this algorithm is to look at the interior of the domain. Should I do this example or not? Okay, thanks. All right. I think I should, I mean I will go quickly. I know that this was in last week's homework and stuff and even quiz I suppose but since I started doing it I just wanted to go quickly over it again, okay? So step one is, step one is to look at the interior of the domain and to calculate the partial derivatives and set the partial equal to zero, okay? I'm going to skip that, I already did it last time but this is inside the domain. So the next step, so that's very easy, right? So you just get two equations and you solve them. You find all the functions. Sorry, all the points which satisfy this equations and this will be the first points on your list. Next, you look at each component of the boundary and on each component of the boundary you can set one of the variables equals something. So effectively your function restricted to that component becomes a function in one variable. So let's say if we take the part of the boundary which is that top horizontal segment that would be y equal 1 and x between negative 1 and 1. When you set y equal 1 in a function you effectively get a new function, let's call it g over x which is x squared plus 1 plus x squared plus 4, which is 2x squared plus 5, right? 2x squared plus 5. And what you want to do now is to find the points where fg prime x is equal to 0. So this will be the points on the boundary which are suspicious, which are candidates for points of maximum and minimum, right? And I purposefully just look at the interior of this interval. So that means x is between negative 1 and 1, but strict inequalities. I didn't make this clear, I think, at the end of my last lecture. What exactly I wanted you to do at this step. So I want to emphasize that what I was talking about is just finding the points where the derivative vanishes. And then step three would be just to include the corners. Now there is a different way to think about this, there is a different way to think about this process. The way it's described in the book is there are two steps, okay? The first step is exactly the same as what I explained, but the second step would be to try to find the maximum and minimum of the function on each of the components of the boundary, or I mean they say on the entire boundary, but effectively you will have to split it into four parts, right, and do it on each part separately. Now what would be involved in doing that? It would, so let's say when you look at this, at my exam, my component, y equals 1. When you look at y equals 1, you effectively get one dimensional problem where you have the interval from negative 1 to 1, and you want to find the absolute maximum and minimum of the function g of x equals 2x squared plus 5, right? So you split this problem into two parts as well. You look at the interior of the interval and you find points where the derivative is zero, right, and also you look at the endpoints. So you have to look at the endpoints as part of the problem of finding the maximum and minimum on this interval, right? So what I did in my presentation of this algorithm, I have taken the endpoints and put them in a separate list, or sublist, a separate sublist, so that in step two, you would only be doing part of the problem of finding the absolute maximum and minimum on this interval, namely the points where the derivative vanishes in the interior. And then you have to deal with the corners, corners being the endpoints of those intervals anyway. The reason I like this way of thinking about it is the following, that the same corner, say this one, will appear twice as the boundary, as the boundary of this horizontal segment and the boundary of this vertical segment. So if you go by the book, so to speak, right? So if you actually literally solve the problem for each of these segments, you will have to include this point twice. Whereas what I'm suggesting, it's really a minor variation, right? But what I'm suggesting is that don't worry about the corners from the beginning, just put them at the end, include them, when I say include, I mean include them in your list, in your list of suspicious, of maybe, let's not use the word suspicious, let's use the word candidates. Candidates for maximum and minimum, right? So you include them anyway. So let's, in step two, then I'm suggesting not to worry about the corners, which could also be thought of as the endpoints of the one-dimensional problems, which you get on the boundary. But instead, just focus on the interiors of the boundary components. And just find the points in there where the derivative is zero, okay? So that's, I think it's a slightly easier way to think about it. But if you like, it's okay, you can do it in two steps, so to speak. In other words, including the calculation with the corners in step two. You just have to do the same work twice. I mean, you have to deal with the same point twice in this example. Do you see what I mean? Is that clear? So that's what I meant, I didn't really spell it out in detail. That's what I meant at the end of my last lecture when I said there's three steps. In other words, I don't mean by step two doing the entire problem of finding the maximum and minimum on each interval. I mean just doing part of that, namely finding the points where the derivative is zero, and then the endpoints you do as a separate step. So in this particular example, in this particular example, you have a list of how many points, quite a few. I mean, I'm not sure I should actually write them down, but you'll have some points for which some points where the partial derivatives will vanish in the interior, some, there will be some points in the interior of those segments where the derivative vanishes. And finally, there will be the corners. So I have what, one, two, three, four, five, six, seven, eight, nine, ten, 11, 11, I think I have 11 points. But anyway, it's not 100, it's going to be a small number of points. And then what you do is you just evaluate your function at those points and you'll find for which points you get the maximum value and for which points you get the minimum value. It's possible that would be more than one point at which the function will attain the same maximum value. You just include both of them and say that the function takes the maximum value at those two points or three points or whatever, okay? Any questions about this? All right, so the reason why this problem was relatively easy was the following. Step one would be essentially the same for all, for all domains. I mean, for step one, no matter what your domain is, you'll just have to calculate the points. You'll just have to find the points where the two partial derivatives vanish. And then you have to make sure that that point belongs to your domain. So even if the domain has a complicated shape, right, that's not going to be so hard. You'll just have to know which points belong to this domain, which points don't. The problem would arise at step two if the domain is not quite so simple, right? So let me give you an example. So another example is a domain where x and y are such that x squared plus 4y squared is less than or equal to 1. So let's sketch this domain. So this are going to, first of all, when you sketch domains, by the way, this is a general rule which you probably have figured out already a long time ago. You first look, you have an inequality. You first look at the corresponding equality, right? So in this case, you would have just x squared plus 4y squared equals 1. And you sketch that, right? And that we know that's an ellipse. We've talked about ellipses. So for instance, we have the point x equals 1, x equals negative 1, and y equals 0. And we also have the points y equals 1.5 and y equals negative 1.5, two other points. And then the ellipses looks like this, right? So it's kind of a circle which is squished under that. So that's the, the equality gives you a curve. And in fact, we can recognize our old friend, the level curve here, right? This is the level curve for the function x squared plus 4y squared. But if instead of, instead of equality, you write inequality like this, it means that in addition, you include points for which the value is not equal to strictly 1, but could be less than 1. And that means that these points are going to be on one or the other side of, of this, of this curve. In this case, it's easy to figure out which side. Well, first of all, they're going to be on the same side. And clearly, x equals 0 and y equals 0 satisfy this inequality, right? This formula, and that's this point. So clearly, it should be inside and not outside. That's how you, you, you figure out whether it's an interior, inside or outside, the interior part or the exterior part of the plane. Of, or inside the curve or outside the curve. In this case, it's inside. And usually, usually it's, you know, it's, it's easy to figure this out. So that's the domain. That's what now plays the role of the square, okay? And let's suppose you're asked to find, find maxima and minima of the following function. F, I'll make the function a little bit easier, linear function, 2x plus y. So how, how would you solve this problem? Well, you approach it in exactly the same way, solve it in the same way. Meaning that the first step would be to set fx equals 0 and fy equals 0 and find all the points inside the domain, inside the domain D, which satisfy this two formulas. So in this case, it's very, it's very easy to see that there are no, no points like this because in this case, f sub x is equal to 2. So 2 equals 0, no solutions. And fy equals 0, also no solutions. So, so in step one, we don't get any contribution to the list of candidates or list of suspicious points. So everything boils down to the boundary. And in fact, there is no step three, no step three here, because there are no corners, the boundary is smooth. So we'd like to understand this entire boundary sort of in one shot. How can we do this? The idea in the previous analysis was to express the restriction of our function to the boundary or maybe a component of the boundary as a function in one variable. Once it becomes a function in one variable, we can solve the problem by just going back to the one variable calculus, right? But in this case, it's not so clear, because well, in the old problem, it was very easy. You just substitute y equal 1, and of course, it's obvious that the function becomes a function of only one variable, namely x. But here, what should you substitute? Well, one way to deal with this would be, one possibility would be to express one of the two variables on the boundary in terms of the other. So you could write, for example, x equals square root of 1 minus 4 y squared. But there is a problem. We have two solutions. There is plus minus 1 minus 4 y squared, right? So in fact, what we are doing is we are taking this very nice domain, and we are artificially cutting it here and here. And so we're breaking it into two parts. One would be where x is greater than 0, or greater than or equal to 0. And the other one would be where x is less than or equal to 0, right? Once you do that, so you have two components. Let me erase this for now. Two components, one is x greater than or equal to 0, and the other one, greater than or equal to 0, and the other one is less than or equal to 0. And then you can try to solve the problem on each component, right? So you would have to, you would get the function, say g of y, which is equal to 2 times square root of 1 minus 4 y squared plus y. This is in the case when x is greater than or equal to 0. And a similar function with a negative sign, when x is less than or equal to 0. And you would have to find the points where g prime of y is 0. So you see that it looks kind of nasty, right? Because the function's not so nice. And you split such a beautiful ellipse into two parts, then you'll have to also deal with the end points. They are not corners the way they were corners there. Because there they were actually non-smooth. They were singular, kind of points of singularity. Here they're actually smooth points, but we have sort of artificially made them singular, made them look like corners. Because now they appear as the end points of the, they appear as the end points of this two segment, two parts of the boundary, right? So it is possible to solve the problem in this way, but it's just not a very elegant solution. So it is natural to try to find a more elegant solution. And the more elegant solution, so then there will still be step three. Actually in this approach, there will still be step three, which will correspond to points x equals 0 and y equals plus minus 1 half. Kind of fake corners, right? So what I'm going to explain now is a more elegant solution, which is called Lagrange multipliers. It's a more elegant solution which is applicable to even more sophisticated functions. In this case, we are dealing with a fairly simple level curve or with a level curve of a fairly simple function. And that's why we can actually get away with expressing one of the variables in terms of the other. But let's say, let's suppose you had instead of this, you had something like x squared plus four y squared plus x y plus squared of x or something. So then try to express now y in terms of x or x in terms of y. That would be very complicated, right? Let alone, even if you can, then you have to take derivatives and stuff like that. So that's very complicated. But it turns out that there is actually a much more straightforward and elegant method. And that's called Lagrange multipliers. And actually I would like to explain this method first geometrically. So let me look again at this picture. This picture, the domain D consists of two parts again. It consists of the interior of the ellipse and the ellipse itself. But we have just seen that on the interior of the ellipse, there are no interesting points for us. There are no candidates for maximum and minimum because our function is such that there are no points where both partial derivatives vanish. So actually we can forget about the interior. The problem boils down to understanding the maximum and minimum of our function restricted to just the boundary. There is nothing interesting for us inside. So that's why I'm sort of raising this and I'm just focusing on the boundary. And now I would like to approach this problem geometrically. In other words, we have discussed several times level curves. And for example, we recognize this curve itself as a level curve of some function. And I said many times that if you know the level curves of a given function, you can understand much better the shape of this function, right? So let's see how it works in practice in this problem. The boundary is given by an equation, so the boundary is a level curve. That's a given. But we also have a function, so you have to separate the two things. You have, first of all, you have the equation, this is the equation of the boundary. But you also have a function. And so what we can do is we can also look at the level curves of this function, right? Here we are looking at just one level curve. Why only one level curve? Because this is the equation, the equation is that this is equal to one. So we are just looking at one level curve for this function F. Sorry, for this function, which let's call it, let's call it something else. Let's call it H. I don't want to use G because I already used G for this, so this is function H. For the function H, there is only one level curve which shows up in this problem. We don't care about other level curves. But for the function F, we would like to find maximum and minimum values, maximum and minimum values, and we don't know yet where they are. So we should look at all level curves for that second function. So what are, what do these level curves look like? So the level curves, level curves for F of x, y equal 2x plus y are given by equations. 2x plus y equals k, or k is some number. So for instance, one possibility is say k is equal to 0. 2x plus y equals 0, any questions? 2x plus y equals 0, what is 2x plus y equals 0? It's the same as y equals, maybe it's easier if I write it like this. y equals minus 2x, that looks like this. That's a line which goes through 0 with a slope, a slope is negative 2. And then if you look at other lines like this, for example, for instance 2x plus y equals 1, this is just y equals minus 2x plus 1. So that's going to be a line which is parallel to this one, but it goes through the 0.1. It's actually, in this case, it's going to cut here at the 0.1 half, right? So I should do it more precisely like this, and so on. Well, my lines are not perfectly aligned, but I hope you see what I'm doing anyway. All right, and what about other level curves? Well, of course, all other level curves are going to be just parallel lines. I mean, we are so sophisticated now, we even understand equations of planes in three space, for sure, we understand equations of lines on the plane. This looks like a typical equation, well, if we had a z, that would be typical equation for a plane in three space, and because we don't have a z, it's even simpler. So instead of a plane in three space, we get a line in two-dimensional space on the plane, where 2,1 is a normal vector. So when you vary this number k, you're going to get a system of parallel lines with such a normal vector, right? So I've drawn two of them, but now I'll draw more. So here's another one, yeah, I kind of messed it up, let me do it again. I really want to emphasize the fact that this is a system of parallel lines. Let's see if I can do it better this time. So we got this, we got this, like this, and we got this. Okay, and now I want to draw a master line, which is going to be this one. I keep hearing voices, like as if there is some color commentary, to my play-by-play, I don't mind, but I'm sure that your people sitting next to you probably mind it. Okay, so you have a system of lines like this, okay? So I think it's more clear now. Okay, so let's say that this one goes through zero. What is special about each of these lines? What is special is that along each of these lines, the value of the function f is the same. That's the function which we want to maximize or minimize. We would like to find the maximum, minimum values of that function. And now what this picture tells us, it tells us the lines of equal value for that function. So for instance, the function is going to be equal to zero along this line, right? The function is going to be equal to, where's my master line? This is my master line. The function is going to be equal to one along this line. The function is going to be equal to say one half along this line, maybe three quarters along this line, one and a quarter along this line, and so on, right? Whatever line you want, you can draw, and it's going to be one of these parallel lines. Okay, but these are the level curves for the function on the entire plane. But for now, we are interested in step two. So we are looking, because step one did not produce anything anyway, right? So we are looking just at this ellipse. So what we're really interested in is the values of the function on the ellipse. Sorry, not this one, this one, right? The one which goes through zero. It's just bad drawing. It's a bad drawing day, but this one, you see what I mean? And one half would be the, this is not one half, this is like one third. Sorry, why are you seeing what I mean? It's not to scale, it's not parallel, and it's a very qualitative picture. Not very precise. Kind of abstract, like Picasso, the way Picasso would approach it. Okay, but I hope you see what I mean. That as you vary, the point is that when you go to the next one to the right, the value will increase. When you go to the next one to the left, the value of the function will decrease. But we are interested not in the values everywhere. We are only interested in the value on, and the values on that ellipse. So in particular, we now know that here and here. These are the two points of intersection of the line ethical zero with our ellipse. Here and here, the function is equal to zero. Here and here, the function is equal to one. Here and here, it's equal to one third and so on, right? So now, how can we use this picture to find where the function takes the maximum or minimal values? Well, the point is that for sure, we can see from this picture, it's quite clear that ethical zero is not. It's neither maximum or nor minimum. Why? Because this line, we can move both to the right and to the left. When we move it to, and we'll still have some points of intersection with our domain, not with the domain, sorry, with the ellipse, with our curve, right? If I move it even by one third, I can move it even by one third and I still have intersection. So that cannot be maximum value because here the value zero, here's one third. Likewise, say this one, this one would be f equals negative one third. So from here, I can also move along this curve to the left. So I can shift my parallel line to the left, decreasing the value. So zero is neither maximum nor minimal. Likewise, this is neither maximum, this one is not, this one is not. So at first, it looks like none of them are maximum or minimum, right? So the point is to find the points where this qualitative argument doesn't work, where it breaks down. We have to find the points where you can no longer move it to the right or to the left, in what sense? Of course, you can always move it to the right and to the left, but you cannot move it and still have non-empty intersection with your curve. For example, you have a line like this, which is one of the level curves. But it's totally outside of the scope of our problem. In other words, there is no intersection between this line and this curve that we're interested in, right? So those guys are excluded from our consideration anyway, okay? And so the point is to find the points where you cannot move to the right or to the left and still have a non-empty intersection. And for most of these lines, for all of the lines which I have drawn, you'll have two points of intersection. So as you move further and further and further to the right, okay? Let me just make it slightly more realistic looking. Somebody have a question? No, okay. As you move it, you still get two points, two points, two points, two points. And then boom, there is this one point, something happens. At this point, the intersection, instead of getting two points, you get just one point of intersection, right? In other words, you have two points, two points, two points, but they get closer and closer to each other and they converge at this point. And suddenly, you get a very special point. This point is a point where the intersection is just this one point and not two points, right? You see what I mean? It's just one point like this. And likewise, on this end, the same thing, you have intersection at two points, at two points, at the next one, it's two points. I'm just unable to draw parallel lines today, two points, two points. And then suddenly, boom, there is this one line where it intersects at one point only. And for these two points, my previous argument actually breaks down. You see, because when I was here, I could argue that this is not the maximum minimum because I could move this way, I could move that way. And when I move a little bit, I would still have a non-empty intersection with my curve. But when I'm here, I can certainly move it to the left, so I can decrease the value. But I cannot move it to the right. It's kind of frozen here. What do I mean that I cannot move it to the right? Of course, I can. I can move it, but if I move it by any small amount, epsilon or any other small amount, there will still be a line like this, but it will not intersect my curve, right? So that second argument breaks down, so that means that this is the maximum value. Because I cannot move it anymore to the right. You see what I mean? Likewise, this is a minimal value because I cannot move it anymore to the left. So what are these special points? Well, now we know enough about level curves and things like that to realize that these are precisely the points where this line is tangent to this level curve, to this curve, right? So this is a case when this is a tangent line. And likewise, this is a case where this is a tangent line. And what does it mean that this is a tangent line? It means that the normal vector to this level curve is proportional to the normal vector of this line, right? So we have found that the maximum and minimum are the points, the level curve of the function f of x, y. Which in this case is 2x plus y. In this case, the level curves are lines. But in general, they're not going to be lines. They're going to be some curves. Where the level curve of the function, which we want to maximize and minimize. So f is a function that we want to maximize or minimize. Is tangent to our curve, which is this h of x, y, which is equals 1. So it is x squared plus 4y squared equals 1. So that's the given curve. That's the given curve. So the point is that in this exercise, we are given two functions. But they play very different roles. There is a function f and there is a function h. Function f is the function which we want to maximize, minimize. Therefore, we kind of look at all level curves of that. h is the second function, is the function which defines the curve. And also defines the domain if actually our original problem was about the interior of that curve, as I started talking about this. And for this function, we only interested in one level curve. That's the curve where we want to maximize and minimize f. But the interesting things happen at the places where the two things, the two curves are tangent to each other, as I explained. And what does it mean that they're tangent to each other? Well, in this example, the level curves of f are lines. So it's clear what we mean by saying that it's tangent, because we talk about tangent lines. But in general, if you have two different curves, there is also an obvious notion of being tangent. It just means that the tangent lines to them are coincide, right? Or in other words, the normal lines to both of them coincide. So this means, in other words, the normal lines, normal lines. So we are points where the level curve of f is tangent to our curve. Maybe I should say, these are the points. These are the points where the normal lines 2 of x, y equals k, and h of x, y equals 1 are the same, coincide, coincide. So how do we check that? Well, we know that the normal lines are given by the direction vector, the normal vector, to that curve, which is a gradient. So equivalently, we can say that the two gradient vectors should be proportional to each other. These are the points x0, y0, such that nabla f at x0, y0 is equal to lambda times nabla h of x0, y0. And that's the equation that will give us those points. What is the meaning of this equation in our case? In our case, at each point, we have a normal vector to the line f, f equals k. That's the vector 2. This is nabla f. Actually, nabla f is very easy to find. It's 2 comma 1. It's the vector 2 comma 1. The two partial derivatives of f are 2 and 1. Let me do it in red so that everything is in the same color. This is nabla f at this point. And nabla h is the vector which is normal to the curve. So in this case, the curve goes like this. So the normal vector will go like this. That's nabla g. Clearly, at this point, they are not proportional to each other. And they shouldn't be, because these are not the points where the two level curves are tangent to each other. They intersect with a certain angle. They are not tangent. But at this point, the two normal vectors suddenly become proportional to each other. So this is one. And this is the other. They become proportional, you see. So that's, and likewise, same thing here. So that's why at this point, we get the maximum and minimum values. So let's find these points. Are there any questions about this, first of all? Yes. What's lambda? Very good point. So lambda is the coefficient of proportionality. We don't know it a priori. This is, by the way, a very important point, because some of you made this mistake on the midterm. If you have two vectors, each vector spans a line. So what is the property of the two vectors for the lines to be the same? It's not that they are equal. They are not that they are equal. They should be proportional. Because if you have a vector, you get a line. But if you take twice that vector, you get the same line. So the condition is much weaker. The condition is that the two vectors are proportional to each other, and then the two lines coincide. And what does it mean that they are proportional? Proportional means that one of them is equal to some number times the other. And we call that number lambda. So that's the coefficient of proportionality, which, in this case, is called Lagrange multiplier. I'm thinking about another name, Lagrange multiplier. And this method of finding these extremal points is called Lagrange multiplier method after a great French mathematician, Lagrange. So any other questions? Let's see how you'll probably see it better when we do it in this example. So let's see what this equation looks like in this example. What is nubla f? Nubla f consists of two partial derivatives over f. And those are very easy to find. They are just 2 and 1. And what's nubla h? These are the two partial derivatives of that function, x squared plus 4y squared. So it's going to be hx and hy going to be 2x and 8y. And now the equation that we want is that 2, 1, that's the left-hand side, is equal to lambda times 2x, 8y. More precisely, since here I wrote x0, y0, let me stick to that and let's write also x0, y0. But of course, when you do your calculations, you will oftentimes just write x and y without worrying about this index 0. Here I write x0 and y0 to emphasize that we are talking about a particular point, x0, y0, and not about general values, x, y. So, but this is not just one equation. This is a system of two equations because you have two components of these vectors. So there are two equations, 2 equals lambda times 2x and 1 equals lambda times x0, y0. So let's remember one thing, which is that lambda is unknown. We are saying that they are proportional to each other, but we don't know what the coefficient of proportionality is. So what you need to do here is to solve these equations for x0, y0, and also lambda. But you shouldn't forget that actually you're solving it not on the entire plane, but you are solving it on that curve only, right? We are interested only in that curve now. That's very important. So far, I've written the equation as though x0 and y0 were an arbitrary point. But in fact, it should be a point on that curve, that curve C. So we have to add one more equation, which is the equation of that curve, which is x squared, x0 in this case, plus 4y squared equals 1. So in fact, you have three equations, three equations on three variables, x0, y0, and lambda. If you just write these two equations, it would mean that you look everywhere. But you have to constrain x and y, or x0, y0, by imposing the original equation of this curve. OK, so now it looks more meaningful, right? Because you've got three equations and three variables. And usually, generically, if you have three equations with three variables, you're going to get one solution or you get, finally, many solutions. That's what's going to happen here. Let's find this solution. So first, we can express x0 and y0 in terms of lambda. And then we can substitute x0 and y0 into the third equation. And we'll get one equation on lambda. So that's the simplest way to solve it. So from the first equation, we find that x0 is 1 over lambda. From the second equation, we find that y0 is 1 over 8 lambda. And now we put them into the third equation. And we get 1 over lambda squared plus 4 times 1 over 8 lambda squared equals 1. So that means 1 over lambda squared times 1 plus 4 divided by 64 equals 1. And that's going to be what? So this is 1 over 16. So that's 17 over 16. And from this, you find that lambda squared is equal to 16 over 17. Is that right? 17 over 16. Because you take it to the other side. 17 over 16. And that means that there are two solutions for lambda. Lambda is equal to plus or minus square root of 17 divided by 4. Once we know what lambda is, we can find x0 and y0. So now we find x0 is equal to 4 over square root of 17. Well, there are two points. First of all, there are two points. So for each, let me do it slow. Let me not mess it up. Each solution for lambda will correspond to a particular point. And of course, we kind of know that we should get two points. We expect to get two points. One is will be the maximum, and the other one will be the minimum. So the first point is lambda equals square root of 17 over 4. Then x0 is 4 over square root of 17. And y0 is 1 over 8 of that. So it's 1 over 2 square root of 17. And the second point, so that's this point. That's this point. And the other point is it's going to be this with the minus sign. 4 over square root of 17 minus 1 over 2 square root of 17. So lambda equals minus square root of 17 over 4. x0 is minus 4 over square root of 17. y0 is minus 1 over 2 square root of 17. And well, in this particular case, it's clear which one is the maximum, which one is the minimum, because we can see it clearly on the picture. But in general, it may not be so obvious. So what you should do is you should just substitute them into your function and calculate the value. And the one for which the value is bigger will be the maximum, and the one for which the value is smaller it will be the minimum. So in this case, f is going to be, you have to substitute in 2x plus y. So that's going to be 2x plus y. So it's like 8. It's going to be 1 over square root of 17. And here will be 8 plus 1 half. So that's going to be square root of 17 over 2, because you get 17 over, so this is square root. And here the function will be just, actually, in this case. Ah, but here, see, I was too fast to, I kind of, oh no, it is correct. So it will be just minus of that. So minus square root of 17 over 2. Not so clear that's the maximum, that's the minimum. So that's a solution, yes. That's right. They point in the same direction. So lambda is positive. Right, and when it's a minimum, they should be opposite. Right, exactly. It's always like this. If they are pointing in the same direction, that's the maximum, so that's actually a very good question. That we can actually tell by looking at the, in which direction the two vectors are pointing, or in other words, what is the sign of lambda? If the sign of lambda is positive, it's a maximum. If the sign of lambda is negative, it's a minimum. And geometrically, actually, I did not draw the picture, but the picture would be like this. This would be the white, will be the gradient vector for the function g, but now the red one will not go this way, but red is always the same, right? It's 2, 2, 1. So that's nubla f. And here, see this here, they are opposite. Whereas here they are pointing in the same direction. Any other questions about this? Yes? Right, so that's right. So that's right. So the question is about the red ones, right? So the red lines are the level curves of the function f, which is 2x plus y, right? So we could look at the equation f equals 2x plus y in 3d. That would be z equals 2x plus y, right? So in fact, because this function is linear, the graph of this function would be a plane, right? And that plane actually can be very easily illustrated here. So let's say it's this plane, right? So now what are the level curves? So I'm kind of back to the same drawing, which I did a couple of lectures ago, right? What are the level curves? Well, you can draw level curves. So the level curves are just the sections which are parallel to the floor, sections by planes which are parallel to the floor, right? So here's one of them. Here's another. I should have drawn in red, but you see what I mean. This will be, so these are the level curves for the function f. But again, so you can think of the level curves as being part of the graph, but you can also think of them, of their projections onto the xy plane. So what I have drawn on that picture are the projections onto the xy plane, you see? So I'm writing them as equations f equals something, for example, f equals zero, or f equals one-third, or equals negative one-third, f equals one, and so on, right? If you like, you can think of the plane, which is a graph of this function, as one which is obtained by assembling those lines, but in a kind of, each time you have to lift it by the height, which is equal to the value of the function. So only this one, the one for which f is equal to zero would remain on the xy plane. And these ones will be elevated, and those guys will be lower, just like here. So let's say if the xy plane, if the xy plane were, so that this one was, let's say this one is f equals zero. So then these ones will be, let's say this is f equals one-third, and so on. So they are all elevated. So it's like, think of a sort of staircase. I mean, it's not really a staircase, but if you think of just step one-third, then this is a collection of lines. But it doesn't make sense to draw them in 3D because they are given by equation on just x and y. So that's why I'm drawing the projections onto the floor, onto the xy plane, you see? Yeah? That's right. That's a very good question. So far, we were lucky that the domain, or more precisely the boundary of the domain, was represented by one equation only. So now I would like to sort of as a last example to look at kind of a mixed case, where you could have several components in the boundary, and some of them could be linear, and some of them could be curved like this. So let's say a very simple generalization of this example would be, a very simple generalization of this example would be if your domain was like this, you see? So you could say, so in this case, the domain would be xy, such that x squared plus 4y squared less than or equal to one, and x is greater than or equal to zero. And oftentimes you will have domains like this. So in this case, we actually do have two corners, and we actually have two natural components in the boundary. This is one component, this first component, and this is the second component. So how would we solve the problem of finding maximum and minimum for function f if our domain is like this? So let's say we're given some function f of xy. I don't want to specify what this function is. It could be this function to x plus y, or it could be a more complicated function. Well, very simple, now we know everything that we need to know for this. Y, that's right, sorry, you're right. Thank you. Y greater than or equal to zero. X greater than or equal to zero would be this part. That's right. So you approach it the same way as before, three steps. The first step would be to find the points in the interior where both partial derivatives vanish. So step one, step one, you set f sub x is zero, f sub y is zero inside d, okay? That's just like before. Well, of course, if our function is just two x plus y, then there are no such points, so we don't have to worry about it. But in general, there might be some points in the interior. So we collect those points, we don't do anything yet, we just collect them and put, so we start a list, and these points will be on the list. Then we do step two. Now in step two, you have two components. So you wanna do the first component, means that you do the Lagrange multiplier. But out of all points, we find, we only pick those points, those points for which y is greater than or equal to zero. Man, yeah. Let's start with the second component. Sorry, the curvy component. No, I called it second component, right? No, I meant that as a component. This is a second component. I'm just doing it out of order. Instead of doing the first component first and second component second, I do second component first. Because I don't want to switch the boards. But now I've spent more time than I would have just switching the boards and changing the first and second. Anyway, I think you know what I mean now, right? Okay, so we do this one. And this is exactly the same calculation as we've done so far. Well, it would have been exactly the same if our function were just to x plus y. But we have to take care of the fact that now the curve that we're talking about is not the entire curve as before, but just the top part. So we are only interested in the points we find which belong to this part. So if you find something here, we discard it. It's not part of our problem. So in this case, if the function were indeed to x plus y, instead of finding two points, we would find just one point, which is this one. Only this one and this one we discard. So it means that at the end of your calculation, you have to check. When you find your point, you have to check. Is it true that y zero is greater than or equal to zero? For this one, it's true, but for this one, it's not. So then we discard this one. So that's what you do for the second component. For the first component, by which I mean just the segment from negative one to one, you do it in an old-fashioned way. You just substitute the function. You just substitute y equals zero into your function. You get function one variable. You find the derivatives. You find the points where the derivative vanishes, right? So the first component is like this. One to negative one. And you just substitute y equals zero. You get a function one variable, function g of x. And then solve the equation g prime of x equals zero. 1x is between negative one and one. And finally, you have step three, where because I ignored in my intermediate calculations up to now, I ignored the two endpoints. I have ignored the endpoints. For the same reason as I explained before, because I don't have to ignore it. I could also take them into account, but then I might have to include each of them twice in my analysis. So I personally would just take the two corners separately. So that's x equals one, y equals zero, and x equals negative one, and y equals zero. So we put them on your list. And finally, you assemble this list. So you've got points from step one, from step two, each of the two components, and step three. And then you calculate the value of your function at each of these points, and you find which ones correspond to the maximum and minimum. That's how you solve it. OK? Question? Yes? That's right. So the question is, does Lagrange work for the inside of the domain? So Lagrange method is specifically for the boundary, for the curve. So it doesn't tell us anything about the inside. Because this argument would break down about it being tangent. Because for being tangent, you'd have to have two curves. And one of the curves would be the level curve of function f, and the other one would be your boundary. If you weren't looking at the boundary, then we wouldn't be able to argue in this way. But you have to realize that there are two ways in which Lagrange method may enter a given problem. Essentially, there are problems of two types. There are problems where you have to maximize or minimize functions on the two-dimensional domain like this, or like this. So these are usually domains which will be given by some inequalities, like x squared plus 4y squared less or equal to 1, or that coupled with y greater or equal to 0. Such a problem consists of several steps. We have to look inside, and we have to look on the boundary. But sometimes there could be a problem where you just ask to maximize or minimize your function on the boundary only. In other words, your set is given not by inequalities, but by equalities. Like you could be asked specifically to find the maximum and minimum of your function to x plus y on that curve, on that ellipse. So in that case, if in the problem there is no reference to the interior of that curve, you don't need to do the first step. You can skip the first step because you don't need to know what partial derivatives are and so on. So you just start with step two. You just look at the corresponding curve. This function, you mean g prime is a constant, or g is a constant? If g prime is a constant, it means it is a linear function. So your question is about function in one variable. What does it mean that you have a function in one variable and the derivative is a constant? It means that the function is a linear function, a x plus b. And of course, such a function does not have any extremal points, any points of local maximum and minimum. This derivative is nowhere vanishing, right? So in that case, then step two will be vacuumed. So if you have such a function, the maximum and minimum that it will attain will happen at the end points. And the end points are the ones we're including anyway. Yes? That's right, that's right. In fact, in this particular case, that's what will happen. If f were actually 2x plus y, right? And we said y equals 0. If f is 2x plus y, and then we said y equals 0, then g becomes 2x. So it is going to be a linear function like this. So in that case, there will be no points coming from this segment, from the interior of the segment. The only points will come from the end points of that segment. And in the way I approach this, those points will show up at the third step. But if you like, you could include them at step two as well, okay? So now I would like to discuss one possible application of all of this. And the application is kind of a practical problem where you have to have kind of an optimization problem where you would like to optimize, maximize or minimize certain quantity under various constraints. And so here is a very, here is a very representative example of that. So we are building a rectangular box, okay? From cardboard. And we'd like to maximize the volume of the interior of that box, given that we can use so much cardboard. Okay, so it's a very natural question one can ask. So build a rectangular cardboard, rectangular box without a lid, from 12 square meters of cardboard board so as to maximize its volume, okay? So here you are asked to build a box like this. And what does it mean to build a box? You have to decide what the dimensions will be. So this will be X, this will be Z, and this will be Y. You have to decide what the dimensions are, given that you have so much cardboard. So that means that you have to maximize, we translate it into mathematics. We say, it means that we have to maximize the volume. The volume is a function of X, Y, Z, which are the dimensions of the box, right? And it's just X times Y times Z. And we have a constraint. So we have function H of X, Y, Z, which is the amount of cardboard, right? So how much cardboard do we use? Well, this box has six sides, and we have cardboard everywhere except at the top, right? So we'll get two rectangles of which size, like the vertical ones, but the horizontal, there will be only one horizontal rectangle of dimensions X and Y. So the function will be X times Y. That's the area of this rectangle, and it's not double because we don't have the lid as we are asked in the exercise. But for the other guys, we'll have to double Y, Z, and X, Z. So it's X, Y plus two X, Z plus two Y, Z. That is a total area of cardboard box that is used for this, for such a box, right? And that has to be equal to 12. So this is a very, this is, we get exactly in the situation of the problem about Lagrange multipliers, except now we have three variables to begin with. You see, in my previous problem, we only had two variables, X and Y. So we had a function, we had a function F in two variables, and we had a function H in two variables. Now, the role of F is played by this function V, and the role of H is played by this function, H in three variables. But we will approach this problem in exactly the same way. Namely, we will say, we will apply Lagrange method. Okay, so by Lagrange method, that means that we are looking for points X, Y, Z. I will skip X, zero, Y, zero, Z, zero, just call them X, Y, Z, to simplify notation, such that nabla V, the gradient of the function V, is proportional to the gradient of the function H, and I will also impose the equation H equals 12. So remember, it's not enough to write down the equation of proportionality. Sorry, I should have written nabla, sure. It's not enough to write down this equation, which is the equation of proportionality of the two normal vectors, of the two gradient vectors. You also have to write down the equation, you're constrained separately. Otherwise, you will not find a unique solution, or you will not find finitely many solutions. So what do these equations look like? Well, nabla V is obtained by taking all partial derivatives of that function. So what are they? Well, with respect to X, it's Y, Z, with respect to Y, it's X, Z, with respect to Z, it's X, Y. And here we have lambda times the partial derivative of H. And what is the partial derivative of H? It's two X, Z plus X, Y. What am I, sorry, I'm looking at the wrong place. So it's Y, what did I write this? Two Z, okay. Two Z plus Y, two Z plus Y, two Z plus X, and two X plus Y, two X plus two Y, okay? So now this means that we have a bunch of equations, actually. Let me see how much time do I have. Okay, great, just enough time. Okay, so this is going to be three equations. Y, Z equals lambda times two Z plus Y, X, Z equals lambda times two Z plus X, X, Y is equal to lambda times two X plus two Y. And finally, let's not forget this equation too. So that will be two X, Z plus two Y, Z plus X, Y equals 12. So we got a system of four equations with the variables X, Y, Z and lambda. So that's good, four equations, four variables. So it first looks kind of intimidating, but actually it's not so bad because for example, the way we can approach this is the following. We can, for example, note that from this formula, we know that X, Y, Z equals lambda X times two Z plus Y. Times two Z plus Y, right? And also from this formula, X, Y, Z, so maybe I'll just write it like this, is lambda times Y to Z plus X. From this formula, now I multiply by Z. This line I multiply by X, this line I multiply by Y and this line I multiply by Z. And the left-hand side is the same, but the right-hand side I get different formulas. So here I get lambda Z times two X plus two Y. And so, for example, we can look at this equation, for example, right? So we have then two X, so we get lambda times two X plus two X Z plus X, Y is equal to lambda times two Y Z plus X, Y. Two Y Z plus X, Y, right? And so now the point is that actually we can assume that we can show that lambda is not equal to zero because if lambda were equal to zero, then nubla v would be zero. Nubla v being zero means that one of the three variables is zero, but of course a card box has non-zero components. Dimensions, all of the three dimensions are non-zero. So lambda is non-zero since nubla v is assumed to be non-zero. So therefore we can divide by lambda. We can remove lambda. And so now you see what happens is that now X, Y disappears and we get two X Z is equal to two Y Z. And again, since Z is not equal to zero, because of course otherwise it's not a box, it's equal to zero, this implies that actually X is equal to Y, okay? So that's the first formula that you have. And then if you substitute in a similar way, we also find that Y is equal to two Z. And so that means you've got two relations between X, Y, Z. X is equal to Y and Y is two Z. So that means that X is equal to Y and X is equal to two Z. So now you can substitute them into this last equation. Put this two in the last equation. You can express all of them in terms of Z, find Z, find X, find Y. That's the solution. So the end result is X is two, Y is two, Z is one. And that's the box that you get. All right, see you on Thursday.