Mathematics - Multivariable Calculus - Lecture 13

Uploaded by UCBerkeley on 18.11.2009

Thank you for coming despite the terrible weather.
In some sense it is 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 maxima and
minima 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 maxima and minima 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'll
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.
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 absolute maxima and minima
of this function.
And the way I explained 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 in the interior of the domain.

Should I do this example or not?
OK, 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 the quiz, I suppose but since I started doing it I
just wanted to go quickly over it again, OK?
So step 1 is-- step 1 is to look at the interior of the
domain and to calculate the partial derivatives.

I set the partial equal to zero.
I'm going to skip that.
I already did it last time.

But this is inside the domain.

So the next step-- 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 to equal something.
So effectively your function restricted to that component
becomes a function of one variable.
So let's say if we take the part of the boundary which is
that top horizontal statement, that would y equal 1 and x
between negative 1 and 1.
When you set y equal 1 in the 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?

squared plus 5.
And what you want to do now is to find the points, fine
the points, where g prime of x is equal to zero.
So this will be the points on the boundary which are
suspicious-- which are candidates for points of
maxima and minima, all right?
And I purposefully just look at the interior-- on the
interior of the 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's what I was talking about is
just finding the points with the derivative vanishes.
And then step 3 would be just to include the corners.

Now there is a different way to think about this-- there's a
different way to think about this process.
The way it is described in the book is there are two steps.
First step is exactly the same as what I explained.
But the second step would be to try to find the maxima and
minima of the function on each all of the components
of the boundary.
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?
So let's say when you look at this-- at 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 walk find the absolute maxima and minima
of the function g over x equals 2x squared plus 5.
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.
And also you look at the end points.
So you have to look at the end points as part of the problem
of finding the maxima and minima on this interval, right?
So what I did in my presentation of this algorithm,
I have taken the end points and put them in separate list, or
sublist-- separate sublist-- so that in step 2 you would only
be doing part of the problem of finding the absolute maxima and
minima on this interval.
Namely the points where the derivative vanishes
in the interior.
And then you have to deal with the corners, corners being that
end points of those intervals anyway.
The reason I like this way of thinking about it is the
following: the same corner-- say this one-- will appear
twice 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 deal-- you'll 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 them I mean include
them in your list, your list of suspicious-- maybe let's not
use the word suspicious, let's use the word candidates--
candidates for maxima and minima, right?

So you include them anyway.
So let's-- in step 2 then I'm suggesting not to worry about
the corners, which could also be thought of as the end points
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.
I think it's a slightly easier way to think about it.
But if you like, it's OK, you can do it in two
steps so to speak.
In other words, including the calculation of the
corners in step 2.
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 life when I
said there's three steps.
I don't mean by step 2 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 end points you as a separate step.
So in this particular example, in this particular example, you
have a list of oh how many points?
Quite a few.
I mean I'm not sure I should actually write them down.
But you have some points which will have the real-- for which
some points where the partial derivatives will vanish
in the interior.
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?
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11-- I have 11 points.
But anyway, it's not a hundred.
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 find for which points you get the maximum value and for
which points you get the minimum value.
It's possible there will 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.
Any questions about this?
All right.
So the reason why this problem was relatively easy was the
following: step 1 would be essentially the same
for all domains.
I mean, for step 1, 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 that's
not going to be so hard.
You just have to know which domain belong-- which points
belong to this domain and which points don't.
The problem would arise at step 2 if the domain is
not quite so simple.
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.
First of all, when you sketch domains by the way, there 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.
So in this case you would have just x squared plus
4y squared equals 1.
And you sketch that.
And that, we know, that's an ellipse.
We've talked about ellipses.
So for instance, we have the point x equal 1, x equals
negative 1, and y equals zero.
And we also have the points y equals 1/2 and y equals
negative 1/2 two other points.
And the ellipse looks like this.

So it's kind of a circle which is squished.
So that's-- the equality gives you a curve.
And in fact we can recognize our old friend the level curve.
This is a level curve for the function x squared
plus 4y squared.
But if instead of equality you write inequality like this, it
means that in addition you include points for which the
values is not equal to strictly 1 but could be less than 1.
And that means that this points are going to be on 1 or the
other side 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 zero and y equals zero satisfies this
equation-- this inequality for this formula.
And that's this point.
So clearly it should be inside and not outside.
That's how you figure out whether it's interior-- inside
or outside-- the interior part or the exterior part of the
plane, or inside the curve or outside the curve.
In this case it's inside.
And usually it's easy to figure this out.
So that's the domain.
That's what now plays the role of this square.
Let's suppose you're asked to 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 would you solve this problem?
You approach it in exactly the same way.

Solve it in the same way.
Meaning that the first step would be to set f(x) equals
zero and f(y) equals zero and find all the points inside the
domain-- inside the domain, which satisfies
the two formulas.
So in this case it's very easy to see that there are no points
like this because in this case f sub x is equal to 2.
If 2 equals zero, no solutions.
And f(y) equals zero, also no solutions.

So in step 1 we don't get any contribution to the list of
candidates, list of suspicious points.
So everything boils down to the boundary.
And in fact there is no step 3-- no step 3 here because
there are no corners. the boundary is smooth.

So we'd like to understand this entire boundary
in sort of 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 of one variable.
Once it becomes a function of one variable, we could solve
the problem by just going back to the one variable calculus.
But in this case it's not so clear.
Because, well, in our problem it was very easy.
You just substituted y equals 1.
And of course, it's obvious that the function then 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 4y squared.
But there is a problem.
We have two solutions.
There's plus minus 1 minus 4y squared.
So in fact what we are doing is that we're 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 zero or greater
than or equal to zero.
And the other one would be where x is less
than or equal to zero.
Once you do that, you have two components-- let me raise
this now-- two components.
One is x greater than or equal to zero and the other one
greater or equal to zero.
And then you can try to solve the problem of each component.
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 4y squared plus y.
This is in the case where x is greater than or equal to zero.
And a similar function with a negative sign, when x is
less than or equal to zero.
And you would have to find the points where
g prime of y is zero.
So you see that it was kind of nasty because the function's
not so nice and you split such a beautiful, a beautiful
ellipse into two parts.
And then you have to also deal with the end points.
There are no corners the way there were corners there,
because there they were actually not smooth.
They were singular, kind of points of singularity.
Here they are 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 these segments-- two
parts of the boundary.
So it is possible to solve the problem in this way but it 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 would
still be step 3.
Actually in this approach there will be a step 3 which will
correspond to points x equal zero and y equals plus/minus
1/2, a kind of fake corners.

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, actually we're 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 have instead of this, you
have something like x squared plus 4y squared plus xy plus--
you know some-- plus y plus square root of x.
So then try to express now y in terms of x or x in terms of y.
That would be very complicated.
That 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 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 maxima and minima 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 maxima and
minima of our function restricted to just
the boundary.
There's nothing interesting for us inside.
So that's why I'm raising-- I'm sort of raising this and I am
just focusing on the boundary.
And now I would like to approach this problem
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.
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 that 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.
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 1.
So we are just looking at one level curve for this function
f-- I'm 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 other.
So this is function h.
For the function h this 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 maxima and minimum
values-- maximal and minimal values-- and we don't know
yet where there are.
So we should look at all level curves for that
second function f.
So what are- what do this level curves look like?
So the level curves 4f of xy equal 2x plus y are given by
equations 2x plus y equals k where k is some number.
So for instance, one possibility is say k is equal
to zero. 2x plus y equals zero.
eq question No?
All right.
2x plus y equals zero.
What is 2x plus y equals zero?
It's the same as y equals-- maybe it's easier if I write
it like this like this: y equals minus 2x.
That looks like this.
That's the line which goes through zero with a
slope with negative 2.
And then the 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 goes through the point 1.
So it's actually in this case, it's going to cut
here at the point 1/2.
So I should do it more precisely like this.

And so on.
Well my lines are not perfect yet.
My lines are not perfectly aligned but I hope you see
what I'm doing anyway.

And what about other level curves?
Of course all other level curves are going to be
just parallel lines.
I mean we are so sophisticated now we even understand
questions of planes in 3-space.
For sure we understand equation 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 3-space.
Because we don't have a z it's even simpler.
So instead of a plane in 3-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 with such normal vector.
So I've drawn two of them but now it I'll draw more.
Here's another one.
Yeah, i kind of messed it up.
We can do it again.
I do 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, and this.
And now I want to draw a master line which is
going to be this one.
I keep hearing voices as if there is some color commentary,
sort of to my play-by-play.

I don't mind but I'm sure that people sitting next
to you probably mind it.

So you have a system of lines like this, OK?
So I think it's more clear now.
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, minimize.
We would like to find maximum, minimum values
of that function.
And now what we-- 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.
The function is going to be equal to-- where
is my master line?
This is my master line-- the function is going to be
equal to 1 along this line.
The function is going to be equal to say
1/2 along this line.
Maybe 3/4 along this line, 1 1/4 along this line and so on.
Whatever line you want you can draw.
And it's going to be one of these parallel lines.
But this the level curves for the function on
the entire plane.
But for now we are interested in step 2, so we're looking--
because step 1 did not produce anything anyway.
So we're looking just at this ellipse.
So what we're really interested in is the values of the
function on the ellipse.
Oh sorry.
Not this one, this one.
The one that goes through zero.
It's just bad drawing.
It's a bad drawing day.
But this one. you see what I mean. 1/2 would be then--
this is not 1/2, it's like 1/3-- sorry.
But you see what I mean.
It's not to scale, it's not parallel, it's not-- it's a
very qualatative picture, not very precise.
Kind of abstract like Picasso, the way Picasso
would approach it.

But I hope you see what I mean.
As you vary-- the point is when you go to the next one the
right, the value will increase.
When you go to the next one to the left, the value of
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, that
these are the two points of intersection of the line f
equals zero with out ellipse.
Here and here the function is equal to zero.
Here and here, the function is equal to 1.
Here and here it's equal to 1/3 and so on.
So now how can we use this picture to find where the
function takes the maximum or minimum values.
Well the point is that for sure, we can see from this
picture it's quite clear that f equals zero is not.
It's neither maximum nor minimum.
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 our domain, sorry--
with the ellipse, with our curve.
If I move it even by 1/3-- I can move it even by 1/3 and
I still have intersection.
So that cannot be maximum value because here the value
is zero, here it's 1/3.
Likewise, say this one would be f equals negative 1/3.
So from here I could also move along this curve to the left.
So I can shift my parallel line to the left,
decreasing the value.
So here is neither maximum nor minimum.
Likewise this is neither maximum or minimum.
This one is not, this one is not.
So at first it looks like neither of them
maximum or minimum.
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 could no longer move
it to the right or to the left.
In what sense?
Of course you could always move it to the right and to the
left, but you could not move it and still have a non-empty
intersection with your curve.
For example, you have a line like this, which is one
of their level curves.
But it's totally outside of the scope of our problem.
In other words, there's no intersection between this line
and this curve that we're interested in, right?
So those guys are excluded from our consideration anyway.
And so the point is to find the points where you can not move
to the right or to the left and still have non-empty
And the point-- for most of these lines, for all of the
lines which I have drawn, you have two points
of intersection.
So as you move further and further and further to the
right-- let me just make it slightly more
realistic looking.

Did somebody have a question?
As you move it, you still get two points, two points, two
points, two points, two points and then boom, there this one
point that something happens.
At this point, the intersection instead of getting two points,
you get just one point of intersection.
In other words, give up two points, 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 intersect is just this one
point and not two points.
You see what I mean?
It's just one point.
And likewise on this end, the same time.
You have intersection of two points and two points and the
next one's two points-- I'm just unable to do parallel
lines today-- two points, two points.
And then suddenly, boom!
There is this one line where it intersects with 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 or 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-zero--
non-empty intersection with my curve.
But when I'm here, I can certainly move it to the left
so I could 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.
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?
And likewise this is the minimum value because
I cannot move it any more one 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.
So this is the case when this is a tangent line.
And likewise, this is the case where this is a tangent line.

And what does it mean that this is a tangent line?
It means that the normal vector-- the normal vector
to this level curve is proportional to the normal
vector of this line.
But what on that the maxima and minima are the points where the
level curve of the function f of xy, which in this
case is 2x plus y.
In this case, the level curve 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 for f is function that we want
to maximize or minimize.
If it's tangent to our curve, which is this h
of xy which equals 1.
So I think that x squared plus 4y squared equals 1.
So that's the given curve.

So the point is in this exercise we are given two
functions, but they play very different roles.
There's a function f and there's a function h.
Function f is the function we want to maximize and minimize.
Therefore we kind of look at all level curves of that.
h is the second function.
It's the function which defines the curve and also defines the
domain if our original problem was about the interior of that
curve, the way I started talking about it.
For this function, we all need this in one level curve.
That's our-- that's the curve where we want to
maximize/minimize f.
But the interesting thing happens the places where
the two curves are tangent to each other.
And what does it mean that they are 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 talked 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 tangent lines to them coincide.
Or in other words, 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, curve of f,
is tangent to our curve.
Maybe I should say these are the point-- these are the
points where the normal lines to f of xy equals k and h of
xy equals 1, are the same.

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 x,zero y,zero such that nabla f at
x,zero y,zero is equal to lambda-- that's nabla--
h for x,zero y, zero.

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 this point we have a normal
vector to the line f.
f equals k.
That's vector That's the vector 2, this is nabla f.
Actually, nabla f is very easy to find, it's 2,1.
It's the vector 2,1.
There are two parts to the derivative.
So our f are 2 and 1.

Let me do it in red so that everything isn't
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, right?
So 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, and likewise same thing here.

That's why at these points we get maxima/minima values.
So let's find these points.
Are there any questions about this first of all? of all?
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 the line, right?
So what is the property of the two vectors for the
lines to be the same?
ehy It's not that they are equal, right?
They should be proportional.
If you have a vector you vet a line.
But if you take twice that vector you get
the same line, right?
So the condition is much weaker.
It's a condition is that the two vectors are proportional
to each other.
And then the two line 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.

La-- I'm thinking of another name-- Lagrange multiplier.

And this method of finding these external points is called
Lagrange multiplier method, after a great French
mathematician, Lagrange.
So, any other questions?
You'll probably see it better when we do it in this example.

So let's see what this equation look like in this example.

So what is nabla f?
Nabla f consists of two partial derivatives of f.
And those are easy to find it, they are just 2 and 1.
And what's nabla h?
These are the two partial derivatives of that function,
x squared plus 4y squared.
So it's going to be hx and hy are 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 x,zero y,zero, let
me stick to that and let's write also x,zero y,zero.
But of course when you do your calculations you will
oftentimes just write x and y without worrying about
the index zero.
Here I write x,zero and y,zero to emphasize that we are
talking about a particular point x,zero y,zero 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 x,zero y,zero.
So let's remember one thing which is that
lambda is unknown.
We are saying that they're proportional to each other,
but we don't know what the coefficient of
proportionality is.
So what we need to do here is to solve these equations for
x,zero y,zero and also lambda.
But you shouldn't forget that actually you are solving it not
on the entire plane but you are solving it on that curve only.
We are interested only in that curve now.
That's very important.
So far, I've written the equation as though x,zero and
y,zero were an arbitrary point.
But in fact, it should be a point on that curve.
So we have to add one more question, which is the
equation of that curve.
Which is x squared-- x,zero in this case plus 4y
squared equals 1.

So in fact you have three equations.
Three equations on three variables. x,zero
y,zero and lambda.
If you just tried these two equations, it would mean
that you look everywhere.
You have to constrain x and y, or x,zero y,zero by
imposing various original equations on this curve.
OK, so now it looks more meaningful 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 fininite many solutions.
That's what's going to happen here.
Let's find a solution.
So first we can express x,zero and y,zero in terms of lambda
and then we can substitute x,zero and y,zero into the
third equation and we'll get one equation in lambda.
That's the simplest way to solve it.
So from the first equation we find that x,zero
is 1 over lambda.
For the second question we find that y,zero is 1 over 8 lambda.
And now we put them into the third equation and we get one
over lambda squared plus 4 times 1 over 8 lambda
squared equals 1.

So what 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/16 so that's 17/16.

And from this you find that lambda squared
is equal to 16/17.

Is that right?
Right, because you take it to the other side. 17/16.
And that means that there are two solutions to lambda.
Lambda is equal to plus or minus square root
of 17 divided by 4.
Once we know what lambda is, we can find x,zero
and y,zero, right?
So now we find x,zero is equal to 4 over of square root of 17.
Well, there are two points.
First of all there are two points.
So for each, let me do it slowly-- let
me not in 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 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. x,zero is 4 over square root of 17.
And y,zero is 1 over 8 of that.
So it's 1 over 2 square root of 17.
The second point, so that's this point, that's this point.

And the other point is going to be 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, x,zero is
minus 4 square root of 17, y,zero is minus 1 over
2 square root of 17.
And well in this particular case it's clear which one is
the maximum and 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 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/2.
So that's going to be 17-- square root of 17 over 2.
So you've got 17 over that's the square root.
And here the function will be just-- actually, in
this case-- ah, but here see I was too fast.
I kind of-- Oh no, it is correct. that's right.
So it will be just minus of that.
Minus square root of 17 over 2.
So it's clear that that's the maximum, that's the minimum.
So that's that solution.
That's right.
They point in the same direction.
So lambda is positive.
When it's the minimum they should be opposite.
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 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 the maximum.
If the sign of lambda is negative it's the minimum.
And geometrically actually, I did not draw the picture, but
the picture would be like this: this would be the-- y would be
the gradient vector for the function g.
But now the red one will now go this way, but
red is always the same.
It's 2,1.
The So that's nabla f.
And here they are opposite whereas here they are pointing
in the same direction.

Any other questions about this?

That's right.
So-- that's right.
So you're talking about-- the question is about the level
curve, the red ones, right?
So the red lines are the level curves of the function
f, which is 2x plus y.
So we could look at the equation f equals
2x plus y in 3D.
That would be z equals 2x plus y.
So in fact, because this function is linear, the
graph of this function would be a plane.
And that plane actually can be very easily
illustrated right here.
So let's say it's this plane.
So now, what are the level curves-- I'm going back to
the same drawing which I did a couple of lectures ago.
What are the level curves?
Well you can draw-- draw level curves are just the sections
which are parallel to the floor, sections by planes which
are parallel to the floor.
So here's one of them, here's another.
I should have drawn in red, but you see what I mean.
This is will be-- so this is the level curve
for the function f.
But again, you think of the level curves as
being part of the graph.
But you can also think of them of their projections
into the x-y plane.
So what I had drawn on that picture are the projections
onto the x-y plane.
So I'm writing them as equations f equals something.
For example, f equals zero, or f equals 1/3 or f equals
negative 1/3, f equals 1 and so on, right?
If you like, you can think of the plane, x is the graph of
this function, as one which is obtained by assembling those
lines but in the 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-- this one, the one for which x is equal
to zero, would remain on the x,y plane.
And this one will be elevated and those guys will be
lower, just like here.
So let's say the x-y plane-- if the x-y plane were so that this
one was-- let's say this one is f equals zero.
So then this one-- let's say this is f equal 1/3 and so on.
So they're all elevated.
Thnk of like sort of a staircase.
I mean it's not like a staircase, but if you think of
just a step 1/3, 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 their projections into the
floor, onto the x-y plane.
You see?
That's right.
That's a very good question.
So, so far we were lucky that the domain, or more precisely,
the boundary of the domain, was presented by one equation only.
So now I would like to for the last example, look at kind of a
mixed case where you could have some 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.
So you could say, in this case the domain would be x,y such
that x squared plus 4y squared is equal To 1.
And x is greater than or equal to zero.
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-- the first component-- and this
is the second component.
So how would we solve the problem of finding maxima and
minima for function f if our domain is like this.
So let's say we're given some function f of x,y. of x,y.
I don't want to specify what this function is.
It could be this function 2x plus y or it coule be a
more complicated function.
Well, very simple.
Now we know everything that we need know to know for this.
y, that's right.
You're right.
Thank you.
y greater or equal to zero.
X greater 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 1, you said f sub x is zero, f sub y is zero inside.
That's just like before.
Well of course if our function is just 2x 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 would collect those points.
So 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.
And then we do step 2.

Now in step 2, you have two components.
So you want to do the first component, means that you
do Lagrange multiplier.
But out of all the points we find we only pick those points
for which y is greater or equal to zero.

Let's start with the second component.
The curvy component.
No, I meant that as a component.
This is the 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 board.
But now I've spent more time than I would have just
switching the board than changing the first and second.
Anyway, I think you know what I mean now, right?
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 2x plus y.
But we to have to take care of the fact that now, the curve
that we're talking about is not the entire as before
just the top part.
So we are only interested in the points we fine which
belong to this part.
So if you find something here, you discard it.
It's not part of our problem.
So in this case, if the function were indeed 2x 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 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 1 to 1, you do it in the old fashioned way.
You just substitute the function-- you just substitute
y equals zero into your function.
You get a function of one variable, you
find the derivative.
You find the points where the derivative vanishes.
So the first component is like this.
From 1 to negative 1.
And you just substitute y equals zero and get a
function of one variable.

Function g of x and then solve the g prime over x equals zero
when x is between negative 1 and 1.
And finally you have step 3, where because I ignored in my
intermediate calculations up to now, I ignored
the two end points.
I have ignored the end points.
For the same reasons that I explained before.
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 1, y equals zero and x equals negative
1 and y equals zero.
So put them on your list.
And finally you assemble this list.
So You've got points from step 1, step 2, each of the
two components in step 3.
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.
And that's how you solve it.

That's right.
So the question is, does Lagrange work for the
inside of the domain?
Lagrange is specifically for the boundary, for the curve.
So it doesn't tell us anything about the inside.
Because this argument would break down it being.
Because for being tangent you would 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, right?
But you have to realize that there are two ways in
which Lagrange methods may enter a given problem.
Essentially there are problems of two types.
The problems where you have to maximizer and minimize
functions on the two-dimensional
domain like this.
So this is usually domains which will be given by some
inequalities like x squared plus 4y squared less than or
equal to 1 or that coupled with y greater than
or equal to zero.
Such a problem consists of several steps.
You have to look at inside and you have to look
on the boundary.
But sometimes there could be a problem where you're just asked
to maximize or minimize your function on the boundary only.
In other words your set is given not by the
inequalities, by equalities.
Like you could be asked specifically to find the
maximum/miminum of your function 2x 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 the partial derivatives and so on.
So you just start with step 2.
You just look at the corresponding curve.
This function?

You mean g prime as a constant or g as a constant?

If g prime is a constant it means that there's
a linear function.
So your question is about function one variable, right?
What does it mean if you have function one variable whose
derivative is a constant?
It means that the function is a linear function.
ax plus b.
And of course that your function does not have
any extrema points.
Any points of local maxima and minima because the derivative
is nowhere vanishing.
So in that case step 2 will be vacuous.
So if you that as your function, the maxima and
minima it will obtain will happen at the end points.
And the end points are the ones we're including anyway.
That's right, that's right.
In fact, in this particular case that's what will happen.
If f were-- actually 2x plus y and we said y equals zero, in f
is 2x plus y and then we said y equals zero 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 this segment.
The only points will come from the end points of that segment.
In the way I approach this, those points will show
up in the third step.
But if you like it, you could include them in step 2 as well.
So now I would like to discuss one possible application
of all of this.
The application of a kind of practical problem where you
have to-- a kind of optimization problem where you
would like to optimize-- maximize or minimize
certain quantity under various constraints.
So here is a very representative example of that.

So we are building a rectangular box from cardboard.
And we would like to maximize the volume of the interior of
that box given that we can use so much cardboard.
So it's a very natural question one could ask.
So build a rectangular cardboard-- a rectangular
box without a lid.
From 12 square meters of cardboard so as to
maximize its volume.

OK, so here you are asked to build a box like this.

And what does it mean 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 that means we must maximize the volume.
And volume is a function of x, y, z, which are the
dimensions of the box.
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 cardbox.
So how much cardbox do we use?
Well, this box has six sides with cardboard everywhere
except for the top.
So we'll get two rectangles of which size for
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 doubled
because we don't have the lid as we are asked
in the exercise.
But for the other guys we'll have to double. yz and xz.
So it's xy plus 2xz plus 2yz.
That is a total area of cardbox that is used for this, such
a box, and that has to be equal to 12.

So this is a very-- we get exactly in the situation
of the problem about Lagrange multipliers.
Except now we have three variables to begin with.
In my previous problem we only had two variables, x and y.
So we had a function f in two variables and we had a
function h in two variables.
Now the role of x is played by the function v and the role of
h is played by this function.
H and three variables.
But we will approach this problem in
exactly the same way.
Namely, we will say-- we will apply Lagrange method.
OK by Lagrange method-- Lagrange multiplier-- 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 the gradient of the function h.
I remember the [UNINTELLIGIBLE]
equation h equals 12.
So remember it's not enough to write down the equation of
proportionality-- I'm sorry, I should have written nabla.
It's not enough to write down this equation, which is the
equation of proportionality of the two normal vectors or
the two gradient vectors.
You also have to write down the equation you
constrained separately.
Otherwise you will not find unique solution or you will not
find fundamental solution.
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 yz, with respect to y it's xz,
with respect to z it's xy.
And here we have lambda times the partial derivative of h.
And what is the partial derivative of h?
It's 2xz plus xy.
What am I -- what am I writing?
Sorry, I'm looking in the wrong place.
So it's y-- where did I write this?
2z-- OK.
2z plus y-- 2z plus y, 2z plus x and 2x plus 2y.
So now of this means that we have a bunch
of equations actually.
Let me see.
How much time do I have?
OK, great.
We have just enough time.

OK, so this is going to be three equations.
Yz equals lambda times 2z plus y. xz equals lambda times
2z plus x. xy is equal to lambda times 2x plus 2y.
Let's not forget this equation too.
So that will be 2xz plus 2yz plus xy equals 12.
So we've got a system of four equations with the variables
x, y, z and lambda.
So that's good.
We have four occasionals and four variables.
So at first it looked kind of intimidating.
But actually-- but actually it's not so bad because, for
example, the way we can approach this is the following.

For example, note that from this formula we know that x,
y, z equals lambda x times 2z plus y.
But also from this formula x, y, z-- so maybe I should try
it like this-- is lambda times y 2z 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 multiple by z.
And the left hand side is the same.
But on the right hand side I get different formulas.
So here I get lambda z times 2x plus 2y.
So for this example, we can then equa-- we can look at
this equation, for example.
So we have then 2x-- so we got lambda times 2x plus-- 2xz plus
xy is equal to lambda times 2yz plus xy.

2yz plus xy, right?
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
nabla v would be zero.
And nabla v being zero means that one of the three
variables is zero.
But of course the cardbox has non-zero comp-- dimensions.
All of the three dimensions are non-zero.
So lambda is non-zero since nabla v is
assumed to be non-zero.
So therefore we divide but lambda, we could move lambda.
And so now you see what happens is that now xy appears
and we get 2xz and 2yz.
And again, since z is not equal to zero because of course
otherwise it's not a box if z is equal to zero.
This implies that there actually x is equal to y.
So that's the first formula that you have.
And then if you substitute, in a similar way we also find
that's why is equal to 2z.
So that means that you've got two relations between x, y, z.
x is equal to y and y is 2z.
So that means that x is equal to y and x is equal to 2z.
So now you can substitute them into this last equation.
Put this too 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 2, y is 2, z is 1.

And that's the box that you get.
All right, see you on Thursday. the on Thursday