2.4 Directional Derivatives and the Gradient

For a function \(z=f(x,y)\), we learned that the partial derivatives \(\tfrac{\partial f}{\partial x}\) and \(\tfrac{\partial f}{\partial y}\) represent the (instantaneous) rate of change of \(f\) in the positive \(x\) and \(y\) directions, respectively. What about other directions? It turns out that we can find the rate of change in any direction using a more general type of derivative called a directional derivative.

Definition 2.5

Let \(f(x,y)\) be a real-valued function with domain \(D\) in \(\Real{2}\), and let \((a,b)\) be a point in \(D\). Let v be a unit vector in \(\Real{2}\). Then the directional derivative of \(\bm{f}\) at \(\bm{(a,b)}\) in the direction of v, denoted by \(\ssub{D}{\textbf{v}}f(a,b)\), is defined as

\begin{equation} \ssub{D}{\textbf{v}}f(a,b) = \lim_{h \to 0} \dfrac{f((a,b) + h\textbf{v}) - f(a,b)}{h} \tag{2.8}\end{equation}

Notice in the definition that we seem to be treating the point \((a,b)\) as a vector, since we are adding the vector \(h\textbf{v}\) to it. But this is just the usual idea of identifying vectors with their terminal points, which the reader should be used to by now. If we were to write the vector v as \(\textbf{v} = \vectwo{v}\), then

\begin{equation} \ssub{D}{\textbf{v}}f(a,b) = \lim_{h \to 0} \dfrac{f(a+h\ssub{v}{1},b+h\ssub{v}{2}) - f(a,b)}{h} ~. \tag{2.9}\end{equation}

From this we can immediately recognize that the partial derivatives \(\tfrac{\partial f}{\partial x}\) and \(\tfrac{\partial f}{\partial y}\) are special cases of the directional derivative with \(\textbf{v} = \textbf{i} = (1,0)\) and \(\textbf{v} = \textbf{j} = (0,1)\), respectively. That is, \(\tfrac{\partial f}{\partial x} = \ssub{D}{\textbf{i}}f\) and \(\tfrac{\partial f}{\partial y} = \ssub{D}{\textbf{j}}f\). Since there are many vectors with the same direction, we use a unit vector in the definition, as that represents a “standard” vector for a given direction.

If \(f(x,y)\) has continuous partial derivatives \(\tfrac{\partial f}{\partial x}\) and \(\tfrac{\partial f}{\partial y}\) (which will always be the case in this text), then there is a simple formula for the directional derivative:

Theorem 2.2

Let \(f(x,y)\) be a real-valued function with domain \(D\) in \(\Real{2}\) such that the partial derivatives \(\tfrac{\partial f}{\partial x}\) and \(\tfrac{\partial f}{\partial y}\) exist and are continuous in \(D\). Let \((a,b)\) be a point in \(D\), and let \(\textbf{v} = \vectwo{v}\) be a unit vector in \(\Real{2}\). Then

\begin{equation} \ssub{D}{\textbf{v}}f(a,b) = \ssub{v}{1}\frac{\partial f}{\partial x}(a,b) + \ssub{v}{2}\frac{\partial f}{\partial y}(a,b) ~. \tag{2.10}\end{equation}

proof[Proof:] Note that if \(\textbf{v} = \textbf{i} = (1,0)\) then the above formula reduces to \(\ssub{D}{\textbf{v}}f(a,b) = \tfrac{\partial f}{\partial x}(a,b)\), which we know is true since \(\ssub{D}{\textbf{i}}f = \tfrac{\partial f}{\partial x}\), as we noted earlier. Similarly, for \(\textbf{v} = \textbf{j} = (0,1)\) the formula reduces to \(\ssub{D}{\textbf{v}}f(a,b) = \tfrac{\partial f}{\partial y}(a,b)\), which is true since \(\ssub{D}{\textbf{j}}f = \tfrac{\partial f}{\partial y}\). So since \(\textbf{i} = (1,0)\) and \(\textbf{j} = (0,1)\) are the only unit vectors in \(\Real{2}\) with a zero component, then we need only show the formula holds for unit vectors \(\textbf{v} = \vectwo{v}\) with \(\ssub{v}{1} \ne 0\) and \(\ssub{v}{2} \ne 0\). So fix such a vector v and fix a number \(h \ne 0\). Then

\begin{equation} f(a+h\ssub{v}{1},b+h\ssub{v}{2}) - f(a,b) = f(a+h\ssub{v}{1},b+h\ssub{v}{2}) - f(a+h\ssub{v}{1},b) + f(a+h\ssub{v}{1},b) - f(a,b) ~. \tag{2.11}\end{equation}

Since \(h \ne 0\) and \(\ssub{v}{2} \ne 0\), then \(h\ssub{v}{2} \ne 0\) and thus any number \(c\) between \(b\) and \(b+h\ssub{v}{2}\) can be written as \(c=b+\alpha h\ssub{v}{2}\) for some number \(0 < \alpha < 1\). So since the function \(f(a+h\ssub{v}{1},y)\) is a real-valued function of \(y\) (since \(a+h\ssub{v}{1}\) is a fixed number), then the Mean Value Theorem from single-variable calculus can be applied to the function \(g(y) = f(a+h\ssub{v}{1},y)\) on the interval \(\lbrack b, b+h\ssub{v}{2} \rbrack\) (or \(\lbrack b+h\ssub{v}{2}, b \rbrack\) if one of \(h\) or \(\ssub{v}{2}\) is negative) to find a number \(0 < \alpha < 1\) such that

\[\frac{\partial f}{\partial y}(a+h\ssub{v}{1},b+\alpha h\ssub{v}{2}) = g\,'(b+\alpha h\ssub{v}{2}) = \frac{g(b+h\ssub{v}{2}) - g(b)}{b+h\ssub{v}{2} - b} = \frac{f(a+h\ssub{v}{1},b+h\ssub{v}{2}) - f(a+h\ssub{v}{1},b)}{h\ssub{v}{2}}\]

and so

\[f(a+h\ssub{v}{1},b+h\ssub{v}{2}) - f(a+h\ssub{v}{1},b) ~~=~~ h\ssub{v}{2} \frac{\partial f}{\partial y}(a+h\ssub{v}{1},b+\alpha h\ssub{v}{2}) ~.\]

By a similar argument, there exists a number \(0 < \beta < 1\) such that

\[f(a+h\ssub{v}{1},b) - f(a,b) ~~=~~ h\ssub{v}{1} \frac{\partial f}{\partial x}(a+\beta h\ssub{v}{1},b) ~.\]

Thus, by equation (2.11), we have

\begin{align*} \frac{f(a+h\ssub{v}{1},b+h\ssub{v}{2}) - f(a,b)}{h} ~~ &= ~~ \frac{h\ssub{v}{2}\tfrac{\partial f}{\partial y}(a+h\ssub{v}{1},b+\alpha h\ssub{v}{2}) + h\ssub{v}{1} \tfrac{\partial f}{\partial x}(a+\beta h\ssub{v}{1},b)}{h}\\[6pt] &= ~~ \ssub{v}{2}\frac{\partial f}{\partial y}(a+h\ssub{v}{1},b+\alpha h\ssub{v}{2}) + \ssub{v}{1} \frac{\partial f}{\partial x}(a+\beta h\ssub{v}{1},b) \end{align*}

so by formula (2.9) we have

\begin{align*} \ssub{D}{\textbf{v}}f(a,b) ~~ &= ~~ \lim_{h \to 0} \dfrac{f(a+h\ssub{v}{1},b+h\ssub{v}{2}) - f(a,b)}{h}\\[8pt] &= ~~ \lim_{h \to 0} \left[ \ssub{v}{2}\frac{\partial f}{\partial y}(a+h\ssub{v}{1},b+\alpha h\ssub{v}{2}) + \ssub{v}{1} \frac{\partial f}{\partial x}(a+\beta h\ssub{v}{1},b) \right]\\[8pt] &= ~~ \ssub{v}{2}\frac{\partial f}{\partial y}(a,b) + \ssub{v}{1}\frac{\partial f}{\partial x}(a,b) \text{~~~by the continuity of $\frac{\partial f}{\partial x}$ and $\frac{\partial f}{\partial y}$, so}\\[8pt] \ssub{D}{\textbf{v}}f(a,b) ~~ &= ~~ \ssub{v}{1}\frac{\partial f}{\partial x}(a,b) + \ssub{v}{2}\frac{\partial f}{\partial y}(a,b) \end{align*}

after reversing the order of summation.

Note that \(\ssub{D}{\textbf{v}}f(a,b) = \Dotprod{\textbf{v}}{\biggl(\frac{\partial f}{\partial x}(a,b), \frac{\partial f}{\partial y}(a,b)\biggr)}\). The second vector has a special name:

Definition 2.6

For a real-valued function \(f(x,y)\), the gradient of \(f\), denoted by \(\nabla f\), is the vector

\begin{equation} \nabla f = \biggl(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y}\biggr) \tag{2.12}\end{equation}

in \(\Real{2}\). For a real-valued function \(f(x,y,z)\), the gradient is the vector

\begin{equation} \nabla f = \biggl(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y},\frac{\partial f}{\partial z}\biggr) \tag{2.13}\end{equation}

in \(\Real{3}\). The symbol \(\nabla\) is pronounced “del”.[1]

Corollary 2.3

\(\ssub{D}{\textbf{v}}f = \Dotprod{\textbf{v}}{\nabla f}\)


width height 0.5pt

Example 2.15

Find the directional derivative of \(f(x,y) = xy^2 + x^3 y\) at the point \((1,2)\) in the direction of \(\textbf{v} = \biggl( \frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}} \biggr)\).

Solution: We see that \(\nabla f = (y^2 + 3x^2 y, 2xy + x^3)\), so

\[\ssub{D}{\textbf{v}}f(1,2) ~=~ \Dotprod{\textbf{v}}{\nabla f(1,2)} ~=~ \Dotprod{\biggl( \tfrac{1}{\sqrt{2}},\tfrac{1}{\sqrt{2}} \biggr)}{(2^2 + 3(1)^2 (2),2(1)(2)+1^3)} ~=~ \tfrac{15}{\sqrt{2}}\]


width height 0.5pt

A real-valued function \(z=f(x,y)\) whose partial derivatives \(\tfrac{\partial f}{\partial x}\) and \(\frac{\partial f}{\partial y}\) exist and are continuous is called continuously differentiable. Assume that \(f(x,y)\) is such a function and that \(\nabla f \ne \textbf{0}\). Let \(c\) be a real number in the range of \(f\) and let v be a unit vector in \(\Real{2}\) which is tangent to the level curve \(f(x,y) = c\) (see Figure 2.4.1).

tikzpicture arrows [black!60,line width=0.3pt,-latex] (-3,0) -- (3,0); [black!60,line width=0.3pt,-latex] (0,-3) -- (0,3); 2.90.20 [center,center]x 0.22.90 [center,center]y 0.1-0.20 [center,center]0 (0,0) circle (0.5); (0,0) circle (1); (0,0) circle (1.5); (0,0) circle (2); (0,0) circle (2.5); (1.77,1.77) circle (1.2pt); [black,line width=1.2pt,-latex] (1.77,1.77) -- (1,2.54); [above] at (1,2.54) v; [black,line width=1.2pt,-latex] (1.77,1.77) -- (2.77,2.77); [right] at (2.77,2.77) f; at (3.1,1.3) f(x,y) = c; tikzpicture

Figure 2.4.1

The value of \(f(x,y)\) is constant along a level curve, so since v is a tangent vector to this curve, then the rate of change of \(f\) in the direction of v is 0, i.e. \(\ssub{D}{\textbf{v}}f = 0\). But we know that \(\ssub{D}{\textbf{v}}f = \Dotprod{\textbf{v}}{\nabla f} = \norm{\textbf{v}}\,\norm{\nabla f}\,\cos \theta\), where \(\theta\) is the angle between v and \(\nabla f\). So since \(\norm{\textbf{v}} = 1\) then \(\ssub{D}{\textbf{v}}f = \norm{\nabla f}\,\cos \theta\). So since \(\nabla f \ne \textbf{0}\) then \(\ssub{D}{\textbf{v}}f = 0 \Rightarrow \cos \theta = 0 \Rightarrow \theta = 90\Degrees\). In other words, \(\nabla f \perp \textbf{v}\), which means that \(\nabla f\) is normal to the level curve.

In general, for any unit vector v in \(\Real{2}\), we still have \(\ssub{D}{\textbf{v}}f = \norm{\nabla f}\,\cos \theta\), where \(\theta\) is the angle between v and \(\nabla f\). At a fixed point \((x,y)\) the length \(\norm{\nabla f}\) is fixed, and the value of \(\ssub{D}{\textbf{v}}f\) then varies as \(\theta\) varies. The largest value that \(\ssub{D}{\textbf{v}}f\) can take is when \(\cos \theta = 1\) (\(\theta = 0\Degrees\)), while the smallest value occurs when \(\cos \theta = -1\) (\(\theta = 180\Degrees\)). In other words, the value of the function \(f\) increases the fastest in the direction of \(\nabla f\) (since \(\theta = 0\Degrees\) in that case), and the value of \(f\) decreases the fastest in the direction of \(-\nabla f\) (since \(\theta = 180\Degrees\) in that case). We have thus proved the following theorem:

Theorem 2.4

Let \(f(x,y)\) be a continuously differentiable real-valued function, with \(\nabla f \ne \textbf{0}\). Then:

  1. The gradient \(\nabla f\) is normal to any level curve \(f(x,y)=c\).

  2. The value of \(f(x,y)\) increases the fastest in the direction of \(\nabla f\).

  3. The value of \(f(x,y)\) decreases the fastest in the direction of \(-\nabla f\).


width height 0.5pt

Example 2.16

In which direction does the function \(f(x,y) = xy^2 + x^3 y\) increase the fastest from the point \((1,2)\)? In which direction does it decrease the fastest?

Solution: Since \(\nabla f = (y^2 + 3x^2 y, 2xy + x^3)\), then \(\nabla f(1,2) = (10,5) \ne \textbf{0}\). A unit vector in that direction is \(\textbf{v} = \frac{\nabla f}{\norm{\nabla f}} = \biggl( \frac{2}{\sqrt{5}}, \frac{1}{\sqrt{5}} \biggr)\). Thus, \(f\) increases the fastest in the direction of \(\biggl( \frac{2}{\sqrt{5}}, \frac{1}{\sqrt{5}} \biggr)\) and decreases the fastest in the direction of \(\biggl( \frac{-2}{\sqrt{5}}, \frac{-1}{\sqrt{5}} \biggr)\).


width height 0.5pt

Though we proved Theorem 2.4 for functions of two variables, a similar argument can be used to show that it also applies to functions of three or more variables. Likewise, the directional derivative in the three-dimensional case can also be defined by the formula \(\ssub{D}{\textbf{v}}f = \Dotprod{\textbf{v}}{\nabla f}\).


width height 0.5pt

Example 2.17

The temperature \(T\) of a solid is given by the function \(T(x,y,z) = e^{-x} + e^{-2y} + e^{4z}\), where \(x\), \(y\), \(z\) are space coordinates relative to the center of the solid. In which direction from the point \((1,1,1)\) will the temperature decrease the fastest?

Solution: Since \(\nabla f = (-e^{-x},-2e^{-2y},4e^{4z})\), then the temperature will decrease the fastest in the direction of \(-\nabla f(1,1,1) = (e^{-1},2e^{-2},-4e^4 )\).


width height 0.5pt

Exercises

A

For Exercises 1-10, compute the gradient \(\nabla f\).

2

  1. \(f(x,y) = x^2 + y^2 - 1 \phantom{\dfrac{1}{x^2}}\)

  2. \(f(x,y) = \dfrac{1}{x^2 + y^2}\)

    2

  3. \(f(x,y) = \sqrt{x^2 + y^2 + 4}\)

  4. \(f(x,y) = x^2 e^y\)

    2

  5. \(f(x,y) = \ln(xy)\)

  6. \(f(x,y) = 2x+5y\)

    2

  7. \(f(x,y,z) = \sin (xyz)\)

  8. \(f(x,y,z) = x^2 e^{yz}\)

    2

  9. \(f(x,y,z) = x^2 + y^2 + z^2\)

  10. \(f(x,y,z) = \sqrt{x^2 + y^2 + z^2}\)

For Exercises 11-14, find the directional derivative of \(f\) at the point \(P\) in the direction of \(\textbf{v} = \biggl( \frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}} \biggr)\).

2

  1. \(f(x,y) = x^2 + y^2 - 1\), \(P=(1,1) \phantom{\dfrac{1}{x^2}}\)

  2. \(f(x,y) = \dfrac{1}{x^2 + y^2}\), \(P=(1,1)\)

    2

  3. \(f(x,y) = \sqrt{x^2 + y^2 + 4}\), \(P=(1,1)\)

  4. \(f(x,y) = x^2 e^y\), \(P=(1,1)\)

For Exercises 15-16, find the directional derivative of \(f\) at the point \(P\) in the direction of \(\textbf{v} = \biggl( \frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}} \biggr)\).

2

  1. \(f(x,y,z) = \sin (xyz)\), \(P=(1,1,1)\)

  2. \(f(x,y,z) = x^2 e^{yz}\), \(P=(1,1,1)\)

  3. Repeat Example 2.16 at the point \((2,3)\).

  4. Repeat Example 2.17 at the point \((3,1,2)\).

B

For Exercises 19-26, let \(f(x,y)\) and \(g(x,y)\) be continuously differentiable real-valued functions, let \(c\) be a constant, and let v be a unit vector in \(\Real{2}\). Show that:

2

  1. \(\nabla (cf) = c\,\nabla f\)

  2. \(\nabla (f+g) = \nabla f + \nabla g\)

    2

  3. \(\nabla (fg) = f\,\nabla g + g\,\nabla f \phantom{\dfrac{g\,\nabla f - f\,\nabla g}{g^2}}\)

  4. \(\nabla (f/g) = \dfrac{g\,\nabla f - f\,\nabla g}{g^2} ~\) if \(g(x,y) \ne 0\)

    2

  5. \(\ssub{D}{-\textbf{v}}f = -\ssub{D}{\textbf{v}}f\)

  6. \(\ssub{D}{\textbf{v}}(cf) = c\,\ssub{D}{\textbf{v}}f\)

    2

  7. \(\ssub{D}{\textbf{v}}(f+g) = \ssub{D}{\textbf{v}}f ~+~ \ssub{D}{\textbf{v}}g\)

  8. \(\ssub{D}{\textbf{v}}(fg) = f\,\ssub{D}{\textbf{v}}g ~+~ g\,\ssub{D}{\textbf{v}}f\)

  9. The function \(r(x,y) = \sqrt{x^2 + y^2}\) is the length of the position vector \(\textbf{r}=x\,\textbf{i} + y\,\textbf{j}\) for each point \((x,y)\) in \(\Real{2}\). Show that \(\nabla r = \dfrac{1}{r}\,\textbf{r}~\) when \((x,y) \ne (0,0)\), and that \(\nabla (r^2 ) = 2\,\textbf{r}\).


  1. Sometimes the notation grad(\(f\)) is used instead of \(\nabla f\).