Hi everyone, welcome to our lecture on a directional derivatives and the gradient vector. all right, so recall what we have so far. If I have some three-dimensional space and I have some generic function, draw the magic carpet is your default. So we'll say this is z equals f of x, y. And I want to know, I pick a certain point I want to study what happens, I want to study the rate of change at a certain point. Let's pick a specific point, we'll call it P, which is x-naught, y-naught, some given point in the x, y plane and we want to know what happens to that point when we evaluate it at the function that gives us a point on the graph. So our specific value our f of P, if you want to call it that. We know that if we look at partial derivatives, we have so far that the partial derivative with respect to x at P, so this treats y constant and this treats x as the variable. So x is free to move from the reminder the x direction is the one that sort of comes off the screen and y is the one to the right. So x is free to move and why is sort of fixed. So if we're going to move and draw, we're going off the screen and I get a nice line in the x-direction, when I talk about the partial derivative with respect to x and this is the slope or perhaps rate of change in the x-direction with the y-variable fixed. We compute these algebraically, we plug in numbers and we get some number and this tells us the slope. This is like the 3 equivalent [inaudible] but because there are infinitely many tangent lines at a given point, then we have to pick a direction. So which one do we want? Do we want the one that goes in the x-direction or the north-south one? You could also, if you wanted to study how the range changes, the landscape changes if you move east to west, if you draw a line in the y direction and the slope of this line is f y of P. This is the same thing. This is a slope, or perhaps more interesting, the rate of change in the y-direction and I really should clarify, of course, this is at P and in this particular example we have the partial derivative with respect to y. So y is the variable and so x is fixed. The thing to realize here is yes, algebraically you're fixing a variable and you're talking about one specific direction, but you're really getting the north, south or east west version. You're going in the x direction and the y direction and you can imagine like these things do not have to be the same. You ever gone on a hike. Imagine you're kind of taking a hike and you're in some mountain range. If you walk straight, maybe the road is a little steeper and if you walk [inaudible] 90 degrees and walk up in that direction, perhaps the path is less steep or something like that. You tend to follow the path it's on but if you turn left, you might be in a very steep hill. So steepness changes based on the direction. So one of the things that you might ask, as the next natural question is, what happens if we want the rate of change in any direction? So not just north-south, not just east-west, maybe I want 45 degrees or some other specific thing. The object to that gives us that is what's called the directional derivative. So let's define that now. So the directional derivative, and this is denoted as D u of f, u as the subscript with a little vector on top and f corresponding to the function and this is defined to be, and I'm going to put the symbols down first and then we'll talk about it. We'll call it the gradient of f. I will define that I promise. Evaluated at p, p is a point given, dot the vector u. I have to tell you all these things are, [inaudible] just yet. So this is the rate of change in the direction of u. So this is the rate of change at a given point P and direction. Remember, directions are given as vectors. I will tell you what all these other things mean in a second, but before we work this out and go through this, let's just appreciate what this is. So let's say you wanted the direction not in the North-South and not in East-West, how is this magic carpet slope changing in some diagonal direction? To do that, you will come down your point and you will define the vector in the direction you want. I always think about this like P is like a little person. You're standing and you have a compass and the needle of the compass can move and whatever direction the compass is pointing in, there is your vector u. So the u will be given, one of the key things that we need and why we use u here is that, u must be a unit vector. So friendly reminder, a unit vector is a vector whose magnitude is length 1. It is often not given as a unit vector, so you will usually have to normalize. So just be careful here. We'll do examples where we normalize these things and so to find the slope of this line, you can imagine this line is going to teeter like a seesaw until lands tangentially on the surface. To find the slope, the rate of change in that direction, we need this thing called delta f here and this delta f is the other name of the title this is a vector, so sometimes you'll see it actually with the little vector notation on top and this is the gradient vector. This is the name of this. This is the gradient vector. This vector has a nice little vector and it is formed by finding the vector of partials, it is the vector of partial derivative. You thought derivatives were important, you can imagine that, well, putting them together in one single object, like a vector, it's pretty important. This vector gets a name, it is called the gradient vector and you can count it as the definition itself. If you look at this thing, it's basically like a recipe, we're just going to build this up. But let's think of the steps for a minute. Step 1 is, they'll give you P and they'll give you some vector. Step 1, you want to ask yourself, is U a unit vector? If not, we're going to normalize. Step 2 is we're going to get the gradient vector, that might mean we take a couple of partial derivatives. That's okay, we're good at that now, and one thing I want to call out, and a lot of people forget this and we're going to make this its own separate step, step 3 is to evaluate at P. We have to plug in to these partials. We don't want some big algebraic expression. We really want number times and common number. Last but not least, we have a vector, we have another vector, what's a nice way to get a scalar? We take the scalar product or the dot product. Our dot product is going to be step number 4. This is the four-step process to find this thing. But once you have this, well then hey, you can do it for any step you want. All right let's do an example. Let's do one with ugly numbers, but I get straight forward functions. Let's find the directional derivative, D_u of F, if F of x, y is x cubed minus 3xy plus 4y squared, if the unit vector U is root 3 over 2, 0.5. A couple things about this one, why they're being nice, why this is a nice first example, notice that they're handing you a unit vector, so they're doing step 1 for you. We'll still think about it though. Is U a unit vector? If not, we have to normalize, but in this case it is, they actually tell you it is, so they're doing one of the steps for you. It's a good maybe perhaps check, you can check, find the magnitude of U and show it is in fact equal to 1. Then step 2 now we got to go get the gradient vector, let's go find the gradient vector, which for us is the vector of partials. This is the vector f_x , f_y, for our particular case, I think we could do this pretty simple, there we go. The function is x cubed minus 3xy plus 4y squared. Partial derivative is 3x squared minus 3x, partial derivative with respect to y is minus 3x plus 8y. We find the partial derivatives, we find two of them. That is okay. Let's make this a separate step. Step 3, we're going to plug in, we're going to evaluate this function at our point. This is also written with the evaluation bar, but you can write it as F of root 3, over 2, 0.5. That's not so nice, but when you plug in, oh I forgot to give you the point, ha just kidding. At P equals 1, 2. We're not going plug in, oh man, totally wrong idea, sorry about that, must have been my notes. The point is 1, 2. We're going plug in at that point P, which is 1, 2. That's much nicer, good thing I caught that. We're going to plug in and everywhere we see an x, we're going plug in 1. Everywhere we see a y, we are going to plug in 2. You can check when you do this, you get negative 3, 13. Last but not least, our fourth step. We're going to find this directional derivative, and remember this is going to be the rate of change in the direction 1, 2. This is going to be the vector minus 3, 13 dot the unit vector which is root 3 over 2, 0.5, there it is. You put it together and you don't get the world's prettiest number, but so be it. You get a minus 3 root 3, over 2, plus 13 over 2. I guess you could combine it for no good reason. 13 minus 3 root 3 over and there you have it. This is a number, it's not the prettiest number, but it's some number. What is it doing? If you have your magic carpet, whatever the graph of this degree 3 polynomial is, you pick your point 1, 2. You come out on the x-axis 1, you go over 2, you look above it and you say,"How is the direction changing? If I draw my vector u, whatever direction it points", and you say,"Well, what is the tangent line? What is the line in that direction? What is the slope?" That slope turns out to be 13 minus 3 root 3 divided by 2. Just a process, just a number. Just take some time and practice getting used to it. Let's do one more example. Hopefully this time I'll remember to give you. Let's do an example here. Let's find the directional derivative. Find D_u of F, when F of x, y, z equals x plus 2y plus 3z raised to the 3 over 2, at P 1, 1, 2 in the direction of the vector 2j minus k. All right this is a good question. If you want to pause for a minute, there's a lot news, more new things going on here. Let's go through this one a little slowly. First off, what's new about it? X, y, and z, three variables, so my gradient vector is going to have three components, partial with respect to x, partial with respect to y, partial with respect to z. I have a point, I have my direction vector. I'm not an IJK kind of person. When you hand me something in IJK notation, just remember what this means. There's no i-component here, so it's like 0 I, 2 J, and then minus 1 K. I like to take it out of IJK notation, that's just my preference. Here we go, let's go to our steps. We want to find the unit vector. Now, this is going to come from the direction of V. Hopefully, a quick check will show that V is not in fact a unit vector, so we need to normalize V, the normalization of V is going to be the vector divided by its length. That's okay, and the vector divided by its length is going to be 0, 2, minus 1, divided by the square root of 0 squared plus 2 squared plus minus 1 squared. That of course is, what is that? 0 plus 4, plus 1, so that's root 5. You get 1 over root 5, 0, 2, minus 1. You can leave the root 5, the 1 over root 5 out or you can absolutely bring it in. There's no right or wrong answer here. If you want to. Unit vectors tend to look like square roots all over the place. We'll bring it in and distribute that scalar to all components. We have a nice unit vector. Step two, we're going to find our gradient vectors. We're going to find some partial derivatives here. We have three variables, X, Y, and Z. Like I said before, we have to find three partial derivatives. Here we go, let's do them carefully. So F of X is 3 over 2. We bring the exponent down, we keep the inside the same, X plus 2 Y, plus 3 Z. We subtract 1 from 1 and a half, to give us a half and then Chain Rule kicks in and we multiply by the derivative of the inside. For us, that's just the one on the X. So I'll write a times 1, so we don't forget. Partial with respect to Y, it's going to look very similar. Bring the three-halfs down. Keep the inside the same, X plus 2 Y plus 3 Z. Subtract one from the exponent, and then we multiply by the partial with respect to Y. Last but not least, F of Z, 3 over 2, X plus 2 Y plus 3 Z to the one half. Then partial times inside, Chain Rule kicks in and we have a nice 3. We find the three partials, we check, we make sure it looks good. Then of course step three is we evaluate, we find the gradient evaluated at P. Let's do this carefully, if I plug in, remember my point is 1, 1, 2. What's nice about this, if you plug in, which is going to be a vector here. We're going to get 3 over 2. Then we get 1 plus 2 plus 6, 3 times 2. So I plugged in X equals 1, Y equals 1, and Z equals 2, you get 1 plus 2 plus 6. That works out nicely to be 6 plus 3, of course 9 to the 1 half, times 1. You can see even though there's kind of a nasty expression to 1 half, it just works out to be 9 to the 1 half or square root of 9. That of course gives you three. We'll clean this up in a second, but basically you're going to get 3 over 2 times, 3 times 2 for the second component. For the third component, you get 3 over 2, times 3, times 3. Not as bad, I guess as it could. We could factor out a 3 over 2, keep the constants out front. You get, 3, 6, and 9. All right, not too bad. Last but not least, we find the Directional Derivatives. So we're going to find DU of F. Friendly reminder of what the formula says to do, says take the partial evaluated at P or plugged in at P, dot the unit vector. Our unit vector here has the scalar. Maybe we'll use this version here with the scalar out front. You do a dot product, you can move all scalars out front. So we have 3 over 2, 1 over root 5 and our two vectors become 0, 2 minus 1, dot 3, 6, and 9. Put it all together and you get 3 over 2 root of 5. So multiply the scalars together and then dot-product to get 0, plus 12 minus 9, or basically 12 minus 9 puts another three on the table. You get basically 9 over 2 root 5. All right, hopefully I didn't make any mistakes on that one, but the steps are perhaps more important and you can go through and check and make sure. But at the end of the day remember, the Directional derivative is the most generalized form of a slope that we've seen and we should absolutely get a number. Before we go on to maybe more examples, let's do a little bit of theory. We want to look at the formula for the Directional derivative a little more closely. So we define the Directional derivative to be the gradient vector evaluated at some point P, times this given unit vector. The vector that signifies the direction that we're interested in. This is a dot product, and remember we had an alternate version of the dot-product. So what happens if we use that alternate version. Friendly minder, What was it? It's the magnitude of the first vector, times the magnitude of the second vector, times cosine theta, where theta is the angle between the two vectors. This formula, there isn't too much you can do to it. Use a unit vector, its magnitude is in fact just one and it simplifies also slightly, but still in a pretty useful way. This turns out that the magnitude or the directional derivative, the slope, is a function of theta. Remember theta is the angle that's being formed by the direction vector and the gradient vector, the vector in the partials there. If we think of this as a function about components, one question you can ask yourself is, what is the maximum rate of change? If you're hiking or something like this, you can think about, what does the steepest sometimes from mountains and stuff you call like, what is the steepest descent or something like that, steepest descent? How do we maximize this thing? Where can I get my compass to point to me in the fastest route? The maximum rate of change, well, this magnitude over here at a point this is just some constant. Theta is the only thing that's varying and that maximal rate of change, well, that occurs when cosine maxes out. Well, what's the maximum cosine? That's of course is just 1 and you say, well, okay, so how do I get cosine to be 1? Well, that's equivalent to saying that theta equals 0 and what does it mean for two angles to have the angle between them to be 0 It means that they're parallel to each other. They're pointing in the same direction. That just means that the gradient is parallel to u. Parallel just means that they point in the same direction. This is interesting. If you're a hiker and you're trying to go up the mountain in the absolute fastest way, then you always want to follow the gradient. Remember the gradient it changes whatever point you're standing at. Basically you take a step and you re-evaluate yourself and yet a compass that always points in the gradient and you just follow that arrow and you get up the fastest. This is important enough to be a theorem and it says that the maximum value of the directional derivative is the magnitude of the gradient. You want maxes out you may cosine one, you're just left with the magnitude of the gradient at any point and it occurs when the direction, the unit vector u that you're pointing in has the same direction as the gradient. One time the maximum value of the directional derivative is the magnitude of the gradient. This occurs when you has the same direction as the gradient vector. You're going to see this a lot we care about how to maximize functions. We find the maximum value. It's a fancy way to say take the gradient and take a magnitude, the steps are not difficult take partials plugin if you're at a point or something like that and then take its magnitude. We'll do an example in a second, but it's more important that sort of idea. Nowhere in the statement like find the max value does it say gradient. You just have to know that the gradient vector maximizes the rate of change. If you were trying to find the steepest tangent line, this has to go up or I guess to go down. You could negate this thing and this is interesting because nature does this. Like if you take a drop of water and you let it fall, it's going to take the quickest to sent to the bottom. The path that it just knows how to take is going to be in the over descending. The negative gradient direction, it's taking the steep, it doesn't take like a slow windy road to get to the bottom. It's like the best fastest way to get down and that's going to be negative the gradient when you're descending. If for whatever reason you're trying to go to the top of them out and the fastest, you always follow the gradient vector wherever it points to at any given point. Let's do one more example and then we'll be all done. Example, find the max rate of change of some function f of y is y squared over x at the point 2, 4. Here it is. There's the magic words, maximum rate of change. If this thing changes a lot, but what's the maximum rate? Well, remember what we're after and we want the magnitude of the gradient at the point. Let's take this in order step 1, find a gradient. This is the vector of partials we only have x and y, so we're just going to have vector with two components. The partial with respect to x is negative y squared over x squared. The partial with respect to y is 2y over x. I guess we should plugin at the point is a important step that people forget. When we do this, remember y is 4, so we get negative 4 squared which is 16 over 2 squared which is 4, 2 times y is 8 over 2. Clean this up a little bit. You get minus 4, 4. Then last but not least step 3 is we take the magnitude of this vector. This will be the magnitude of the vector negative 4, 4 and this of course the formula is take each component throw it under a square root and sum the squares. This gives us the square root of 16 plus 16, or perhaps the square root of two times 16, which is the square root of two, times the square root of 16, which is of course, 4 root 2. As expected we get a number back. Sometimes people trying to hand me back a vector or something weird here like or finding a rate of change. This is the slope. Make sure when you answer these things, you're giving back a number. Hardest part about this thing is not the steps and honesty is recognizing the theory that the maximum rate change comes from the directional derivative maxing out and therefore giving the magnitude of the gradient. We're putting all our smaller formulas together, using them all to really just see how to find and how to use these, all these partial derivatives. Alright, so great job on this video. Review as you need to keep the formulas handy, and I'll see you next time.