Section 4.6Directional Derivatives and the Gradient
In Partial Derivatives we introduced the partial derivative. A function \(z=f(x,y)\) has two partial derivatives: \(∂z\text{/}∂x\) and \(∂z\text{/}∂y.\) These derivatives correspond to each of the independent variables and can be interpreted as instantaneous rates of change (that is, as slopes of a tangent line). For example, \(∂z\text{/}∂x\) represents the slope of a tangent line passing through a given point on the surface defined by \(z=f(x,y),\) assuming the tangent line is parallel to the x-axis. Similarly, \(∂z\text{/}∂y\) represents the slope of the tangent line parallel to the \(y\text{-axis.}\) Now we consider the possibility of a tangent line parallel to neither axis.
Directional Derivatives
We start with the graph of a surface defined by the equation \(z=f(x,y).\) Given a point \((a,b)\) in the domain of \(f,\) we choose a direction to travel from that point. We measure the direction using an angle \(θ,\) which is measured counterclockwise in the x, y-plane, starting at zero from the positive x-axis (Figure 1). The distance we travel is \(h\) and the direction we travel is given by the unit vector \(u=(\text{cos}\,θ)i+(\text{sin}\,θ)j.\) Therefore, the z-coordinate of the second point on the graph is given by \(z=f(a+h\,\text{cos}\,θ,b+h\,\text{sin}\,θ).\)

We can calculate the slope of the secant line by dividing the difference in \(z\text{-values}\) by the length of the line segment connecting the two points in the domain. The length of the line segment is \(h.\) Therefore, the slope of the secant line is
\[{m}_{\text{sec}}=\frac{f(a+h\,\text{cos}\,θ,b+h\,\text{sin}\,θ)-f(a,b)}{h}.\]
To find the slope of the tangent line in the same direction, we take the limit as \(h\) approaches zero.
Suppose \(z=f(x,y)\) is a function of two variables with a domain of \(D.\) Let \((a,b)\in D\) and define \(\text{u}=\text{cos}\,θi+\text{sin}\,θj.\) Then the directional derivative of \(f\) in the direction of \(u\) is given by
\[{D}_{u}f(a,b)=\underset{h\to 0}{\text{lim}}\frac{f(a+h\,\text{cos}\,θ,b+h\,\text{sin}\,θ)-f(a,b)}{h},\]
provided the limit exists.
Equation 2 provides a formal definition of the directional derivative that can be used in many cases to calculate a directional derivative.
Let \(θ=\text{arccos}(3\text{/}5).\) Find the directional derivative \({D}_{u}f(x,y)\) of \(f(x,y)={x}^{2}-xy+3{y}^{2}\) in the direction of \(\text{u}=(\text{cos}\,θ)i+(\text{sin}\,θ)j.\) What is \({D}_{u}f(-1,2)?\)
Substitute \(f(x+h\,\text{cos}\,θ,y+h\,\text{sin}\,θ)\) into the difference-quotient definition of \({D}_{u}f,\) simplify, then take the limit as \(h\to 0.\)
First of all, since \(\text{cos}\,θ=3\text{/}5\) and \(θ\) is acute, this implies
\[\text{sin}\,θ=\sqrt{1-{(\frac{3}{5})}^{2}}=\sqrt{\frac{16}{25}}=\frac{4}{5}.\]
Using \(f(x,y)={x}^{2}-xy+3{y}^{2},\) we first calculate \(f(x+h\,\text{cos}\,θ,y+h\,\text{sin}\,θ)\text{:}\)
\[\begin{array}{ll}f(x+h\,\text{cos}\,θ,y+h\,\text{sin}\,θ) & ={(x+h\,\text{cos}\,θ)}^{2}-(x+h\,\text{cos}\,θ)(y+h\,\text{sin}\,θ)+3{(y+h\,\text{sin}\,θ)}^{2} \\ & ={x}^{2}+2xh\,\text{cos}\,θ+{h}^{2}{\text{cos}}^{2}θ-xy-xh\,\text{sin}\,θ-yh\,\text{cos}\,θ \\ & \,{\text{-h}}^{2}\text{sin}\,θ\,\text{cos}\,θ+3{y}^{2}+6yh\,\text{sin}\,θ+3{h}^{2}{\text{sin}}^{2}θ \\ & ={x}^{2}+2xh(\frac{3}{5})+\frac{9{h}^{2}}{25}-xy-\frac{4xh}{5}-\frac{3yh}{5}-\frac{12{h}^{2}}{25}+3{y}^{2} \\ & \,+6yh(\frac{4}{5})+3{h}^{2}(\frac{16}{25}) \\ & ={x}^{2}-xy+3{y}^{2}+\frac{2xh}{5}+\frac{9{h}^{2}}{5}+\frac{21yh}{5}.\end{array}\]
We substitute this expression into Equation 2:
\[\begin{array}{ll}{D}_{u}f(a,b) & =\underset{h\to 0}{\text{lim}}\frac{f(a+h\,\text{cos}\,θ,b+h\,\text{sin}\,θ)-f(a,b)}{h} \\ & =\underset{h\to 0}{\text{lim}}\frac{({x}^{2}-xy+3{y}^{2}+\frac{2xh}{5}+\frac{9{h}^{2}}{5}+\frac{21yh}{5})-({x}^{2}-xy+3{y}^{2})}{h} \\ & =\underset{h\to 0}{\text{lim}}\frac{\frac{2xh}{5}+\frac{9{h}^{2}}{5}+\frac{21yh}{5}}{h} \\ & =\underset{h\to 0}{\text{lim}}\frac{2x}{5}+\frac{9h}{5}+\frac{21y}{5} \\ & =\frac{2x+21y}{5}.\end{array}\]
To calculate \({D}_{u}f(-1,2),\) we substitute \(x=-1\) and \(y=2\) into this answer:
\[\begin{array}{ll}{D}_{u}f(-1,2) & =\frac{2(-1)+21(2)}{5} \\ & =\frac{-2+42}{5} \\ & =8.\end{array}\]
(See the following figure.)

Another approach to calculating a directional derivative involves partial derivatives, as outlined in the following theorem.
Let \(z=f(x,y)\) be a function of two variables \(x\,\text{and}\,y,\) and assume that \({f}_{x}\) and \({f}_{y}\) exist and \(f(x, y)\) is differentiable everywhere. Then the directional derivative of \(f\) in the direction of \(\text{u}=\text{cos}\,θ\text{i}+\text{sin}\,θ\text{j}\) is given by
\[{D}_{u}f(x,y)={f}_{x}(x,y)\text{cos}\,θ+{f}_{y}(x,y)\text{sin}\,θ.\]
Proof
Equation 2 states that the directional derivative of f in the direction of \(u=\text{cos}\,θi+\text{sin}\,θj\) is given by
\[{D}_{u}f(a,b)=\underset{t\to 0}{\text{lim}}\frac{f(a+t\,\text{cos}\,θ,b+t\,\text{sin}\,θ)-f(a,b)}{t}.\]
Let \(x=a+t\,\text{cos}\,θ\) and \(y=b+t\,\text{sin}\,θ,\) and define \(g(t)=f(x,y).\) Since \({f}_{x}\) and \({f}_{y}\) both exist, and therefore \(f\) is differentiable, we can use the chain rule for functions of two variables to calculate \({g}^{\prime }(t)\text{:}\)
\[\begin{array}{ll}{g}^{\prime }(t) & =\frac{∂\text{f}}{∂\text{x}}\,\frac{dx}{dt}+\frac{∂\text{f}}{∂\text{y}}\,\frac{dy}{dt} \\ & ={f}_{x}(x,y)\text{cos}\,θ+{f}_{y}(x,y)\text{sin}\,θ.\end{array}\]
If \(t=0,\) then \(x={x}_{0}(=a)\) and \(y={y}_{0}(=b),\) so
\[{g}^{\prime }(0)={f}_{x}({x}_{0},{y}_{0})\text{cos}\,θ+{f}_{y}({x}_{0},{y}_{0})\text{sin}\,θ.\]
By the definition of \({g}^{\prime }(t),\) it is also true that
\[\begin{array}{ll}{g}^{\prime }(0) & =\underset{t\to 0}{\text{lim}}\frac{g(t)-g(0)}{t} \\ & =\underset{t\to 0}{\text{lim}}\frac{f({x}_{0}+t\,\text{cos}\,θ,{y}_{0}+t\,\text{sin}\,θ)-f({x}_{0},{y}_{0})}{t}.\end{array}\]
Therefore, \({D}_{u}f({x}_{0},{y}_{0})={f}_{x}(x,y)\text{cos}\,θ+{f}_{y}(x,y)\text{sin}\,θ.\)
□
Let \(θ=\text{arccos}(3\text{/}5).\) Find the directional derivative \({D}_{u}f(x,y)\) of \(f(x,y)={x}^{2}-xy+3{y}^{2}\) in the direction of \(u=(\text{cos}\,θ)i+(\text{sin}\,θ)j.\) What is \({D}_{u}f(-1,2)?\)
Compute \({f}_{x}\) and \({f}_{y},\) then substitute them into the formula \({D}_{u}f={f}_{x}\text{cos}\,θ+{f}_{y}\text{sin}\,θ\) using the given \(θ.\)
First, we must calculate the partial derivatives of \(f\text{:}\)
\[\begin{array}{l}{f}_{x}=2x-y \\ {f}_{y}=\text{-}x+6y,\end{array}\]
Then we use Equation 7 with \(θ=\text{arccos}(3\text{/}5)\text{:}\)
\[\begin{array}{ll}{D}_{u}f(x,y) & ={f}_{x}(x,y)\text{cos}\,θ+{f}_{y}(x,y)\text{sin}\,θ \\ & =(2x-y)\frac{3}{5}+(\text{-}x+6y)\frac{4}{5} \\ & =\frac{6x}{5}-\frac{3y}{5}-\frac{4x}{5}+\frac{24y}{5} \\ & =\frac{2x+21y}{5}.\end{array}\]
To calculate \({D}_{u}f(-1,2),\) let \(x=-1\) and \(y=2\text{:}\)
\[{D}_{u}f(-1,2)=\frac{2(-1)+21(2)}{5}=\frac{-2+42}{5}=8.\]
This is the same answer obtained in Example 1.
Gradient
The right-hand side of Equation 7 is equal to \({f}_{x}(x,y)\text{cos}\,θ+{f}_{y}(x,y)\text{sin}\,θ,\) which can be written as the dot product of two vectors. Define the first vector as \(∇f(x,y)={f}_{x}(x,y)\text{i}+{f}_{y}(x,y)\text{j}\) and the second vector as \(u=(\text{cos}\,θ)i+(\text{sin}\,θ)j.\) Then the right-hand side of the equation can be written as the dot product of these two vectors:
\[{D}_{u}f(x,y)=∇f(x,y)·u.\]
The first vector in Equation 15 has a special name: the gradient of the function \(f.\) The symbol \(∇\) is called nabla and the vector \(∇f\) is read \(\text{“del}\,f\text{.”}\)
Let \(z=f(x,y)\) be a function of \(x\,\text{and}\,y\) such that \({f}_{x}\) and \({f}_{y}\) exist. The vector \(∇f(x,y)\) is called the gradient of \(f\) and is defined as
\[∇f(x,y)={f}_{x}(x,y)i+{f}_{y}(x,y)j.\]
The vector \(∇f(x,y)\) is also written as \(\text{“grad}\,f\text{.”}\)
Find the directional derivative \({D}_{u}f(x,y)\) of \(f(x,y)=3{x}^{2}y-4x{y}^{3}+3{y}^{2}-4x\) in the direction of \(u=(\text{cos}\,\frac{\pi }{3})i+(\text{sin}\,\frac{\pi }{3})j\) using Equation 7. What is \({D}_{u}f(3,4)?\)
\(\begin{array}{l} \\ \\ {D}_{u}f(x,y)=\frac{(6xy-4{y}^{3}-4)(1)}{2}+\frac{(3{x}^{2}-12x{y}^{2}+6y)\sqrt{3}}{2} \\ {D}_{u}f(3,4)=\frac{72-256-4}{2}+\frac{(27-576+24)\sqrt{3}}{2}=-94-\frac{525\sqrt{3}}{2}\end{array}\)
If the vector that is given for the direction of the derivative is not a unit vector, then it is only necessary to divide by the norm of the vector. For example, if we wished to find the directional derivative of the function in Example 2 in the direction of the vector \(\langle -5,12\rangle ,\) we would first divide by its magnitude to get \(u.\) This gives us \(u=\langle \text{-}(5\text{/}13),12\text{/}13\rangle .\) Then
\[\begin{array}{ll}{D}_{u}f(x,y) & =∇f(x,y)·u \\ & =-\frac{5}{13}(2x-\frac{77}{12}y)+\frac{12}{13}(\text{-}x+6y) \\ & =-\frac{22}{13}x+\frac{17}{13}y.\end{array}\]
Find the gradient \(∇f(x,y)\) of each of the following functions:
- \(f(x,y)={x}^{2}-xy+3{y}^{2}\)
- \(f(x,y)=\text{sin}\,3x\,\text{cos}\,3y\)
Compute \({f}_{x}\) and \({f}_{y}\) for each function, then assemble them into the vector \(∇f={f}_{x}i+{f}_{y}j.\)
For both parts a. and b., we first calculate the partial derivatives \({f}_{x}\) and \({f}_{y},\) then use Equation 16.
\(\begin{array}{lll}{f}_{x}(x,y) & = & 2x-y\,\text{and}\,{f}_{y}(x,y)=\text{-}x+6y,\,\text{so} \\ ∇f(x,y) & = & {f}_{x}(x,y)i+{f}_{y}(x,y)j \\ & = & (2x-y)i+(\text{-}x+6y)j.\end{array}\)
\(\begin{array}{lll}{f}_{x}(x,y) & = & 3\,\text{cos}\,3x\,\text{cos}\,3y\,\text{and}\,{f}_{y}(x,y)=-3\,\text{sin}\,3x\,\text{sin}\,3y,\,\text{so} \\ ∇f(x,y) & = & {f}_{x}(x,y)i+{f}_{y}(x,y)j \\ & = & (3\,\text{cos}\,3x\,\text{cos}\,3y)i-(3\,\text{sin}\,3x\,\text{sin}\,3y)j.\end{array}\)
Find the gradient \(∇f(x,y)\) of \(f(x,y)=({x}^{2}-3{y}^{2})\text{/}(2x+y).\)
\(∇f(x,y)=\frac{2{x}^{2}+2xy+6{y}^{2}}{{(2x+y)}^{2}}i-\frac{{x}^{2}+12xy+3{y}^{2}}{{(2x+y)}^{2}}j\)
The gradient has some important properties. We have already seen one formula that uses the gradient: the formula for the directional derivative. Recall from The Dot Product that if the angle between two vectors \(a\) and \(b\) is \(φ,\) then \(a·\text{b}=\Vert a\Vert \Vert \text{b}\Vert \text{cos}\,φ.\) Therefore, if the angle between \(∇f({x}_{0},{y}_{0})\) and \(u=(\text{cos}\,θ)i+(\text{sin}\,θ)j\) is \(φ,\) we have
\[{D}_{u}f({x}_{0},{y}_{0})=∇f({x}_{0},{y}_{0})·u=\Vert ∇f({x}_{0},{y}_{0})\Vert \Vert u\Vert \text{cos}\,φ=\Vert ∇f({x}_{0},{y}_{0})\Vert \text{cos}\,φ.\]
The \(\Vert u\Vert\) disappears because \(u\) is a unit vector. Therefore, the directional derivative is equal to the magnitude of the gradient evaluated at \(({x}_{0},{y}_{0})\) multiplied by \(\text{cos}\,φ.\) Recall that \(\text{cos}\,φ\) ranges from \(-1\) to \(1.\) If \(φ=0,\) then \(\text{cos}\,φ=1\) and \(∇f({x}_{0},{y}_{0})\) and \(u\) both point in the same direction. If \(φ=\pi ,\) then \(\text{cos}\,φ=-1\) and \(∇f({x}_{0},{y}_{0})\) and \(u\) point in opposite directions. In the first case, the value of \({D}_{\text{u}}f({x}_{0},{y}_{0})\) is maximized; in the second case, the value of \({D}_{\text{u}}f({x}_{0},{y}_{0})\) is minimized. If \(∇f({x}_{0},{y}_{0})=0,\) then \({D}_{u}f({x}_{0},{y}_{0})=∇f({x}_{0},{y}_{0})·u=0\) for any vector \(u.\) These three cases are outlined in the following theorem.
Suppose the function \(z=f(x,y)\) is differentiable at \(({x}_{0},{y}_{0})\) (Figure 3).
- If \(∇f({x}_{0},{y}_{0})=0,\) then \({D}_{u}f({x}_{0},{y}_{0})=0\) for any unit vector \(u.\)
- If \(∇f({x}_{0},{y}_{0})\ne 0,\) then \({D}_{u}f({x}_{0},{y}_{0})\) is maximized when \(u\) points in the same direction as \(∇f({x}_{0},{y}_{0}).\) The maximum value of \({D}_{u}f({x}_{0},{y}_{0})\) is \(\Vert ∇f({x}_{0},{y}_{0})\Vert \text{.}\)
- If \(∇f({x}_{0},{y}_{0})\ne 0,\) then \({D}_{u}f({x}_{0},{y}_{0})\) is minimized when \(u\) points in the opposite direction from \(∇f({x}_{0},{y}_{0}).\) The minimum value of \({D}_{u}f({x}_{0},{y}_{0})\) is \(\text{-}\Vert ∇f({x}_{0},{y}_{0})\Vert \text{.}\)

Find the direction for which the directional derivative of \(f(x,y)=3{x}^{2}-4xy+2{y}^{2}\) at \((-2,3)\) is a maximum. What is the maximum value?
Compute \(∇f\) at the point, then normalize it to a unit vector — that direction gives the maximum, and the gradient's magnitude gives the maximum value.
The maximum value of the directional derivative occurs when \(∇f\) and the unit vector point in the same direction. Therefore, we start by calculating \(∇f(x,y)\text{:}\)
\[\begin{array}{lll}{f}_{x}(x,y) & = & 6x-4y\,\text{and}\,{f}_{y}(x,y)=-4x+4y,\,\text{so} \\ ∇f(x,y) & = & {f}_{x}(x,y)i+{f}_{y}(x,y)j=(6x-4y)i+(-4x+4y)j.\end{array}\]
Next, we evaluate the gradient at \((-2,3)\text{:}\)
\[∇f(-2,3)=(6(-2)-4(3))i+(-4(-2)+4(3))j=-24i+20j.\]
We need to find a unit vector that points in the same direction as \(∇f(-2,3),\) so the next step is to divide \(∇f(-2,3)\) by its magnitude, which is \(\sqrt{{(-24)}^{2}+{(20)}^{2}}=\sqrt{976}=4\sqrt{61}.\) Therefore,
\[\frac{∇f(-2,3)}{\Vert ∇f(-2,3)\Vert }=\frac{-24}{4\sqrt{61}}i+\frac{20}{4\sqrt{61}}j=\frac{-6\sqrt{61}}{61}i+\frac{5\sqrt{61}}{61}j.\]
This is the unit vector that points in the same direction as \(∇f(-2,3).\) To find the angle corresponding to this unit vector, we solve the equations
\[\text{cos}\,θ=\frac{-6\sqrt{61}}{61}\,\text{and}\,\text{sin}\,θ=\frac{5\sqrt{61}}{61}\]
for \(θ.\) Since cosine is negative and sine is positive, the angle must be in the second quadrant. Therefore, \(θ=\pi -\text{arcsin}((5\sqrt{61})\text{/}61)\approx 2.45\,\text{rad.}\)
The maximum value of the directional derivative at \((-2,3)\) is \(\Vert ∇f(-2,3)\Vert =4\sqrt{61}\) (see the following figure).

Find the direction for which the directional derivative of \(g(x,y)=4x-xy+2{y}^{2}\) at \((-2,3)\) is a maximum. What is the maximum value?
The gradient of \(g\) at \((-2,3)\) is \(∇g(-2,3)=i+14j.\) The unit vector that points in the same direction as \(∇g(-2,3)\) is \(\frac{∇g(-2,3)}{\Vert ∇g(-2,3)\Vert }=\frac{1}{\sqrt{197}}i+\frac{14}{\sqrt{197}}j=\frac{\sqrt{197}}{197}i+\frac{14\sqrt{197}}{197}j,\) which gives an angle of \(θ=\text{arcsin}((14\sqrt{197})\text{/}197)\approx 1.499\,\text{rad}.\) The maximum value of the directional derivative is \(\Vert ∇g(-2,3)\Vert =\sqrt{197}.\)
Figure 5 shows a portion of the graph of the function \(f(x,y)=3+\text{sin}\,x\,\text{sin}\,y.\) Given a point \((a,b)\) in the domain of \(f,\) the maximum value of the gradient at that point is given by \(\Vert ∇f(a,b)\Vert .\) This would equal the rate of greatest ascent if the surface represented a topographical map. If we went in the opposite direction, it would be the rate of greatest descent.

When using a topographical map, the steepest slope is always in the direction where the contour lines are closest together (see Figure 6). This is analogous to the contour map of a function, assuming the level curves are obtained for equally spaced values throughout the range of that function.

Gradients and Level Curves
Recall that if a curve is defined parametrically by the function pair \((x(t),y(t)),\) then the vector \({x}^{\prime }(t)i+{y}^{\prime }(t)j\) is tangent to the curve for every value of \(t\) in the domain. Now let’s assume \(z=f(x,y)\) is a differentiable function of \(x\,\text{and}\,y,\) and \(({x}_{0},{y}_{0})\) is in its domain. Let’s suppose further that \({x}_{0}=x({t}_{0})\) and \({y}_{0}=y({t}_{0})\) for some value of \(t,\) and consider the level curve \(f(x,y)=k.\) Define \(g(t)=f(x(t),y(t))\) and calculate \({g}^{\prime }(t)\) on the level curve. By the chain Rule,
\[{g}^{\prime }(t)={f}_{x}(x(t),y(t)){x}^{\prime }(t)+{f}_{y}(x(t),y(t)){y}^{\prime }(t).\]
But \({g}^{\prime }(t)=0\) because \(g(t)=k\) for all \(t.\) Therefore, on the one hand,
\[{f}_{x}(x(t),y(t)){x}^{\prime }(t)+{f}_{y}(x(t),y(t)){y}^{\prime }(t)=0;\]
on the other hand,
\[{f}_{x}(x(t),y(t)){x}^{\prime }(t)+{f}_{y}(x(t),y(t)){y}^{\prime }(t)=∇f(x,y)·\langle {x}^{\prime }(t),{y}^{\prime }(t)\rangle \text{.}\]
Therefore,
\[∇f(x,y)·\langle {x}^{\prime }(t),{y}^{\prime }(t)\rangle =0.\]
Thus, the dot product of these vectors is equal to zero, which implies they are orthogonal. However, the second vector is tangent to the level curve, which implies the gradient must be normal to the level curve, which gives rise to the following theorem.
Suppose the function \(z=f(x,y)\) has continuous first-order partial derivatives in an open disk centered at a point \(({x}_{0},{y}_{0}).\) If \(∇f({x}_{0},{y}_{0})\ne 0,\) then \(∇f({x}_{0},{y}_{0})\) is normal to the level curve of \(f\) at \(({x}_{0},{y}_{0}).\)
We can use this theorem to find tangent and normal vectors to level curves of a function.
For the function \(f(x,y)=2{x}^{2}-3xy+8{y}^{2}+2x-4y+4,\) find a tangent vector to the level curve at point \((-2,1).\) Graph the level curve corresponding to \(f(x,y)=18\) and draw in \(∇f(-2,1)\) and a tangent vector.
Compute \(∇f(-2,1);\) since the gradient is normal to the level curve there, swap its components and negate one of them to get a vector orthogonal to it.
First, we must calculate \(∇f(x,y)\text{:}\)
\[{f}_{x}(x,y)=4x-3y+2\,\text{and}\,{f}_{y}=-3x+16y-4\,\text{so}\,∇f(x,y)=(4x-3y+2)i+(-3x+16y-4)j.\]
Next, we evaluate \(∇f(x,y)\) at \((-2,1)\text{:}\)
\[∇f(-2,1)=(4(-2)-3(1)+2)i+(-3(-2)+16(1)-4)j=-9i+18j.\]
This vector is orthogonal to the curve at point \((-2,1).\) We can obtain a tangent vector by reversing the components and multiplying either one by \(-1.\) Thus, for example, \(-18i-9j\) is a tangent vector (see the following graph).

For the function \(f(x,y)={x}^{2}-2xy+5{y}^{2}+3x-2y+4,\) find the tangent to the level curve at point \((1,1).\) Draw the graph of the level curve corresponding to \(f(x,y)=9\) and draw \(∇f(1,1)\) and a tangent vector.
\(∇f(x,y)=(2x-2y+3)i+(-2x+10y-2)j\)
\(∇f(1,1)=3i+6j\)
Tangent vector: \(6i-3j\) or \(-6i+3j\)
Three-Dimensional Gradients and Directional Derivatives
The definition of a gradient can be extended to functions of more than two variables.
Let \(w=f(x,y,z)\) be a function of three variables such that \({f}_{x},{f}_{y},\text{and}\,{f}_{z}\) exist. The vector \(∇f(x,y,z)\) is called the gradient of \(f\) and is defined as
\[∇f(x,y,z)={f}_{x}(x,y,z)i+{f}_{y}(x,y,z)j+{f}_{z}(x,y,z)k.\]
\(∇f(x,y,z)\) can also be written as \(\text{grad}\,f(x,y,z).\)
Calculating the gradient of a function in three variables is very similar to calculating the gradient of a function in two variables. First, we calculate the partial derivatives \({f}_{x},{f}_{y},\) and \({f}_{z},\) and then we use Equation 29.
Find the gradient \(∇f(x,y,z)\) of each of the following functions:
- \(f(x,y,z)=5{x}^{2}-2xy+{y}^{2}-4yz+{z}^{2}+3xz\)
- \(f(x,y,z)={e}^{-2z}\text{sin}\,2x\,\text{cos}\,2y\)
Compute \({f}_{x},{f}_{y},\) and \({f}_{z}\) for each function, then assemble them into \(∇f={f}_{x}i+{f}_{y}j+{f}_{z}k.\)
For both parts a. and b., we first calculate the partial derivatives \({f}_{x},{f}_{y},\) and \({f}_{z},\) then use Equation 29.
\(\begin{array}{lll}{f}_{x}(x,y,z) & = & 10x-2y+3z,\,{f}_{y}(x,y,z)=-2x+2y-4z\,\text{and}\,{f}_{z}(x,y,z)=3x-4y+2z,\,\text{so} \\ ∇f(x,y,z) & = & {f}_{x}(x,y,z)i+{f}_{y}(x,y,z)j+{f}_{z}(x,y,z)k \\ & = & (10x-2y+3z)i+(-2x+2y-4z)j+(3x-4y+2z)k.\end{array}\)
\(\begin{array}{lll}{f}_{x}(x,y,z) & = & 2{e}^{-2z}\text{cos}\,2x\,\text{cos}\,2y,\,{f}_{y}(x,y,z)=-2{e}^{-2z}\text{sin}\,2x\,\text{sin}\,2y\,\text{and} \\ {f}_{z}(x,y,z) & = & -2{e}^{-2z}\text{sin}\,2x\,\text{cos}\,2y,\,\text{so} \\ ∇f(x,y,z) & = & {f}_{x}(x,y,z)i+{f}_{y}(x,y,z)j+{f}_{z}(x,y,z)k \\ & = & (2{e}^{-2z}\text{cos}\,2x\,\text{cos}\,2y)i+(-2{e}^{-2z}sin 2x sin 2y)j+(-2{e}^{-2z}sin 2x cos 2y)k \\ & = & 2{e}^{-2z}(\text{cos}\,2x\,\text{cos}\,2y\,\text{i}-\text{sin}\,2x\,\text{sin}\,2y\,\text{j}-\text{sin}\,2x\,\text{cos}\,2y\,\text{k}).\end{array}\)
Find the gradient \(∇f(x,y,z)\) of \(f(x,y,z)=\frac{{x}^{2}-3{y}^{2}+{z}^{2}}{2x+y-4z}.\)
\(\begin{array}{ll}∇f(x,y,z) & =\frac{2{x}^{2}+2xy+6{y}^{2}-8xz-2{z}^{2}}{{(2x+y-4z)}^{2}}i-\frac{{x}^{2}+12xy+3{y}^{2}-24yz+{z}^{2}}{{(2x+y-4z)}^{2}}j \\ & +\frac{4{x}^{2}-12{y}^{2}-4{z}^{2}+4xz+2yz}{{(2x+y-4z)}^{2}}k.\end{array}\)
The directional derivative can also be generalized to functions of three variables. To determine a direction in three dimensions, a vector with three components is needed. This vector is a unit vector, and the components of the unit vector are called directional cosines. Given a three-dimensional unit vector \(u\) in standard form (i.e., the initial point is at the origin), this vector forms three different angles with the positive \(x-,y-,\) and z-axes. Let’s call these angles \(α,β,\) and \(γ.\) Then the directional cosines are given by \(\text{cos}\,α,\text{cos}\,β,\) and \(\text{cos}\,γ.\) These are the components of the unit vector \(u;\) since \(u\) is a unit vector, it is true that \({\text{cos}}^{2}α+{\text{cos}}^{2}β+{\text{cos}}^{2}γ=1.\)
Suppose \(w=f(x,y,z)\) is a function of three variables with a domain of \(D.\) Let \(({x}_{0},{y}_{0},{z}_{0})\in D\) and let \(\text{u}=\text{cos}\,αi+\text{cos}\,βj+\text{cos}\,γk\) be a unit vector. Then, the directional derivative of \(f\) in the direction of \(u\) is given by
\[{D}_{u}f({x}_{0},{y}_{0},{z}_{0})=\underset{t\to 0}{\text{lim}}\frac{f({x}_{0}+t\,\text{cos}\,α,{y}_{0}+t\,\text{cos}\,β,{z}_{0}+t\,\text{cos}\,γ)-f({x}_{0},{y}_{0},{z}_{0})}{t},\]
provided the limit exists.
We can calculate the directional derivative of a function of three variables by using the gradient, leading to a formula that is analogous to Equation 15.
Let \(f(x,y,z)\) be a differentiable function of three variables and let \(u=\text{cos}\,αi+\text{cos}\,βj+\text{cos}\,γk\) be a unit vector. Then, the directional derivative of \(f\) in the direction of \(u\) is given by
\[\begin{array}{ll}{D}_{u}f(x,y,z) & =∇f(x,y,z)·u \\ & ={f}_{x}(x,y,z)\text{cos}\,α+{f}_{y}(x,y,z)\text{cos}\,β+{f}_{z}(x,y,z)\text{cos}\,γ.\end{array}\]
The three angles \(α,β,\,\text{and}\,γ\) determine the unit vector \(u.\) In practice, we can use an arbitrary (nonunit) vector, then divide by its magnitude to obtain a unit vector in the desired direction.
Calculate \({D}_{u}f(1,-2,3)\) in the direction of \(\text{v}=\text{-}i+2j+2k\) for the function
\[f(x,y,z)=5{x}^{2}-2xy+{y}^{2}-4yz+{z}^{2}+3xz.\]
Normalize \(v\) to get the directional cosines \(\text{cos}\,α,\text{cos}\,β,\text{cos}\,γ,\) compute \({f}_{x},{f}_{y},{f}_{z},\) then combine using \({D}_{u}f={f}_{x}\text{cos}\,α+{f}_{y}\text{cos}\,β+{f}_{z}\text{cos}\,γ.\)
First, we find the magnitude of \(v\text{:}\)
\[\Vert v\Vert =\sqrt{{(-1)}^{2}+{(2)}^{2}+{(2)}^{2}}=3.\]
Therefore, \(\frac{v}{\Vert v\Vert }=\frac{\text{-}i+2j+2k}{3}=-\frac{1}{3}i+\frac{2}{3}j+\frac{2}{3}k\) is a unit vector in the direction of \(v,\) so \(\text{cos}\,α=-\frac{1}{3},\text{cos}\,β=\frac{2}{3},\,\text{and}\,\text{cos}\,γ=\frac{2}{3}.\) Next, we calculate the partial derivatives of \(f\text{:}\)
\[\begin{array}{lll}{f}_{x}(x,y,z) & = & 10x-2y+3z \\ {f}_{y}(x,y,z) & = & -2x+2y-4z \\ {f}_{z}(x,y,z) & = & -4y+2z+3x,\end{array}\]
then substitute them into Equation 31:
\[\begin{array}{ll}{D}_{u}f(x,y,z) & ={f}_{x}(x,y,z)\text{cos}\,α+{f}_{y}(x,y,z)\text{cos}\,β+{f}_{z}(x,y,z)\text{cos}\,γ \\ & =(10x-2y+3z)(-\frac{1}{3})+(-2x+2y-4z)(\frac{2}{3})+(-4y+2z+3x)(\frac{2}{3}) \\ & =-\frac{10x}{3}+\frac{2y}{3}-\frac{3z}{3}-\frac{4x}{3}+\frac{4y}{3}-\frac{8z}{3}-\frac{8y}{3}+\frac{4z}{3}+\frac{6x}{3} \\ & =-\frac{8x}{3}-\frac{2y}{3}-\frac{7z}{3}.\end{array}\]
Last, to find \({D}_{u}f(1,-2,3),\) we substitute \(x=1,y=-2,\,\text{and}\,z=3\text{:}\)
\[\begin{array}{ll}{D}_{u}f(1,-2,3) & =-\frac{8(1)}{3}-\frac{2(-2)}{3}-\frac{7(3)}{3} \\ & =-\frac{8}{3}+\frac{4}{3}-\frac{21}{3} \\ & =-\frac{25}{3}.\end{array}\]
Calculate \({D}_{u}f(x,y,z)\) and \({D}_{u}f(0,-2,5)\) in the direction of \(\text{v}=-3i+12j-4k\) for the function \(f(x,y,z)=3{x}^{2}+xy-2{y}^{2}+4yz-{z}^{2}+2xz.\)
\(\begin{array}{lll}{D}_{u}f(x,y,z) & = & -\frac{3}{13}(6x+y+2z)+\frac{12}{13}(x-4y+4z)-\frac{4}{13}(2x+4y-2z) \\ {D}_{u}f(0,-2,5) & = & \frac{384}{13}\end{array}\)
Key Concepts
- A directional derivative represents a rate of change of a function in any given direction. (See Example 1.)
- The gradient can be used in a formula to calculate the directional derivative. (See Example 2 and Example 7.)
- The gradient indicates the direction of greatest change of a function of more than one variable. (See Example 4.)
Key Equations
| directional derivative (two dimensions) | \({D}_{u}f(a,b)=\underset{h\to 0}{\text{lim}}\frac{f(a+h\,\text{cos}\,θ,b+h\,\text{sin}\,θ)-f(a,b)}{h}\) or \({D}_{u}f(x,y)={f}_{x}(x,y)\text{cos}\,θ+{f}_{y}(x,y)\text{sin}\,θ\) |
| gradient (two dimensions) | \(∇f(x,y)={f}_{x}(x,y)i+{f}_{y}(x,y)j\) |
| gradient (three dimensions) | \(∇f(x,y,z)={f}_{x}(x,y,z)i+{f}_{y}(x,y,z)j+{f}_{z}(x,y,z)k\) |
| directional derivative (three dimensions) | \(\begin{array}{ll}{D}_{u}f(x,y,z) & =∇f(x,y,z)·u \\ & ={f}_{x}(x,y,z)\text{cos}\,α+{f}_{y}(x,y,z)\text{cos}\,β+{f}_{x}(x,y,z)\text{cos}\,γ\end{array}\) |
Section Exercises
For the following exercises, find the directional derivative using the limit definition only.
\(f(x,y)=5-2{x}^{2}-\frac{1}{2}{y}^{2}\) at point \(P(3,4)\) in the direction of \(\text{u}=(\text{cos}\,\frac{\pi }{4})i+(\text{sin}\,\frac{\pi }{4})j\)
\(f(x,y)={y}^{2}\text{cos}(2x)\) at point \(P(\frac{\pi }{3},2)\) in the direction of \(\text{u}=(\text{cos}\,\frac{\pi }{4})i+(\text{sin}\,\frac{\pi }{4})j\)
\(-2\sqrt{6}-\sqrt{2}\)
Find the directional derivative of \(f(x,y)={y}^{2}\text{sin}(2x)\) at point \(P(\frac{\pi }{4},2)\) in the direction of \(u=5i+12j.\)
For the following exercises, find the directional derivative of the function at point \(P\) in the direction of \(u\) or \(v\) as appropriate.
\(f(x,y)=xy,\) \(P(0,-2),\) \(v=\frac{1}{2}i+\frac{\sqrt{3}}{2}j\)
\(-1\)
\(h(x,y)={e}^{x}\text{sin}\,y,P(1,\frac{\pi }{2}),v=\text{-}i\)
\(h(x,y,z)=xyz,P(2,1,1),v=2i+j-k\)
\(\frac{2}{\sqrt{6}}\)
\(f(x,y)=xy,P(1,1),u=\langle \frac{\sqrt{2}}{2},\frac{\sqrt{2}}{2}\rangle\)
\(f(x,y)={x}^{2}-{y}^{2},\begin{array}{ll}u=\langle \frac{\sqrt{3}}{2},\frac{1}{2}\rangle , & P(1,0)\end{array}\)
\(\sqrt{3}\)
\(f(x,y)=3x+4y+7,\begin{array}{ll}u=\langle \frac{3}{5},\frac{4}{5}\rangle , & P(0,\frac{\pi }{2})\end{array}\)
\(\begin{array}{lll}f(x,y)={e}^{x}\text{cos}\,y, & u=\langle 0,1\rangle , & P=(0,\frac{\pi }{2})\end{array}\)
\(-1.0\)
\(\begin{array}{lll}f(x,y)={y}^{10}, & u=\langle 0,-1\rangle , & P=(1,-1)\end{array}\)
\(f(x,y)=\text{ln}({x}^{2}+{y}^{2}),\begin{array}{ll}u=\langle \frac{3}{5},\frac{4}{5}\rangle , & P(1,2)\end{array}\)
\(\frac{22}{25}\)
\(f(x,y)={x}^{2}y,\begin{array}{ll}P(-5,5), & v=3i-4j\end{array}\)
\(f(x,y,z)={y}^{2}+xz,\begin{array}{ll}P(1,2,2), & v=\langle 2,-1,2\rangle \end{array}\)
\(\frac{2}{3}\)
For the following exercises, find the directional derivative of the function in the direction of the unit vector \(u=\text{cos}\,θi+\text{sin}\,θj.\)
\(f(x,y)={x}^{2}+2{y}^{2},θ=\frac{\pi }{6}\)
\(f(x,y)=\frac{y}{x+2y},θ=-\frac{\pi }{4}\)
\(\frac{\text{-}\sqrt{2}(x+y)}{2{(x+2y)}^{2}}\)
\(f(x,y)=\text{cos}(3x+y),θ=\frac{\pi }{4}\)
\(w(x,y)=y{e}^{x},θ=\frac{\pi }{3}\)
\(\frac{{e}^{x}(y+\sqrt{3})}{2}\)
\(\begin{array}{ll}f(x,y)=x\,\text{arctan}(y), & θ=\frac{\pi }{2}\end{array}\)
\(\begin{array}{ll}f(x,y)=\text{ln}(x+2y), & θ=\frac{\pi }{3}\end{array}\)
\(\frac{1+2\sqrt{3}}{2(x+2y)}\)
For the following exercises, find the gradient.
Find the gradient of \(f(x,y)=\frac{14-{x}^{2}-{y}^{2}}{3}.\) Then, find the gradient at point \(P(1,2).\)
Find the gradient of \(f(x,y,z)=xy+yz+xz\) at point \(P(1,2,3).\)
\(\langle 5,4,3\rangle\)
Find the gradient of \(f(x,y,z)\) at \(P\) and the directional derivative in the direction of \(u\text{:}\) \(f(x,y,z)=\text{ln}({x}^{2}+2{y}^{2}+3{z}^{2}),\begin{array}{ll}P(2,1,4), & u=\frac{-3}{13}i-\frac{4}{13}j-\frac{12}{13}k\end{array}.\)
\(f(x,y,z)=4{x}^{5}{y}^{2}{z}^{3},\begin{array}{ll}P(2,-1,1), & u=\frac{1}{3}i+\frac{2}{3}j-\frac{2}{3}k\end{array}\)
\(-320\)
For the following exercises, find the directional derivative of the function at point \(P\) in the direction of \(Q.\)
\(f(x,y)={x}^{2}+3{y}^{2},\begin{array}{ll}P(1,1), & Q(4,5)\end{array}\)
\(f(x,y,z)=\frac{y}{x+z},\begin{array}{ll}P(2,1,-1), & Q(-1,2,0)\end{array}\)
\(\frac{3}{\sqrt{11}}\)
For the following exercises, find the derivative of the function at \(P\) in the direction of \(u.\)
\(f(x,y)=-7x+2y,\begin{array}{ll}P(2,-4), & u=4i-3j\end{array}\)
\(f(x,y)=\text{ln}(5x+4y),\begin{array}{ll}P(3,9), & u=6i+8j\end{array}\)
\(\frac{31}{255}\)
[T] Use technology to sketch the level curve of \(f(x,y)=4x-2y+3\) that passes through \(P(1,2)\) and draw the gradient vector at \(P.\)
[T] Use technology to sketch the level curve of \(f(x,y)={x}^{2}+4{y}^{2}\) that passes through \(P(-2,0)\) and draw the gradient vector at \(P.\)
For the following exercises, find the gradient vector at the indicated point.
\(f(x,y)=x{y}^{2}-y{x}^{2},P(-1,1)\)
\(f(x,y)=x{e}^{y}-\text{ln}(x),P(-3,0)\)
\(\frac{4}{3}i-3j\)
\(f(x,y,z)=xy-\text{ln}(z),P(2,-2,2)\)
\(f(x,y,z)=x\sqrt{{y}^{2}+{z}^{2}},P(-2,-1,-1)\)
\(\sqrt{2}i+\sqrt{2}j+\sqrt{2}k\)
For the following exercises, find the derivative of the function.
\(f(x,y)={x}^{2}+xy+{y}^{2}\) at point \((-5,-4)\) in the direction the function increases most rapidly
\(f(x,y)={e}^{xy}\) at point \((6,7)\) in the direction the function increases most rapidly
\(1.6({10}^{19})\)
\(f(x,y)=\text{arctan}(\frac{y}{x})\) at point \((-9,9)\) in the direction the function increases most rapidly
\(f(x,y,z)=\text{ln}(xy+yz+zx)\) at point \((-9,-18,-27)\) in the direction the function increases most rapidly
\(\frac{5\sqrt{2}}{99}\)
\(f(x,y,z)=\frac{x}{y}+\frac{y}{z}+\frac{z}{x}\) at point \((5,-5,5)\) in the direction the function increases most rapidly
For the following exercises, find the maximum rate of change of \(f\) at the given point and the direction in which it occurs.
\(f(x,y)=x{e}^{\text{-}y},\) \((1,0)\)
\(\sqrt{2},\langle 1,-1\rangle\)
\(f(x,y)=\sqrt{{x}^{2}+2y},\) \((4,10)\)
\(f(x,y)=\text{cos}(3x+2y),(\frac{\pi }{6},-\frac{\pi }{8})\)
\(\sqrt{\frac{13}{2}},\langle -3,-2\rangle\)
For the following exercises, find equations of
- the tangent plane and
- the normal line to the given surface at the given point.
The level surface \(f(x,y,z)=12\) for \(f(x,y,z)=4{x}^{2}-2{y}^{2}+{z}^{2}\) at point \((2,2,2).\)
\(f(x,y,z)=xy+yz+xz=3\) at point \((1,1,1)\)
a. \(x+y+z=3,\) b. \(x-1=y-1=z-1\)
\(f(x,y,z)=xyz=6\) at point \((1,2,3)\)
\(f(x,y,z)=x{e}^{y}\text{cos}\,z-z=1\) at point \((1,0,0)\)
a. \(x+y-z=1,\) b. \(x-1=y=\text{-}z\)
For the following exercises, solve the problem.
The temperature \(T\) in a metal sphere is inversely proportional to the distance from the center of the sphere (the origin: \((0,0,0)).\) The temperature at point \((1,2,2)\) is \(120\text{°}\text{C}.\)
- Find the rate of change of the temperature at point \((1,2,2)\) in the direction toward point \((2,1,3).\)
- Show that, at any point in the sphere, the direction of greatest increase in temperature is given by a vector that points toward the origin.
The electrical potential (voltage) in a certain region of space is given by the function \(V(x,y,z)=5{x}^{2}-3xy+xyz.\)
- Find the rate of change of the voltage at point \((3,4,5)\) in the direction of the vector \(\langle 1,1,-1\rangle .\)
- In which direction does the voltage change most rapidly at point \((3,4,5)?\)
- What is the maximum rate of change of the voltage at point \((3,4,5)?\)
a. \(\frac{32}{\sqrt{3}},\) b. \(\langle 38,6,12\rangle ,\) c. \(2\sqrt{406}\)
If the electric potential at a point \((x,y)\) in the xy-plane is \(V(x,y)={e}^{-2x}\text{cos}(2y),\) then the electric intensity vector at \((x,y)\) is \(E=\text{-}∇V(x,y).\)
- Find the electric intensity vector at \((\frac{\pi }{4},0).\)
- Show that, at each point in the plane, the electric potential decreases most rapidly in the direction of the vector \(E.\)
In two dimensions, the motion of an ideal fluid is governed by a velocity potential \(φ.\) The velocity components of the fluid \(u\) in the x-direction and \(v\) in the y-direction, are given by \(\langle u,v\rangle =∇φ.\) Find the velocity components associated with the velocity potential \(φ(x,y)=\text{sin}\,\pi x\,\text{sin}\,2\pi y.\)
\(\langle u,v\rangle =\langle \pi \,\text{cos}(\pi x)\text{sin}(2\pi y),2\pi \,\text{sin}(\pi x)\text{cos}(2\pi y)\rangle\)
Glossary
- directional derivative
- the derivative of a function in the direction of a given unit vector
- gradient
- the gradient of the function \(f(x,y)\) is defined to be \(∇f(x,y)=(∂f\text{/}∂x)i+(∂f\text{/}∂y)j,\) which can be generalized to a function of any number of independent variables