Main content

### Course: Multivariable calculus > Unit 2

Lesson 3: Partial derivative and gradient (articles)# Directional derivatives (introduction)

How does the value of a multivariable function change as you nudge the input in a specific direction?

## Background

## What we're building to

- If you have some multivariable function,
and some vector in the function's input space,$f(x,y)$ , the directional derivative of$\overrightarrow{\mathbf{\text{v}}}$ along$f$ tells you the rate at which$\overrightarrow{\mathbf{\text{v}}}$ will change while the input moves with velocity vector$f$ .$\overrightarrow{\mathbf{\text{v}}}$

- The notation here is
, and it is computed by taking the dot product between the gradient of${\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}f$ and the vector$f$ , that is,$\overrightarrow{\mathbf{\text{v}}}$ $\mathrm{\nabla}f\cdot \overrightarrow{\mathbf{\text{v}}}$ - When the directional derivative is used to compute slope, be sure to normalize the vector
first.$\overrightarrow{\mathbf{\text{v}}}$

## Generalizing partial derivatives

Consider some multivariable function:

We know that the partial derivatives with respect to $x$ and $y$ tell us the rate of change of $f$ as we nudge the input either in the $x$ or $y$ direction.

The question now is what happens when we nudge the input of $f$ in a direction which is not parallel to the $x$ or $y$ axes.

For example, the image below shows the graph of $f$ along with a small step along a vector $\overrightarrow{\mathbf{\text{v}}}$ in the input space, meaning the $xy$ -plane in this case. Is there an operation which tells us how the height of the graph above the tip of $\overrightarrow{\mathbf{\text{v}}}$ compares to the height of the graph above its tail?

As you have probably guessed, there is a new type of derivative, called the

**directional derivative**, which answers this question.Just as the partial derivative is taken with respect to some input variable—e.g., $x$ or $y$ —the directional derivative is taken $\overrightarrow{\mathbf{\text{v}}}$ in the input space.

*along*some vectorOne very helpful way to think about this is to picture a point in the input space moving with velocity $\overrightarrow{\mathbf{\text{v}}}$ . The directional derivative of $f$ along $\overrightarrow{\mathbf{\text{v}}}$ is the resulting rate of change in the output of the function. So, for example, multiplying the vector $\overrightarrow{\mathbf{\text{v}}}$ by two would double the value of the directional derivative since all changes would be happening twice as fast.

## Notation

There are quite a few different notations for this one concept:

${\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}f$ $\frac{\partial f}{\partial \overrightarrow{\mathbf{\text{v}}}}$ ${f}_{\overrightarrow{\mathbf{\text{v}}}}^{\prime}$ ${D}_{\overrightarrow{\mathbf{\text{v}}}f}$ ${\partial}_{\overrightarrow{\mathbf{\text{v}}}}f$

All of these represent the same thing: the rate of change of $f$ as you nudge the input along the direction of $\overrightarrow{\mathbf{\text{v}}}$ . We'll use the ${\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}f$ notation, just because it subtly hints at how you compute the directional derivative using the gradient, which you'll see in a moment.

## Example 1: $\overrightarrow{\mathbf{\text{v}}}=\hat{\mathbf{\text{j}}}$

Before jumping into the general rule for computing ${\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}f$ , let's look at how we can rewrite the more familiar notion of a partial derivative as a directional derivative.

For example, the partial derivative $\frac{\partial f}{\partial y}$ tells us the rate at which $f$ changes as we nudge the input in the $y$ direction. In other words, as we nudge it along the vector $\hat{\mathbf{\text{j}}}$ . Therefore, we could equivalently write the partial derivative with respect to $y$ as $\frac{\partial f}{\partial y}}={\mathrm{\nabla}}_{\hat{\mathbf{\text{j}}}}f$ .

This is all just fiddling with different notation. What's more important is to have a clear mental image of what all this notation

*represents*.**Reflection Question**: Suppose

## How to compute the directional derivative

Let's say you have a multivariable $f(x,y,z)$ which takes in three variables—$x$ , $y$ and $z$ —and you want to compute its directional derivative along the following vector:

The answer, as it turns out, is

This should make sense because a tiny nudge along $\overrightarrow{\mathbf{\text{v}}}$ can be broken down into ${two}$ tiny nudges in the $x$ -direction, ${three}$ tiny nudges in the $y$ -direction, and a tiny nudge backwards, by ${-1}$ , in the $z$ -direction. We'll go through the rigorous reasoning behind this much more thoroughly in the next article.

More generally, we can write the vector $\overrightarrow{\mathbf{\text{v}}}$ abstractly as follows:

The directional derivative looks like this:

That is, a tiny nudge in the $\overrightarrow{\mathbf{\text{v}}}$ direction consists of ${{v}_{1}}$ times a tiny nudge in the $x$ -direction, ${{v}_{2}}$ times a tiny nudge in the $y$ -direction, and ${{v}_{3}}$ times a tiny nudge in the $z$ -direction.

This can be written in a super-pleasing compact way using the dot product and the gradient:

This is why the notation ${\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}$ is so suggestive of the way we compute the directional derivative:

Take a moment to delight in the fact that one single operation, the gradient, packs enough information to compute the rate of change of a function in ${}^{\circ}$ clockwise from the $x$ -axis... Madness!

*every possible direction!*That's so many directions! Left, right, up, down, north-north-east, 34.8## Example 2:

**Problem**: Take a look at the following function.

What is the directional derivative of $f$ at the point $(2,-3)$ along the vector $\begin{array}{r}\overrightarrow{\mathbf{\text{v}}}={0.6}\hat{\mathbf{\text{i}}}+{0.8}\hat{\mathbf{\text{j}}}\end{array}$ ?

**Solution**: You can think of the direction derivative either as a weighted sum of partial derivatives, as below:

Or, you can think of it as a dot product with the gradient, as you see here:

The first is faster, but just for practice, let's see how the gradient interpretation unfolds. We start by computing the gradient itself:

Next, plug in the point $(x,y)=(2,-3)$ since this is the point the question asks us about.

To get the desired directional derivative, we take the dot product between this gradient and $\mathbf{\text{v}}$ :

## Finding slope

How do you find the slope of a graph intersected with a plane that is not parallel to the $x$ or $y$ axes?

You can use the directional derivative, but there is one important thing to remember:

*If the directional derivative is used to compute slope, either*$\overrightarrow{\mathbf{\text{v}}}$ must be a unit vector or you must remember to divide by $||\overrightarrow{\mathbf{\text{v}}}||$ at the end.

In the definition and computation above, doubling the length of $\overrightarrow{\mathbf{\text{v}}}$ would double the value of the directional derivative. In terms of the computation, this is because $\mathrm{\nabla}f\cdot (2\overrightarrow{\mathbf{\text{v}}})=2(\mathrm{\nabla}f\cdot v)$ .

However, this might not always be what you want. The slope of a graph in the direction of $\overrightarrow{\mathbf{\text{v}}}$ , for example, depends only on the direction of $\overrightarrow{\mathbf{\text{v}}}$ , not the magnitude $||\overrightarrow{\mathbf{\text{v}}}||$ . Let's see why.

How can we imagine this slope? Slice the graph of $f$ with a vertical plane that cuts the $xy$ -plane in the direction of $\overrightarrow{\mathbf{\text{v}}}$ . The slope in question is that of a line tangent to the resulting curve. As with any slope, we look for the rise over run.

In this case, the run will be the distance of a small nudge in the direction of $\overrightarrow{\mathbf{\text{v}}}$ . We can express such a nudge as an addition of $h\overrightarrow{\mathbf{\text{v}}}$ to an input point ${\mathbf{\text{x}}}_{0}$ , where $h$ is thought of as some small number. The magnitude of this nudge is $h||\overrightarrow{\mathbf{\text{v}}}||$ .

The resulting change in the output of $f$ can be approximated by multiplying this little value $h$ by the directional derivative:

In fact, the rise of the tangent line—as opposed to the graph of the function— is $h{\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}f({x}_{0},{y}_{0})$ due to this run of size $h||\overrightarrow{\mathbf{\text{v}}}||$ . For full details on why this is true, see the formal definition of the directional derivative in the next article.

*precisely*Therefore, the rise-over-run slope of our graph is

Notice, if $\overrightarrow{\mathbf{\text{v}}}$ is a unit vector, meaning $||\overrightarrow{\mathbf{\text{v}}}||=1$ , then the directional derivative $\overrightarrow{\mathbf{\text{v}}}$ .

*does*give the slope of a graph along that direction. Otherwise, it is important to remember to divide out by the magnitude ofSome authors even go so far as to include normalization in the definition of ${\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}f$ .

**Alternate definition of directional derivative:**

Personally, I think this definition puts too much emphasis on the particular use case of finding slope, so I prefer to use the original definition and normalize $\overrightarrow{\mathbf{\text{v}}}$ when necessary.

## Example 3: Slope

**Problem**: On the stage for this problem we have three players.

Player 1, the function:

Player 2, the point:

Player 3, the vector:

What is the slope of the graph of $f$ at the point $({x}_{0},{y}_{0})$ along the vector $\overrightarrow{\mathbf{\text{v}}}$ ?

**Answer**: Since we are finding slope, we must first normalize the vector in question. The magnitude

Next, find the gradient of $f$ :

Plug in the point $({x}_{0},{y}_{0})=({\displaystyle \frac{\pi}{3}},{\displaystyle \frac{1}{2}})$ to this gradient.

Finally, take the dot product between $\hat{\mathbf{\text{u}}}$ and $\mathrm{\nabla}f(\pi /3,1/2)$ :

## Summary

- If you have some multivariable function,
and some vector in the function's input space,$f(x,y)$ , the directional derivative of$\overrightarrow{\mathbf{\text{v}}}$ along$f$ tells you the rate at which$\overrightarrow{\mathbf{\text{v}}}$ will change while the input moves with velocity vector$f$ .$\overrightarrow{\mathbf{\text{v}}}$ - The notation here is
, and it is computed by taking the dot product between the gradient of${\mathrm{\nabla}}_{\overrightarrow{\mathbf{\text{v}}}}f$ and the vector$f$ , that is,$\overrightarrow{\mathbf{\text{v}}}$ .$\mathrm{\nabla}f\cdot \overrightarrow{\mathbf{\text{v}}}$ - When the directional derivative is used to compute slope, be sure to normalize the vector
first.$\overrightarrow{\mathbf{\text{v}}}$

## Want to join the conversation?

- In example 3, is there an error?

cos((1/2) * (pi/3)) =/= 1/2

SqRt(3)/2 is what I get. I think you have taken the sin of pi/6 instead of cos.(23 votes)- Yes, there is an error.

I found that ∇v ( π/3 , 1/2 ) = [(√3 + π.√3) / (2.√13)] or [(√3 . (1 + π) ) / (2 . √13)](8 votes)

- I'm still not sure why you have to normalize vector v when computing the directional derivative for slope. Isn't the directional derivative just computing the rate at which f will change while the input moves along v, which is a lengthier way of describing the slope?(12 votes)
- The derivative means instantaneous rate of change. it is obvious if you move along a vector, the bigger the magnitude of the vector is you travel faster, so in each instance, you have a bigger instantaneous rate of change. but the slope is something different. you only care about the rise over run. two vectors with different magnitude have the same rise over run if they point in the same direction. so if we are using derivative as a mean to get to the slope, we ignore the magnitude, cause we only care about the direction. Hope my answer is clear.(25 votes)

- In example 3: slope, the magnitude of v should be sqrt(2^2+3^3) = sqrt(13). sqrt(4^2+3^2) = sqrt(25) = 5, not sqrt(13), and 4 is not part of the vector v.

On a side note, I'm glad to see I'm not the only one who works through an operation and then puts the result back in to the operation, as if it still needs to be solved. I've gotten a few KA exercises wrong that way, usually involving simple arithmetic after having taken care of the calculus.(5 votes)- Even the u vector calculated is wrong as expressed but later on in the calculation the j component is corrected by using 3 instead of 2 divided by sqrt3 ........ :-)(2 votes)

- Why does he say, the vector "v" is the velocity vector?? I think in this context, it is the displacement vector. We are not considering time, just space.

If we just consider the graph, (independently of if the real function represents the output of benefits from two inputs of production and investiment, in an economy problem), we obtain the increment of Z distance (increment of the functions), for an increment of a combination of distances in X and Y. Talking about velocity has not sense here.(4 votes)- It's helpful to think about
**v**as of a velocity vector because if you move along**v**2 as fast the resulting rate of change has to be 2 as fast (and it is if you double the directional vector). But if you think of it as of distance, i will not be intuitive to think that doubling the distance traveled will double the output.(2 votes)

- if h is an infinitsimal why does the magnitude of v matter? even if it would matter wouldn't it be better to aproach the vector's magnitude to zero too?(4 votes)
- Rate of change with h approaching zero is equivalent to the slope of a tangent. If you are using the rate of change on the original graph, h must be tiny. If you are using a tangent line, then h can be whatever, since the slope is constant.
**v**can't possibly be zero since the zero vector has no direction. It has to have some length to retain its directional information, We decide 1 is the best choice because it's the most general number other than 0.

Slope is defined as rise/run, so it is also rise when run = 1. rise/run = rise/1 = rise. We could of course had defined it as 2rise/run or run/rise, which would still retain all the useful information about how steep the graph is, but we defined it as rise/run, and so we have to use ||**v**|| = 1.(0 votes)

- so if I compute the directional derivative, having the unit vector as my direction I get the slope of the surface right?, if i dont use a unit vector what do i get? Im asking for a physical interpretation.

thanks!(2 votes)- I think the answer must be: the instantaneous rate of change.(2 votes)

- example 2 calculates the directional derivative and uses dot product with gradient and the vector components, yet example 3 in calculating slope, converts the vector to the unit vector before the dot product. Whats the difference between directional derivative and slope?(2 votes)
- There is no difference. Whenever you calculate either, you need to make the vector specifying direction a unit vector. In example 2, the 0.6î+0.8ĵ is already a unit vector, so there was no need to convert anything.(1 vote)

- In example 1, reflection question, since v = i + j, why isn't the gradient along v, sqrt(2)/2*df/dx+ sqrt(2)/2*df/dy, since we have to normalize it? I'm a bit confused with having two definitions with different meaning for the gradient... some physical examples on when you use one or another?(2 votes)
- For example 3, shouldn't it be root(2 squared + 3 squared) and then 3/root(13) j?(2 votes)
- When you asked to calculate the directional derivative with respect to vector v=i+j you didn't normalize the vector v since the length of i+j is actually sqrt(2) (following pythagorean sqrt(1+1)), so the directional derivative should be sqrt(2)*(df/dx)+sqrt(2)*(df/dy).

Am I correct?(1 vote)- If you are computing the slope you would have to normalize
**v**, that's right. But a derivative along the vector doesn't have to equal to the slope. I don't know how else is it useful then, but Grant says so.(2 votes)