JOEL LEWIS: Hi.
Welcome back to recitation.
In lecture, you've been learning about using
the method of Lagrange multipliers
to optimize functions of several variables given a constraint.
So here's a problem that you can practice this method on.
So I've got a function f of x, y, z equals
x squared plus x plus 2 y squared plus 3 z squared.
And what I'd like you to do is find the maximum and minimum
values that this function takes as the point (x, y, z)
moves around the unit sphere x squared plus y squared plus z
squared equals 1.
So to optimize this function given the constraint
x squared plus y squared plus z squared equals 1.
So why don't you pause the video, take some time
to work that out, come back, and we can work it out together.
Hopefully you had some luck working on this problem.
Let's have a go at it.
So remember that the method of Lagrange
multipliers-- in order to apply it-- what it says
is that when you have a function being optimized
on some constraint condition, what
you do to find the points where the function could be maximum
or minimum is that first you look for points where
the gradient of your objective function
is parallel to the gradient of your constraint function.
So what that means is you take the partial derivatives
f_x, f_y, f_z, and you say f_x has to be equal to lambda times
g_x, f_y has to be equal to lambda times g_y,
and f_z has to be equal to lambda times
g_z, for some lambda.
And then you solve that system together
with the constraint equation.
And so the points that are the solutions
of that system of equations, those points
are your points that you have to check for whether they're
the maximum or the minimum.
And also, sometimes you have some boundary to your region
and you have to check that as well.
So in this case, the sphere doesn't have boundary.
Right?
So we don't have any boundary conditions to check.
So we're going to have a really straightforward problem
to solve where we just have to look
at the partial derivatives.
So let's write down that system of equations
that we have to solve.
So the partial derivative of f with respect to x
is going to be 2x plus 1.
So we have to solve the system 2x plus 1 equals--
and the partial derivative of our constraint with respect
to x is 2x, so 2x plus 1 has to equal lambda times 2x.
That's what we get from the x-partial derivatives.
How about from the y-partial derivatives?
The y-partial derivative of f is going to be 4y.
So that has to be equal to lambda
and the y-partial derivative of the constraint equation
which is 2y.
And the z-partial derivative of f is 6z.
So 6z has to be equal to lambda times, well,
the z-partial derivative of the constraint function, which
is 2z.
And we have the last equation x squared plus y squared plus z
squared equals 1.
So we get four equations in our variables x, y, and z,
plus this new parameter lambda that we introduced.
And we want to solve these to find
the points x, y, and z at which these equations are all
satisfied.
And then, once we get those points,
we have to test them to see whether they
are the maximum or the minimum or neither.
So OK.
So we have this system of equations.
Now, this is a little bit complicated.
It's not a system of linear equations.
So we need to think about ways that we can solve it.
And one thing that I think we can do here,
is if you look at the second and third equations,
you see that in the second equation,
everything has a factor of y in it.
So either y is equal to 0, or we can divide by it.
So from the second equation, we have
that either y is equal to 0, or we
can divide by y, in which case we get lambda is equal to 2.
Similarly, from the third equation,
we have that either z is equal to 0, or we can divide by z
and we get lambda is equal to 3.
So from the third equation, we have z
equals 0 or lambda equals 3.
So now we have a bunch of possibilities, right?
So either we have y equals z equals 0, or we have y equals 0
and lambda equals 3, or we have lambda equals 2 and z equals 0.
Or, well, the other possibility would be lambda
equals 2 and lambda equals 3, but that can't happen.
So we have three possibilities.
Three different ways that this could be satisfied.
So let's go over here and write down
what those possibilities are.
So case one, or maybe I'll call it case a.
So the case a is when y is equal to z is equal to 0.
So when y is equal to z is equal to 0-- OK,
we need to find x still.
So let's look back at our equations.
And when y is equal to z is equal to 0,
well, we can solve our constraint equation for x.
When y equals z equals 0, we have that x squared equals 1.
So there are two possibilities.
The point (1, 0, 0), and the point minus 1, 0, 0.
So this gives us, in this case, we
have x equals 1 or x equals minus 1.
So that gives us the points (1, 0, 0)
and minus 1, 0, 0 that we're going
to have to check at the end.
All right.
So the second case is we could have y equal to 0
and lambda equal to 3.
So in this case, let's go back to our equations again.
So from lambda equals 3, we have in our first equation
that 2x plus 1 equals 6x.
So 1 equals 4x or x equals 1/4.
So this implies over here that x equals 1/4.
And now, we still need to find z.
So if we go back to our constraint equation here,
we have that x is a quarter and y is 0.
So that means 1/16 plus z squared equals 1.
So z has to be the square root of 15/16, plus or minus.
And z is equal to plus or minus--
so that we can also write that as the square root
of 15 over 4.
So this also gives us two points to check.
The points are 1/4, 0, the square root of 15 over 4.
And 1/4, 0, minus square root of 15 over 4.
And finally, we have our third case.
So our third case is when lambda is equal to 2
and z is equal to 0.
So again, let's go back over to our equation.
So when lambda equals 2 in the first equation,
we have 2x plus 1 equals 4x.
So 2x equals 1 or x is 1/2.
So this gives us x equals a half.
And now if you take z equals 0 and x equals 1/2,
we can take that down to our constraint equation.
And we get a quarter plus y squared equals 1,
so y is a square root of 3/4.
So y equals plus or minus square root of 3 over 2.
And this gives us two points.
1/2, square root of 3 over 2, 0.
And 1/2, minus square root of 3 over 2, 0.
Those were our three cases.
We've solved each of them.
We've solved each of them all the way down
to finding the points that they lead to.
Now remember, we said already that there's
no boundary to this region.
It's just the sphere.
It has no edges.
So these are the only points we have to check.
We have to check these six points.
What do we have to check them for?
Well, we have to look at the value of f
at each of these six points.
And we want to figure out where f is maximized
and where f is minimized, and these six points are
the only points where that could happen,
where f could be maximized or minimized.
So we just have to evaluate our objective function
f at these six points and find the largest
value and the smallest value.
So let's do that.
So our objective function, remember, it's
all the way back over here.
It's this function x squared plus x plus 2 y
squared plus 3 z squared.
OK.
So let's look at the value of that function at these point.
So x squared plus x plus 2 y squared
plus 3 z squared at the point 1, 0, that's just equal to 2.
So I'm going to write the function values just off
to the side of the points here.
So this gives me the value 2.
And I'm going to circle them.
So the point (1, 0, 0) gives me the value 2.
The point minus 1, 0, 0-- so that's x squared
is 1, plus x is minus 1-- so that's 1 minus 1
is 0-- and then the y and z terms are both 0.
So at the point minus 1, 0, 0, the function value is 0.
I'm going to circle that.
Oh boy.
OK, so at these points-- at the point 1/4, 0, square root
of 15 over 4, and 1/4, 0, minus square root of 15 over 4--
I'm going to cheat and look at what I wrote down already.
So you could do the arithmetic yourself,
but I think it's not that hard to work out
that in both of these cases, the function value that you get out
is 25 over 8.
I'm not going to do the arithmetic right now.
But you can double-check that for yourself.
And at these last two points-- the points 1/2,
root 3 over 2, 0, and 1/2, minus root 3 over 2,
0-- the function has the same value at both of those points.
That value is 9/4.
Yeah, so 25 over 8 was the value at both of these points,
and 9/4 is the value of both of these points.
So now, to find the maximum value of the function
and the minimum value of the function,
we just look at the values that we got and say,
which of these is biggest and which of these is smallest?
And in our case, it's easy to see that 0 is the minimum.
You know, all the other values are positive,
so 0 is the minimum.
So our minimum value of f is 0 at the point minus 1, 0, 0.
And if you just compare the values 2 and 25/8 and 9/4,
25/8 is the largest.
This is bigger than 3, whereas both of those are less than 3,
for example.
This is one easy way to see that.
So the max of f is 25/8, and that's
achieved at the points 1/4, 0, plus or minus
square root of 15 over 4.
So there you have it.
The method of Lagrange multipliers.
We just followed exactly the strategy that we have.
So you start out and you have an objective function
and a constraint function.
And so what do you do?
You write down their partial derivatives
and you come up with this system of equations.
So this system of equations that you get by setting,
you know, f_x equal to lambda g_x, f_y equal to lambda g_y,
f_z equals lambda g_z, and your constraint equation g
equals some constant.
So then the one part of this procedure that isn't just
a recipe is that you need to solve this system of equations,
but sometimes that can be hard.
So in this case, there were a couple of observations
that we could make from the second and third equations that
made it relatively straightforward to do.
And that gave us some cases.
And then in each of those cases, we
were able to completely solve for the points x, y, and z.
Now we also could solve for the associated values of lambda,
but lambda isn't important to us.
It doesn't affect f.
We can forget about it as soon as we found it,
once we found x, y, and z.
So we were able to solve.
In this case, we got six points of interest.
And then you just look at the value
of your objective function at those points.
So that was what I wrote down in these circles.
So you look at the value of the objective function.
And to find the maximum value of the function,
you just look at which of those is largest.
Now sometimes-- not in this problem, but in other problems,
you'll also have to check-- if the region has a boundary,
you'll also have to check for possible maxima and minima
on the boundary of the region.
But a sphere doesn't have any edges,
so it doesn't have any boundary.
So we don't have to worry about that.
So that's how we apply the method of Lagrange multipliers
to this problem.
And how you can apply it to other problems as well.
I'll end there.