If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

# Gradient and graphs

## Video transcript

so here I'd like to talk about what the gradient means in the context of the graph of a function so in the last video I defined the gradient but let me just take a function here and the one that I have graphed is x squared plus y squared f of X y equals x squared plus y squared so two-dimensional input which we think about as being kind of the xy-plane and then a one-dimensional output that's just the height of the graph above that plane and I defined in the last video the gradient to be a certain operator an operator just means you take in a function and you output another function and we use this upside-down triangle so it gives you another function that's also of x and y but this time it has a vector-valued output and the two components of its output are the partial derivatives partial of F with respect to X and the partial of F with respect to Y so for a function we actually evaluated it let's take a look the very the first one is taking the derivative with respect to X so it looks at X and says you look like a variable to me I'm going to take your derivative you're 2 X 2 X but the Y component just looks like a constant as far as the partial X is concerned and the derivative of a constant is 0 but when you take the partial derivative with respect to Y things reverse it looks at the X component and says you look like a constant your derivative is 0 but it looks at the Y component and says ah you look like a variable your derivative is 2y so this ultimate function that we get the gradient which takes in a two variable input X Y some point on this plane but outputs a vector can nicely be visualized with a vector field and I have another video on vector fields if you're feeling unsure but I want you to just take a take a moment pause if you need to and guess or try to think about what vector field this will look like I'm going to show you in a moment but what's it going to look like the one that it takes in X Y and outputs to X to Y alright have you done it have you thought about what it's going to look like here's what we get it's a bunch of vectors pointing away from the origin and the basic reason for that is that if you have any given input point and say it's got coordinates X Y then the vector that that input point represents would you know if it went from the origin here that's what that vector looks like but the output is 2 times that vector so when we attach that output to the original point you get something that's 2 times that original vector but pointing in the same direction which is away from the origin kind of drew it poorly here and of course when we draw vector fields we don't usually draw them to scale you scale them down just so that things don't look as cluttered that's why everything here they all look the same length but color indicates length so you should think of these red guys as being really long the blue ones is being really short so what does this have to do with the graph of the function there's actually a really cool interpretation so imagine that you are just walking along this graph you know you're a hiker and this is a mountain and you picture yourself an annual point on this graph let's say what color should I use let's say you're sitting at a point like this and you say what direction should I walk to increase my altitude the fastest you want to get uphill as quickly as possible and from that point you might walk you know what looks like straight up there you certainly want to go around and this way you wouldn't go down so you might go straight up there and if you project your point down onto the input space so it's this is the point above which you are that vector the one that's going to get you going uphill the fastest the direction you should walk for this graph it should kind of makes sense is directly away from the origin because here I'll erase this because once I start moving things that won't stick if you look at things from the very bottom any point that you are on the mountain on the graph here and you when you want to increase the fastest you should just go directly away from the origin because that's when it's the steepest and all of these vectors are also pointing directly away from the origin so people will say the gradient points in the direction of steepest descent that might even be worth writing down direction of steepest descent and let's just see what that looks like in texts of another example so I'll pull up another graph here pull up another graph and it's vector field so this graph it's all negative values it's all below the XY plane and it's got these two different peaks and I've also drawn the gradient field which is the word for the vector field representing the gradient on top and you'll notice near the peak all of the all of the vectors are pointing kind of in the uphill direction sort of telling you to go towards that peak in some way and you know as you get a feel around you can see here this very top one like the point that it's stemming from corresponds with something just a little bit shy of the peak there and everybody's telling you to go uphill each vector is telling you which way to walk to increase the altitude on the graph the fastest is the direction of steepest descent and that's what the direction means but what is the length mean well if you take a look take a look at these red vectors here so red means that they should be considered very very long and the graph itself the point they correspond to on the graph is just way off screen for us because this graph gets really steep and really negative very fast so the points these correspond to have really really steep slopes whereas these blue ones over here you know it's kind of a relatively shallow slope I by the time you get into the peak things start leveling off so the length of the gradient vector actually tells you the steepness of that direction of steepest descent but one thing I want to point out here it doesn't really make sense immediately looking at it why just throwing the partial derivatives into a vector is going to give you this direction of steepest descent ultimately it will we're going to talk through that and I hope to make that connection pretty clear but unless you're some kind of intuitive genius I don't I don't think that connection is it all obvious at first but you will see it in due time it's going to require something called the directional derivative see you next video