We've seen how a function of two variables, like $f(x, y)$ represents a surface in three dimensions — with two independent variables. We can write the $z$ coordinate as the dependent variable, $z = f(x, y)$.
We've studied partial derivatives:
Now we'll ask whether we can find the slope of such a surface in any arbitrary direction. Say we have a point $P$ on $f(x, y)$. Now we can recall that the gradient vector is
$$\nabla f(x, y) = \left( \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y} \right)$$
and these gradients,
$$ \begin{align} \nabla f \cdot \hat i &= f_x \\[5pt] \nabla f \cdot \hat j &= f_y \end{align}$$
are gradients (slopes) in the $x$- and $y$-directions, aligned with our coordinate system. What if we could replace those directions with some arbitrary direction vector, $\vec u$.
Here's a picture that illustrates the idea. The direction vector $\vec u$ is not along the $x$ or $y$ axes.
The directional derivative of the function $f$ in the direction of $\vec u$, which we write as $D_{\vec u} f$, is
$$D_{\vec u} f = \frac{\nabla f \cdot \vec u}{|\vec u |}$$
Recall that $\frac{\vec u}{|\vec u|}$ is just the normalized version of $\vec u$, which is $\hat u$.
Let's see if we can outline where that definition comes from. Take a function $z = f(x,y)$ that has a graph like the one shown below. Now let's take a direction vector $\vec u$ (
First, let's call the components of $\hat u$ be $\vec u = (u_1, u_2)$. And let's parameterize our trip along $f(x,y)$ in the direction of $\hat u$ with a parameter $s$, which could loosely be speed or time — it doesn't really matter. That makes $f(x,y)$ into the compound function $f(x(s), y(s))$, which will beg the chain rule in a minute.
Then we can write
$$ \begin{align} x(s) &= x_o + u_1 s \tag{1} \\[5pt] y(s) &= y_o + u_2 s \end{align}$$
Notice that $x'(s) = u_1$ and $y'(s) = u_2$. Then the derivative of our function in the direction of $\hat u$ is
$$D_{\hat u} f(x_o,y_o) = \lim_{s \to 0} \frac{f(x_o+s u_1, y_o +s u_2) - f(x_o, y_o)}{s}$$
This is the usual definition of the derivative, the slope (rise over run) of a secant line on our curve, taken as the distance between the two points that define the secant line goes to zero — that is, as $s \rightarrow 0$. But how do we actually compute it? First, we use the chain rule:
$$ \begin{align} \frac{d}{ds} \left[ f(x(s), y(s)) \right] &= \left( \frac{\partial f}{\partial x}_{(x_o,y_o)} \frac{dx}{ds} \right) \\[5pt] &+ \left( \frac{\partial f}{\partial y}_{(x_o,y_o)} \frac{dy}{ds} \right) \end{align}$$
Recall from (1) above that $\frac{dx}{ds} = u_1$ and $\frac{dy}{ds} = u_2$, so we can write
$$\frac{df}{ds} = \left( \frac{\partial f}{\partial x}_{(x_o,y_o)} u_1 \right) + \left( \frac{\partial f}{\partial y}_{(x_o,y_o)} u_2 \right)$$
Well, there is a gradient and a dot product hidden in there:
$$\frac{df}{ds} = \nabla f |_{(x_o, y_o)} \cdot (u_1, u_2)$$
Let's streamline that a little more and write
$$\frac{df}{ds} = \nabla f |_{(x_o, y_o)} \cdot \hat u$$
Now notice that the directional derivative is just the dot product of the standard gradient vector of the function with the unit direction vector, $\hat u$ — pretty simple. And the calculation is equally simple. Here are a couple of examples.
Take the function in the graph above, and let $a = 9$, giving $f(x,y) = 9 - x^2 - y^2$. Find the directional derivative in the direction (1, 2) over the point (1, 1) in the $x-y$ plane.
$$ \begin{align} \nabla f &= \left( \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y} \right) \\[5pt] &= (-2x, -2y) \\[5pt] \nabla f(1,1) &= (-2, -2) \end{align}$$
Let $\vec u = (1, 2) = \hat i + 2 \hat j$. Then the length of $\vec u$ is
$$| \vec u | = \sqrt{1^2 + 2^2} = \sqrt{5}$$
Now we can compute our directional derivative:
$$ \begin{align} D_{\vec u} f &= \frac{\nabla f \cdot \vec u}{\vec u} \\[5pt] &= \frac{(-2,-2) \cdot (1, 2)}{\sqrt{5}} \\[5pt] &= \frac{-2(1) - 2(2)}{\sqrt{5}} \\[5pt] &= -\frac{6}{\sqrt{5}} = -\frac{6 \sqrt 5}{5} \end{align}$$
Find the directional derivative of $f(x,y) = (1+xy)^{3/2}$ at point $P = (3, 1)$ and in the direction $\vec u = (1, 1)$.
$$ \begin{align} \nabla f &= \left( \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y} \right) \\[5pt] &= \left( \frac{3}{2} y \sqrt{1 + xy}, \frac{3}{2} x \sqrt{1 + xy} \right) \\[5pt] \nabla f(3,1) &= (3, 9) \end{align}$$
Let $\vec u = (1, 1) = \hat i + \hat j$. Then the length of $\vec u$ is
$$| \vec u | = \sqrt{1^2 + 1^2} = \sqrt{2}$$
Now we can compute our directional derivative:
$$ \begin{align} D_{\vec u} f &= \frac{\nabla f \cdot \vec u}{\vec u} \\[5pt] &= \frac{(3,9) \cdot (1, 1)}{\sqrt{2}} \\[5pt] &= \frac{3(1) + 9(1)}{\sqrt{2}} \\[5pt] &= \frac{12}{\sqrt{2}} = 6 \sqrt{2} \end{align}$$
Let's do an example with three independent variables — it's the same idea. Find the derivative of $f(x,y,z) = x^2+2y^2+3z^2$ at point $P_o = (3,2,1)$ along the direction $\vec u = (2, 1, 1)$.
$$\hat u = \frac{(2,1,1)}{\sqrt{2^2+1^2+1^2}} = \frac{1}{\sqrt{6}}(2,1,1)$$
The gradient of $f(x,y,z)$ is
$$\nabla f(x,y,z) = (2x,4y,6z)$$
Now the directional derivative is
$$ \begin{align} \nabla f(x,y,z) \cdot \hat u &= (2x,4y,6z) \cdot (2,1,1) \frac{1}{\sqrt{6}} \\[5pt] &= \frac{1}{\sqrt{6}} (4x+4y+6z) \end{align}$$
Then we plug in our point, $P_o$:
$$ \begin{align} D_{\hat u}(3,2,1) &= \frac{1}{\sqrt{6}} (4x+4y+6z) \\[5pt] &= \frac{1}{\sqrt{6}} [4(3)+4(2)+6(1)] \\[5pt] &= \frac{12}{\sqrt{6}} + \frac{8}{\sqrt{6}} + \frac{6}{\sqrt{6}} \\[5pt] &= \frac{26}{\sqrt{6}} \end{align}$$
Find an equation of the plane tangent to the surface at the given point.
For $f(x,y) = 4 - x^2 - y^2$, calculate the derivative of $f$ above point $(1, 1)$ in the $x-y$ plane and along the vector $\vec u = (1, 3)$. What does it mean that $\nabla f(0, 0) = \vec 0$ for this function?
First calculate the unit vector form of $\vec u$:
$$ \begin{align} |\vec u| &= \sqrt{1^2 + 3^2} = \sqrt{10} \\[5pt] \hat u &= \frac{1}{\sqrt{10}} (1, 3) \end{align}$$
Now $\nabla f = (-2x, -2y)$, so
$$ \begin{align} \nabla f \cdot \hat u &= (-2x, -2y) \cdot (1, 3) \frac{1}{\sqrt{10}} \\[5pt] &= \frac{-2x}{\sqrt{10}} - \frac{6y}{\sqrt{10}} \end{align}$$
Finally,
$$\nabla f \cdot \hat u(1, 1) = \frac{-2}{\sqrt{10}} - \frac{6}{\sqrt{10}} = \frac{-8}{\sqrt{10}}$$
This makes sense because the function is a downward-opening paraboloid, which we'd expect to have a negative slope in this direction. The gradient of the function, $\nabla f(0,0) = (0, 0)$, the zero vector. This is because $(0,0)$ is the global maximum value of the function.
Find the directional derivative of $f(x,y) = sin(xy^2)$ above point $P = (\pi/4, 2)$ in the direction of $\vec u = (1, 1)$
The unit direction vector is
$$\hat u = \frac{1}{\sqrt{2}}(1, 1)$$
The gradient vector is
$$\nabla f = (y^2cos(xy^2), 2xy \, cos(xy^2))$$
Then we have
$$ \begin{align} \nabla f &= (y^2cos(xy^2), 2xy \, cos(xy^2)) \cdot (1,1) \frac{1}{\sqrt{2}} \\[5pt] &= \frac{1}{\sqrt{2}} \left[ y^2 cos(xy^2) + 2xy \, cos(xy^2) \right] \end{align}$$
Finally,
$$ \require{cancel} \begin{align} \nabla f &\left( \frac{\pi}{4}, 2 \right) \cdot \hat u \\[5pt] &= \frac{1}{\sqrt{2}} \left[ 4 cos(\pi) + \cancel{2} \left(\frac{\pi}{\cancel{4}} \right)\cancel{2} cos(\pi) \right] \\[5pt] &= \frac{1}{\sqrt{2}} \left[ (4 + \pi) cos(\pi) \right] \\[5pt] &= -\frac{1}{\sqrt{2}} (4 + \pi) \\[5pt] &= \frac{-(4+\pi)}{\sqrt{2}} \end{align}$$
Find the derivative of $f(x,y) = x^2 + xy + y^2$ above point $P = (0, 1)$ in the direction of $-3 \hat i + 4 \hat j$.
The unit vector version of $\vec u$ is
$$ \begin{align} |\vec u| &= \sqrt{(-3)^2+4^2} = \sqrt{25} = 5 \\[5pt] \rightarrow \; \hat u &= \frac{1}{5}(-3, 4) \end{align}$$
The gradient is
$$\nabla f(x,y) = (2x + y, 2y + x)$$
$$ \begin{align} \nabla f \cdot \hat u &= -\frac{3}{5}(2x + y) + \frac{4}{5} (2y + x) \\[5pt] &= -\frac{6}{5} x - \frac{3}{5} y + \frac{8}{5} y + \frac{4}{5} x \\[5pt] &= -\frac{1}{5} x + y \end{align}$$
Then
$$\nabla f(0, 1) \cdot \hat u = -\frac{1}{5} (0) + 1 = 1$$
Find the derivative of $f(x,y,z) = (x-y)(y-z)(z-x)$ above point $P = (1,1,1)$ in any direction.
It will be easier to find the gradient (take the derivatives) if we expand these binomials:
$$ \begin{align} f(x,y,z) &= (x-y)(y-z)(z-x) \\[5pt] &= (xy - xz - y^2 + yz)(z-x) \\[5pt] &= \cancel{xyz} - x^2 y - xz^2 + x^2z \\[5pt] &\phantom{000} - y^2z + xy^2 + yz^2 - \cancel{xyz} \\[5pt] &= -x^2 y - xz^2 + x^2z - y^2z + xy^2 + yz^2 \end{align}$$
Now the gradient is
$$ \begin{align} \nabla f &= (-2xy - z^2 + 2xz + y^2, \\[5pt] &\phantom{000} -x^2 - 2yz + x + 2yz, \\[5pt] &\phantom{000} -2xz + x^2 - y^2 + 2yz) \end{align}$$
and
$$ \begin{align} \nabla f(1,1,1) &= (-2-1+2+1,\\[5pt] &-1-2+1+2, \\[5pt] &-2+1-1+2) \\[5pt] &= (0,0,0) \end{align}$$
Now the directional derivative in an unspecified direction, $\hat u = (u_1, u_2, u_3)$ is
$$ \begin{align} \nabla f(1,1,1) &\cdot (u_1, u_2, u_3) \\[5pt] &= (0,0,0) \cdot (u_1, u_2, u_3) = 0 \end{align}$$
So the directional derivative at this point in any direction is zero.
Notice that in this problem you have to be meticulous about your algebra — there are a lot of steps and many opportunities to make a sign error.
Suppose that $z = e^{xy+x-y}$.
Moving away from the origin toward $(2, 1)$ means moving in the direction of $\vec u = (2, 1)$. The unit vector is
$$\hat u = \frac{1}{\sqrt{5}}(2, 1)$$
The gradient of $f(x,y)$ is
$$ \begin{align} \nabla f &= \left( e^{xy+x-y}(y+1), e^{xy+x-y}(x-1) \right) \\[5pt] \nabla f(2,1) &= \left( e^{2+2-1}(1+1), e^{2+2-1}(1) \right) \\[5pt] &= (2e^3, e^3) \\[5pt] &= e^3(2, 1) \end{align}$$
Now
$$ \begin{align} \nabla f(2, 1) \cdot \hat u &= e^3(2, 1)\cdot (2, 1) \frac{1}{\sqrt{5}} \\[5pt] &= e^3[2(2)+1(1)] \frac{1}{\sqrt{5}} \\[5pt] &= e^3 \cdot 5 \sqrt{5} \end{align}$$
The direction of maximum slope is the gradient. The gradient we found above, evaluated at the origin is
$$ \begin{align} \nabla f &= \left( e^{xy+x-y}(y+1), e^{xy+x-y}(x-1) \right) \\[5pt] \nabla f(0,0) &= \left( e^0(0+1), e^0(0-1) \right) \\[5pt] &= (1, -1) \end{align}$$
That is the direction of steepest ascent. The magnitude of the slope is the length of this vector:
$$|(1, -1)| = \sqrt{2}$$
Consider the function $f(x,y) = \frac{x^2-y^2}{x^2+y^2}$. In what direction is the directional derivative of $f$ at $(1, 1)$ equal to zero?
We'll just call our unknown direction unit vector
$$\hat u = (u_1, u_2)$$
And we'll seek to find the $u_1$ and $u_2$ that yield
$$\nabla f \cdot \hat u = 0$$
Let's do the gradient in pieces:
$$ \begin{align} \frac{\partial f}{\partial x} &= \frac{(x^2+y^2)(2x) - (x^2-y^2)(2x)}{(x^2+y^2)^2} \\[5pt] &= \frac{\cancel{2x^3}+2xy^2 - \cancel{2x^3} + 2xy^2}{(x^2+y^2)^2} \\[5pt] &= \frac{4xy^2}{x^2+y^2)^2} \\[5pt] \frac{\partial f}{\partial y} &= \frac{(x^2+y^2)(-2y) - (x^2-y^2)(2y)}{(x^2+y^2)^2} \\[5pt] &= \frac{-2x^2y - \cancel{-2y^3} - 2x^2y + \cancel{2y^3}}{(x^2+y^2)^2} \\[5pt] &= \frac{-4xy^2}{(x^2+y^2)^2} \\[5pt] \rightarrow \nabla f &= \left( \frac{4xy^2}{x^2+y^2)^2}, \frac{-4xy^2}{(x^2+y^2)^2} \right) \end{align}$$
Evaluated at $(1, 1)$, the gradient is
$$\nabla f(1, 1) = \left( \frac{4}{2^2}, \frac{-4}{2^2} \right) = (1, -1)$$
Now in order to have a directional derivative of zero, we require that
$$ \begin{align} \nabla f(1, 1) \cdot (u_1, u_2) &= 0 \\[5pt] (1, -1) \cdot (u_1, u_2) &= 0 \\[5pt] u_1 - u^2 = 0 \end{align}$$
So the directional derivative is zero when $u_1 = u_2$, that is, directions specified by $(1, 1)$ and $(-1,-1)$.
xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2024, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to jeff.cruzan@verizon.net.