WEBVTT
00:00:07.026 --> 00:00:07.650
JOEL LEWIS: Hi.
00:00:07.650 --> 00:00:09.180
Welcome back to recitation.
00:00:09.180 --> 00:00:11.950
In lecture, you've learned
about gradients and about
00:00:11.950 --> 00:00:13.170
directional derivatives.
00:00:13.170 --> 00:00:16.500
So I have a problem here
to test your understanding
00:00:16.500 --> 00:00:20.820
of those objects and give you
some practice computing them.
00:00:20.820 --> 00:00:23.869
So I have three functions here.
00:00:23.869 --> 00:00:25.410
And for each function,
I've given you
00:00:25.410 --> 00:00:27.260
a point and a direction.
00:00:27.260 --> 00:00:30.020
So what I'd like
you to do is compute
00:00:30.020 --> 00:00:32.310
the gradients of
the functions, then
00:00:32.310 --> 00:00:34.900
evaluate their gradients
at the point given,
00:00:34.900 --> 00:00:38.830
and then compute the directional
derivative of the function
00:00:38.830 --> 00:00:42.250
at the point in the direction
of the vector given.
00:00:42.250 --> 00:00:44.070
So here, for example,
in part a, I've
00:00:44.070 --> 00:00:48.270
given you the function f of x,
y equal to x squared y plus x
00:00:48.270 --> 00:00:52.740
y squared, at the point x
equal minus 1, y equal 2,
00:00:52.740 --> 00:00:56.400
and in the direction
of the vector [3, 4].
00:00:56.400 --> 00:00:59.729
And then we've got two more
examples here. g of x, y, z
00:00:59.729 --> 00:01:02.020
is equal to the square root
of x squared plus y squared
00:01:02.020 --> 00:01:05.400
plus z squared, P is
the point 2, 6, minus 3,
00:01:05.400 --> 00:01:07.480
and v is the
direction [1, 1, 1].
00:01:07.480 --> 00:01:10.870
And our third example, h is a
function of four variables, w,
00:01:10.870 --> 00:01:12.220
x, y, and z.
00:01:12.220 --> 00:01:19.130
It's given by w*x plus w*y plus
w*z plus x*y plus x*z plus y*z,
00:01:19.130 --> 00:01:23.180
at the point 2, 0, minus 1,
minus 1, in the direction 1,
00:01:23.180 --> 00:01:26.030
minus 1, 1, minus 1.
00:01:26.030 --> 00:01:28.390
So why don't you pause
the video, take some time
00:01:28.390 --> 00:01:30.374
to work out these three
problems, come back,
00:01:30.374 --> 00:01:31.790
and we can work
them out together.
00:01:40.350 --> 00:01:42.760
I hope you had some luck
working out these problems.
00:01:42.760 --> 00:01:46.560
Let's get started
on the first one.
00:01:46.560 --> 00:01:52.260
So on the first one,
our function f of x, y
00:01:52.260 --> 00:01:57.330
is equal to x squared
y plus x y squared.
00:01:57.330 --> 00:01:59.120
So to compute the
gradient, I just
00:01:59.120 --> 00:02:01.540
have to compute the first
partials of our function,
00:02:01.540 --> 00:02:03.570
and then put them
into a single vector.
00:02:03.570 --> 00:02:04.910
So that's what the gradient is.
00:02:04.910 --> 00:02:09.790
So we have that the
gradient of f at (x,
00:02:09.790 --> 00:02:12.760
y) is equal to--
it's the vector,
00:02:12.760 --> 00:02:16.650
and its first component is the
first partial of f with respect
00:02:16.650 --> 00:02:23.270
to x, so that's going to
be 2x*y plus y squared.
00:02:23.270 --> 00:02:26.580
And its second component is the
partial of f with respect to y,
00:02:26.580 --> 00:02:31.920
so that's going to be
x squared plus 2x*y.
00:02:31.920 --> 00:02:34.400
So this is the gradient
of our function f.
00:02:34.400 --> 00:02:36.780
Now, the question asked you
to compute this gradient
00:02:36.780 --> 00:02:40.620
at the particular
point minus 1, 2.
00:02:40.620 --> 00:02:44.520
So we have gradient of
f at the point minus 1,
00:02:44.520 --> 00:02:48.390
2 is equal to-- well, we
just put in x equal minus 1,
00:02:48.390 --> 00:02:50.310
y equal 2 into this formula.
00:02:50.310 --> 00:02:54.060
So at x equal minus 1, y
equals 2, this is 2 times
00:02:54.060 --> 00:02:56.480
minus 1 times 2 plus 2 squared.
00:02:56.480 --> 00:02:59.260
So that's minus 4 plus
4, so that's just 0.
00:02:59.260 --> 00:03:04.750
And the second term is
minus 1 squared plus 2 times
00:03:04.750 --> 00:03:06.180
minus 1 times 2.
00:03:06.180 --> 00:03:11.730
So that's 1 plus 4--
nope-- 1 plus negative 4,
00:03:11.730 --> 00:03:14.390
so that's negative 3.
00:03:14.390 --> 00:03:14.890
All right.
00:03:14.890 --> 00:03:17.650
So this is the gradient
of our function f.
00:03:17.650 --> 00:03:20.820
This is the gradient at
the point minus 1, 2.
00:03:20.820 --> 00:03:23.950
Now we are asked for the
directional derivative.
00:03:23.950 --> 00:03:26.350
So we were asked for the
directional derivative
00:03:26.350 --> 00:03:29.745
of f in a direction.
00:03:29.745 --> 00:03:34.400
So we're given-- I didn't give
you-- so I gave you a vector v.
00:03:34.400 --> 00:03:37.620
But when we take directional
derivatives, what we want
00:03:37.620 --> 00:03:39.450
is a unit vector.
00:03:39.450 --> 00:03:40.020
Right?
00:03:40.020 --> 00:03:43.790
So the vector v that I gave
you-- was right over here--
00:03:43.790 --> 00:03:46.820
it was this vector, [3, 4].
00:03:46.820 --> 00:03:51.050
And so we need to find the unit
vector u in the direction of v
00:03:51.050 --> 00:03:53.750
in order to apply
our usual formula.
00:03:53.750 --> 00:04:00.040
So u is just v divided
by the length of
00:04:00.040 --> 00:04:04.020
v. So in this case,
the vector [3, 4],
00:04:04.020 --> 00:04:06.450
by the Pythagorean
theorem, it has length 5.
00:04:06.450 --> 00:04:14.110
So this is equal to the
vector 3/5 comma 4/5.
00:04:14.110 --> 00:04:16.440
And so our
directional derivative
00:04:16.440 --> 00:04:19.790
in the direction of v--
which is this vector
00:04:19.790 --> 00:04:23.280
u-- it's just equal to
the gradient at that point
00:04:23.280 --> 00:04:25.690
dotted with the
direction vector.
00:04:25.690 --> 00:04:32.990
So this is equal to gradient
of f at that point dot u.
00:04:32.990 --> 00:04:36.790
Which in our case
is equal to-- well,
00:04:36.790 --> 00:04:39.880
since we're interested at the
point P-- it's equal to 0,
00:04:39.880 --> 00:04:47.650
minus 3, dot our vector
u, which is [3/5, 4/5].
00:04:47.650 --> 00:04:51.680
And that dot product
is negative 12/5.
00:04:51.680 --> 00:04:54.520
So in this direction,
the function
00:04:54.520 --> 00:04:58.370
is decreasing at about this
rate at the given point.
00:04:58.370 --> 00:04:58.870
All right.
00:04:58.870 --> 00:05:00.050
That's part a.
00:05:00.050 --> 00:05:02.340
Let's go on to part b.
00:05:02.340 --> 00:05:05.380
So, you know, you've probably
noticed that these questions
00:05:05.380 --> 00:05:06.410
are all fairly similar.
00:05:06.410 --> 00:05:11.020
The only real complication
is that I've been increasing
00:05:11.020 --> 00:05:12.072
the number of variables.
00:05:12.072 --> 00:05:13.530
But of course, you
know how to take
00:05:13.530 --> 00:05:16.010
a gradient for a function
of three variables as well.
00:05:16.010 --> 00:05:21.980
So in this case, our
function g of x, y, z
00:05:21.980 --> 00:05:25.660
is given by the square
root of x squared
00:05:25.660 --> 00:05:29.330
plus y squared plus z squared.
00:05:29.330 --> 00:05:31.760
So, if you like,
this is the function
00:05:31.760 --> 00:05:36.890
that measures the distance
of a point from the origin.
00:05:36.890 --> 00:05:42.146
And so we're asked first for the
gradient, so the gradient of g.
00:05:45.499 --> 00:05:46.040
What do I do?
00:05:46.040 --> 00:05:50.020
Well, again, I just take
these partial derivatives.
00:05:50.020 --> 00:05:52.902
This is going to be a tiny
bit messy, I'm afraid.
00:05:52.902 --> 00:05:54.360
Because I take a
partial derivative
00:05:54.360 --> 00:05:56.140
of this expression
with respect to x,
00:05:56.140 --> 00:05:57.980
I've got to apply the
chain rule, right?
00:05:57.980 --> 00:06:01.551
Because this is a composition
of functions here.
00:06:01.551 --> 00:06:02.050
So OK.
00:06:02.050 --> 00:06:03.580
So, what do I get?
00:06:03.580 --> 00:06:08.161
I get the derivative of the
inside times the derivative
00:06:08.161 --> 00:06:08.660
of the out.
00:06:08.660 --> 00:06:10.368
So the outside function
is a square root,
00:06:10.368 --> 00:06:12.470
so that's to the
one halfth power.
00:06:12.470 --> 00:06:18.665
So I get 1/2 times the thing
inside to the minus one halfth
00:06:18.665 --> 00:06:19.165
power.
00:06:19.165 --> 00:06:21.360
So it's over 2 times
the square root
00:06:21.360 --> 00:06:26.160
of x squared plus y
squared plus z squared.
00:06:26.160 --> 00:06:29.845
And then I need to multiply by
the derivative of the inside,
00:06:29.845 --> 00:06:32.150
which is times 2x.
00:06:32.150 --> 00:06:32.650
OK.
00:06:32.650 --> 00:06:34.360
So, and then the 2's
cancel, and that's
00:06:34.360 --> 00:06:37.880
x over square root of x squared
plus y squared plus z squared.
00:06:37.880 --> 00:06:40.410
And similarly, this is a
nice symmetric function,
00:06:40.410 --> 00:06:43.200
and, you know, if I changed
x and y, it's the same.
00:06:43.200 --> 00:06:45.770
So the other partial
derivatives look very similar.
00:06:45.770 --> 00:06:49.970
So they're going to be y over
the square root of x squared
00:06:49.970 --> 00:06:53.730
plus y squared plus z squared.
00:06:53.730 --> 00:07:00.530
And z over the square root of
x squared plus y squared plus z
00:07:00.530 --> 00:07:01.810
squared.
00:07:01.810 --> 00:07:02.310
Sorry.
00:07:02.310 --> 00:07:05.090
That's a little bit of
a long formula there.
00:07:05.090 --> 00:07:06.450
But there we have it.
00:07:06.450 --> 00:07:09.230
That's the derivative-- or,
sorry, not the derivative.
00:07:09.230 --> 00:07:10.190
That's the gradient.
00:07:10.190 --> 00:07:13.100
The vector of
partial derivatives.
00:07:13.100 --> 00:07:16.710
So now you were asked also
to compute this gradient
00:07:16.710 --> 00:07:17.970
at a particular point.
00:07:17.970 --> 00:07:23.020
So the point in question-- I
have to look back over here.
00:07:23.020 --> 00:07:29.220
And the point in question was
this point, 2, 6, minus 3.
00:07:29.220 --> 00:07:31.362
So at the point
2, 6, minus 3, we
00:07:31.362 --> 00:07:32.570
want to compute the gradient.
00:07:32.570 --> 00:07:35.080
So we just take these
numbers back over
00:07:35.080 --> 00:07:37.570
to our formula over there, and
we're going to put them in.
00:07:37.570 --> 00:07:44.940
So we take the gradient
of g at 2, 6, minus 3.
00:07:44.940 --> 00:07:49.140
Well, OK, so this square root of
x squared plus y squared plus z
00:07:49.140 --> 00:07:50.420
squared appears in all terms.
00:07:50.420 --> 00:07:51.610
So let's compute that first.
00:07:51.610 --> 00:07:56.370
So x squared is 4, y squared
is 36, and z squared is 9.
00:07:56.370 --> 00:07:59.910
So I add those numbers
together, I get 49.
00:07:59.910 --> 00:08:02.600
And then I take a square
root of that and I get 7.
00:08:02.600 --> 00:08:06.480
So these denominators are all
going to be 7, and then up
00:08:06.480 --> 00:08:08.820
top I just have x, y, and z.
00:08:08.820 --> 00:08:13.580
So this is going to
be 2 over 7 comma
00:08:13.580 --> 00:08:19.640
6 over 7 comma minus 3 over 7.
00:08:19.640 --> 00:08:20.330
All right.
00:08:20.330 --> 00:08:23.790
So just what I get by plugging
the values at our point
00:08:23.790 --> 00:08:24.630
into this formula.
00:08:24.630 --> 00:08:26.890
So this is the
gradient at that point.
00:08:26.890 --> 00:08:29.940
And now once again,
I want to compute
00:08:29.940 --> 00:08:32.770
a particular directional
derivative of this function.
00:08:32.770 --> 00:08:35.740
So in order to do that, I just
need the right unit vector,
00:08:35.740 --> 00:08:38.000
and I need to dot it.
00:08:38.000 --> 00:08:40.060
So the direction
that I asked you
00:08:40.060 --> 00:08:46.380
was the direction v with
coordinates 1, 1, 1.
00:08:46.380 --> 00:08:48.340
So of course again, this
isn't a unit vector.
00:08:48.340 --> 00:08:51.170
So we need to divide it by
its length to find the unit
00:08:51.170 --> 00:08:53.740
vector that we're going to use.
00:08:53.740 --> 00:08:56.520
So the length of this vector
is the square root of 1
00:08:56.520 --> 00:08:58.105
squared plus 1 squared
plus 1 squared,
00:08:58.105 --> 00:08:59.950
so that's the square root of 3.
00:08:59.950 --> 00:09:03.050
So u is equal to--
well, I'm just
00:09:03.050 --> 00:09:06.080
going to write it as 1
over the square root of 3
00:09:06.080 --> 00:09:08.970
times the vector [1, 1, 1].
00:09:13.410 --> 00:09:20.450
And so the directional
derivative dg/ds
00:09:20.450 --> 00:09:24.030
in the direction u hat is--
again, it's what I get,
00:09:24.030 --> 00:09:32.500
I dot the gradient with this
u-- it's gradient dot u.
00:09:32.500 --> 00:09:35.830
Which in our case, so that
1 over the square root of 3
00:09:35.830 --> 00:09:36.720
lives out front.
00:09:40.240 --> 00:09:45.730
And now I dot 2/7, 6/7,
minus 3/7 with [1, 1, 1].
00:09:45.730 --> 00:09:55.287
And that's just going to give
me 2/7 plus 6/7 minus 3/7.
00:09:55.287 --> 00:09:57.370
And OK, so we can finish
off the arithmetic there,
00:09:57.370 --> 00:10:01.430
and I think that's 5
over 7 square root of 3
00:10:01.430 --> 00:10:03.550
if I didn't make any mistake.
00:10:03.550 --> 00:10:05.960
Now, the last one,
very, very similar.
00:10:05.960 --> 00:10:08.880
Now we have a function
of four variables.
00:10:08.880 --> 00:10:11.060
There's really nothing
new there at all.
00:10:11.060 --> 00:10:12.565
So let me rewrite.
00:10:12.565 --> 00:10:20.110
So for part c, we
have h of w, x, y,
00:10:20.110 --> 00:10:34.060
z is equal to w*x plus w*y plus
w*z plus x*y plus x*z plus y*z.
00:10:34.060 --> 00:10:40.770
So, for the gradient
of h, I just
00:10:40.770 --> 00:10:42.190
take the four
partial derivatives.
00:10:42.190 --> 00:10:43.900
Now here, w is first.
00:10:43.900 --> 00:10:46.290
So I take the partial
derivative with respect
00:10:46.290 --> 00:10:48.460
to w as the first coordinate.
00:10:48.460 --> 00:10:53.105
So that's going to
be x plus y plus z.
00:10:53.105 --> 00:10:55.230
And then I take the partial
derivative with respect
00:10:55.230 --> 00:10:57.080
to x as the second coordinate.
00:10:57.080 --> 00:11:00.845
So that's going to
be w plus y plus z.
00:11:00.845 --> 00:11:09.894
And similarly, the last two are
w plus x plus z, and w plus--
00:11:09.894 --> 00:11:15.270
that's a plus-- x plus y.
00:11:15.270 --> 00:11:15.770
Whew.
00:11:15.770 --> 00:11:16.269
OK.
00:11:16.269 --> 00:11:18.760
So that's my gradient.
00:11:18.760 --> 00:11:20.260
Those are my
partial derivatives.
00:11:20.260 --> 00:11:23.620
Now, I asked you again for the
gradient at a particular point.
00:11:23.620 --> 00:11:30.690
So that's grad h at the
point 2, 0, minus 1, minus 1.
00:11:30.690 --> 00:11:32.200
So we can just plug that in.
00:11:32.200 --> 00:11:36.330
Here, it's 0 plus minus 1
plus minus 1 is minus 2.
00:11:36.330 --> 00:11:41.290
Here it's 2 plus minus 1
plus minus 1, that's 0.
00:11:41.290 --> 00:11:45.660
Here, it's 2 plus 0 plus
minus 1 so that's 1.
00:11:45.660 --> 00:11:51.560
And lastly, it's 2 plus
0 plus minus 1 is 1.
00:11:51.560 --> 00:11:59.360
So that's the gradient of this
function h at this point P.
00:11:59.360 --> 00:12:02.800
And now I gave you again, I
gave you a vector v. So this
00:12:02.800 --> 00:12:07.900
was the vector 1,
minus 1, 1, minus 1.
00:12:07.900 --> 00:12:10.170
And I asked you to find
the directional derivative
00:12:10.170 --> 00:12:11.930
at this point in that direction.
00:12:11.930 --> 00:12:13.770
Again, we need a unit vector.
00:12:13.770 --> 00:12:15.260
This isn't a unit vector.
00:12:15.260 --> 00:12:22.000
So u is equal to v over the
length of v. Well, what is
00:12:22.000 --> 00:12:24.470
the length of v in this case?
00:12:24.470 --> 00:12:30.679
It's over the square root of--
well, we square the coordinates
00:12:30.679 --> 00:12:31.220
and add them.
00:12:31.220 --> 00:12:33.305
So that's 1 plus
1 plus 1 plus 1.
00:12:33.305 --> 00:12:35.520
So that's 4; square rooted is 2.
00:12:35.520 --> 00:12:36.970
So that's v over 2.
00:12:40.330 --> 00:12:47.510
And finally, I get that the
directional derivative dh/ds
00:12:47.510 --> 00:12:50.980
in this direction
u, is what I get
00:12:50.980 --> 00:12:54.550
when I dot this
gradient together
00:12:54.550 --> 00:12:57.340
with the direction
in which I'm heading.
00:12:57.340 --> 00:13:02.160
So this is minus 2, 0, 1, 1.
00:13:02.160 --> 00:13:07.330
The gradient dotted with the
unit vector of the direction.
00:13:12.060 --> 00:13:13.500
Which we just computed.
00:13:13.500 --> 00:13:15.710
And so finally, you could
expand this out yourself.
00:13:15.710 --> 00:13:17.800
I won't write down
the final answer,
00:13:17.800 --> 00:13:21.610
but it's just a
dot product, right?
00:13:21.610 --> 00:13:22.180
All right.
00:13:22.180 --> 00:13:25.950
So hopefully this has
gotten you totally
00:13:25.950 --> 00:13:27.850
comfortable with
computing gradients
00:13:27.850 --> 00:13:30.920
and with computing directional
derivatives from gradients.
00:13:30.920 --> 00:13:32.580
So I'll end there.