yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Directional derivative


5m read
·Nov 11, 2024

Hello everyone. So here, I'm going to talk about the directional derivative. That's a way to extend the idea of a partial derivative. Partial derivatives, if you'll remember, have to do with functions with some kind of multivariable input. I'll just use two inputs because that's the easiest to think about. It could be some single variable output; it could also deal with vector variable outputs. We haven't gotten to that yet, so we'll just think about a single variable ordinary real number output. That's, you know, an expression of X and Y.

The partial derivative—one of the ways that I said you think about it—is to take a look at the input space, your X and Y plane. So this would be the x-axis; this is y. You know vaguely in your mind you're thinking that somehow this outputs to a line. This outputs to just the real numbers, and maybe you're thinking about a transformation that takes it there. Or maybe you're just thinking, "Okay, this is the input space; that's the output."

When you take the partial derivative at some kind of point—so I'll write it out like partial derivative of f with respect to X at a point like (1, 2)—you think about that point: you know 1, y is equal to 2. If you're taking it with respect to X, you think about just nudging it a little bit in that X direction, and you see what the resulting nudge is in the output space. The ratio between the size of that resulting nudge and the original one—the ratio between, you know, partial F and partial X—is the value that you want.

When you did it with respect to Y, you know you were thinking about traveling in a different direction. Maybe you nudge it straight up, and you're wondering, "Okay, how does that influence the output?" The question here, with directional derivatives, is: what if you have some vector v? I'll give a little vector hat on top of it. I don't know, let's say it's (-1, 2) as the vector. So you'd be thinking about that as a step of -1 in the X direction and then two more in the Y direction. So it's going to be something that ends up there.

This is your vector v, at least if you're thinking of v as stemming from the original point. You're wondering, "What does a nudge in that direction do to the function itself?" Remember, with these original nudges in the X direction, nudges in the Y, you're not really thinking of it as, you know, this is kind of a large step. You're really thinking of it as something itty-bitty, you know? It's not that, but it's really something very, very small. Formally, you'd be thinking about the limit as this gets really, really, really small, approaching zero, and this gets really, really small, approaching zero. What does the ratio of the two approach?

Similarly, with the Y, you're not thinking of it as something this is, this is pretty sizable, but it would be something really, really small. The directional derivative is similar; you're not thinking of the actual vector actually taking a step along that, but you'd be thinking of taking a step along, say, h multiplied by that vector, and h might represent some really, really small number. So, you know, maybe this here is like 0.001.

When you're doing this formally, you'd just be thinking the limit as h goes to zero. The directional derivative is saying, when you take a slight nudge in the direction of that vector, what is the resulting change to the output? One way to think about this is to say, well, that slight nudge of the vector—if we actually expand things out and we look at the definition itself—it'll be H(-1) * that component and then 2H here. So it's kind of like you took a negative (-1) nudge in the X direction and then two nudges in the Y direction. You know, for whatever your nudge in the v direction there, you take a negative one step by X and then two of them up by Y.

So when we actually write this out, the notation, by the way, is you take that same nabla from the gradient, but then you put the vector down here. So this is the directional derivative in the direction of v. There's a whole bunch of other notations too. You know, I think there's like derivative of f with respect to that vector is one way people will think about it. Some people will just write like partial with a little subscript vector. There's a whole bunch of different notations, but this is the one I like. You think that nabla with a little f down there with a little v for your vector of f, and it's still a function of X and Y.

The reason I like this is it's indicative of how you end up calculating it, which I'll talk about at the end of the video. For this particular example, a good guess that you might have is to say, well, we take a negative step in the X direction. So you think of it as whatever the change that's caused by such a step in the X direction, you do the negative of that and then it's two steps in the Y direction. So whatever the change caused by a tiny step in the Y direction, let's just take two of those: 2 * ∂f/∂Y.

And this is actually how you calculate it! If I was going to be more general, you know, let's say we've got a vector W. I'm going to keep it abstract and just call it a and b as its components rather than the specific numbers. You would say that the directional derivative in the direction of w, whatever that is of f, is equal to a * (∂f/∂X) + b * (∂f/∂Y). And this is it. This is the formula that you would use for the directional derivative.

Again, the way that you're thinking about this is you're really saying, you know, you take a little nudge that's a in the X direction and b in the Y direction, so this should kind of make sense. Sometimes you see this written not with respect to the partial derivatives themselves and the actual components a and b, but with respect to the gradient. This is because it makes it much more compact, more general if you're dealing with other dimensions.

So I'll just write it over here. If you look at this expression, it looks like a dot product. If you take the dot product of the vectors a and the one that has the partial derivatives in it, what's lined up with a is the partial derivative with respect to X (∂f/∂X) and what's lined up with b is the partial derivative with respect to Y. You look at this and you say, "Hey, ab! I mean that's just the original vector, right? That's W, that's the vector W!" And then you're dotting this with, well, partial derivative with respect to X in one component, the other partial derivative in the other component—that's just the gradient of f.

Here, you know, it's nabla without that little w at the bottom. This is why we use this notation, because it's so suggestive of the way that you ultimately calculate it. This is really what you'll see in a textbook or see as the compact way of writing it, and you can see how this is more flexible for dimensions. So if we were talking about something that has like a five-dimensional input, and the direction you move has five different components, this is flexible.

When you expand it, the gradient would have five components and the vector itself would have five components. So this is the directional derivative and how you calculate it. The way you interpret it, you're thinking of moving along that vector by a tiny nudge, by a tiny, you know, little value multiplied by that vector and saying how does that change the output, and what's the ratio of the resulting change?

In the next video, I'll clarify that with the formal definition of the directional derivative itself.

More Articles

View All
Warren Buffett: How to Invest in an Overvalued Market
Some people are not actually emotionally or psychologically fit to own stocks, but I think there are more of them that would be if you get educated on what you’re really buying, which is part of a business. There is Mr. Warren Buffett, the world’s best in…
Worked example: separable differential equation (with taking log of both sides) | Khan Academy
Let’s say we need to find a solution to the differential equation that the derivative of y with respect to x is equal to x squared over e to the y. Pause this video and see if you can have a go at it. I will give you a clue: it is a separable differential…
Reasons Not to Worry What Others Think
You have no responsibility to live up to what other people think you ought to accomplish. I have no responsibility to be like they expect me to be. It’s their mistake, not my failing. It’s generally a good idea to care about other people’s opinions to som…
Worked example: Derivative of ln(Ãx) using the chain rule | AP Calculus AB | Khan Academy
So we have here F of x being equal to the natural log of the square root of x. What we want to do in this video is find the derivative of F. The key here is to recognize that F can actually be viewed as a composition of two functions, and we can diagram t…
Consumer credit unit overview | Teacher Resources | Financial Literacy | Khan Academy
Hi teachers, Welcome to the unit on consumer credit. So, just as a high level, this is going to cover everything from credit scores—what is it? How it’s able to give people who might give someone credit a sense of how likely you are to pay back that cred…
How Much Equity to Give Your Cofounder - Michael Seibel
How much equity to give your co-founders? This is a problem and a question that a lot of people have written about, and you can see a lot of varied advice online. My perspective is that most founders are missing a couple key points when divvying up their …