# 14. Directional Derivatives and Gradients

## c.1. Directional Derivatives

So we now know how to differentiate a function \(f\) along any vector \(\vec v\): \[ \nabla_{\vec v}f=\vec v\cdot\vec\nabla f \] If \(\vec v\) happens to be a unit vector (i.e. \(|\vec v|=1\)), then \(\nabla_{\vec v}f\) has a special name.

If \(\vec v\) is a *unit* vector, then the derivative of \(f(x,y)\)
along \(\vec v\) is called the *directional*
derivative of \(f(x,y)\) along \(\vec v\) (or
with respect to \(\vec v\)).
\[
\nabla_{\vec v}f=\vec v\cdot\vec\nabla f
\]

If \(\vec v\) is *not* a unit vector, then we can construct the
unit vector
\[
\hat v=\dfrac{\vec v}{|\vec v|},
\]
which is call the unit vector in the direction of
\(\vec v\) or more simply the the direction of
\(\vec v\). Then:

For *any* vector \(\vec v\), the directional
derivative of \(f(x,y)\) *in the direction of* \(\vec v\)
is the derivative of \(f(x,y)\) along \(\hat v\):
\[
\nabla_{\hat v}f=\hat v\cdot\vec\nabla f
\]

Notice the key words *“in the direction of”*.
This is the indication that we are to use \(\hat v\) rather than \(\vec v\).

Suppose we want to know the rate of change of a function \(f\).
If we compute the derivative of \(f\) along a curve \(\vec r(t)\) we get
\[
\dfrac{df}{dt}=\nabla_{\vec v}f=\vec v\cdot\vec\nabla f
\]
where \(\vec v\) is the velocity of the curve. However, any vector can be
split up as the product of its magnitude and its direction,
\[
\vec v=|\vec v|\,\hat v,
\]
in this case, the speed and the unit tangent vector. So the derivative
along the curve is
\[
\dfrac{df}{dt}
=|\vec v|\,\hat v\cdot\vec\nabla f=|\vec v|\,\nabla_{\hat v}f
\]
which is the speed of the curve times the directional derivative of \(f\).
So the derivative along the curve is proportional to the speed we move
along the curve. *If we want to know the rate of change of \(f\),
we don't want the answer to depend on the speed of the curve used to
measure it.* So we use a curve with unit speed, and in that case,
the rate of change of \(f\) is the directional derivative of \(f\):
\[
\dfrac{df}{dt}=\hat v\cdot\vec\nabla f=\nabla_{\hat v}f
\]

Find the directional derivative of \(f(x,y)=\dfrac{x}{y}\) in the direction of \(\vec v=\langle 3,4\rangle\) at the point \(P=(1,2)\).

The length of \(\vec v\) is \(|\vec v|=\sqrt{3^2+4^2}=5\). So the unit vector in the direction of \(\vec v\) is: \[ \hat{v}=\dfrac{\vec v}{|\vec v|} =\left\langle \dfrac{3}{5},\dfrac{4}{5}\right\rangle \] From the example on the previous page, the gradient of \(f\) at \(P\) is: \[ \left.\vec\nabla f\right|_P =\left\langle \dfrac{1}{2},-\,\dfrac{1}{4}\right\rangle \] So the directional derivative of \(f\) in the direction of \(\vec v\) is: \[ \left.\vec\nabla_{\hat v}f\right|_P =\hat v\cdot\left.\vec\nabla f\right|_P =\left\langle \dfrac{3}{5},\dfrac{4}{5}\right\rangle \cdot\left\langle \dfrac{1}{2},-\,\dfrac{1}{4}\right\rangle =\dfrac{3}{10}-\,\dfrac{1}{5} =\dfrac{1}{10} \]

In general, the directional derivative measures the slope of the function along the path.

Find the slope of the function \(z=f(x,y)\) at the point \((a,b)\) in the direction of \(\vec v\).

The vector \(\vec v\) only tell us how \(x\) and \(y\) are changing. The function \(f\) tells us how \(z\) is changing. The slope is the rise over the run. We want to do this infinitesimally. So we approximate changes by differentials.

The run is the change in \(x\) and \(y\), i.e. \(\sqrt{\Delta x^2+\Delta y^2}\) computed using the vector \(\vec v=\langle \Delta x,\Delta y\rangle\). So: \[ \text{run}=\sqrt{\Delta x^2+\Delta y^2} =|\vec v| \]

The rise is the change in \(z\), computed using \(f\): \[\begin{aligned} \text{rise}&=\Delta z=\Delta f\approx df \\ &=\dfrac{\partial f}{\partial x}\,dx+\dfrac{\partial f}{\partial y}\,dy \\ &=\dfrac{\partial f}{\partial x}\,\Delta x+\dfrac{\partial f}{\partial y}\,\Delta y =\vec v\cdot\vec\nabla f \end{aligned}\] So the slope is \[ \text{slope}=\dfrac{\text{rise}}{\text{run}} =\dfrac{\vec v\cdot\vec\nabla f}{|\vec v|} =\hat v\cdot\vec\nabla f =\nabla_{\hat v}f \] which is the directional derivative; another reason the directional derivative is important.

A hiker is walking up a mountainside whose altitude is given by \(a=4-\,\dfrac{x^2+y^2}{25}\). If the hiker is currently at \((3,4)\) and walking in the direction \(\vec v=\langle 5,-12\rangle\), what is the slope of the path?

\(\text{slope}=\dfrac{66}{325}\)

The slope is the directional derivative. The gradient of the altitude is: \[\begin{aligned} \vec\nabla a &=\left\langle-\,\dfrac{2x}{25},-\,\dfrac{2y}{25}\right\rangle \\ \left.\vec\nabla a\right|_{(3,4)} &=\left\langle-\,\dfrac{6}{25},-\,\dfrac{8}{25}\right\rangle \end{aligned}\] The direction of \(\vec v\) is: \[ \hat v=\left\langle \dfrac{5}{13},-\,\dfrac{12}{13}\right\rangle \] So the slope is \[\begin{aligned} \text{slope}&=\hat v\cdot\left.\vec\nabla a\right|_{(3,4)} =\left\langle \dfrac{5}{13},-\,\dfrac{12}{13}\right\rangle \cdot\left\langle-\,\dfrac{6}{25},-\,\dfrac{8}{25}\right\rangle \\[8pt] &=-\,\dfrac{30}{13\cdot25}+\dfrac{96}{13\cdot25} =\dfrac{66}{325} \end{aligned}\]

More applications of the directional derivative appear on the next page.

## Heading

Placeholder text: Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum