Learning Objectives
- Calculate directional derivatives and gradients in three dimensions.
The definition of a gradient can be extended to functions of more than two variables.
Definition
Let [latex]w=f(x, y ,z)[/latex] be a function of three variables such that [latex]f_x[/latex], [latex]f_y[/latex], and [latex]f_z[/latex] exist. The vector [latex]\nabla{f}(x,y,z)[/latex] is called the gradient of [latex]f[/latex] and is defined as
[latex]\nabla{f}(x,y,z)=f_x(x,y,z){\bf{i}}+f_y(x,y,z){\bf{j}}+f_z(x,y,z){\bf{k}}.[/latex]
[latex]\nabla{f}(x,y,z)[/latex] can also be written as [latex]\text{grad }f(x,y,z)[/latex].
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 [latex]f_x[/latex], [latex]f_y[/latex], and [latex]f_z[/latex], and then we use the Equation for [latex]\nabla{f}(x,y,z)[/latex].
Example: finding gradients in three dimensions
Find the gradient [latex]\nabla{f}(x,y,z)[/latex] of each of the following functions:
a. [latex]f(x,y,z)=5x^2-2xy+y^2-4yz+z^2+3xz[/latex]
b. [latex]f(x,y,z)=e^{-2z}\sin 2x\cos 2y[/latex]
Show Solution
For both parts a. and b., we first calculate the partial derivatives [latex]f_x[/latex], [latex]f_y[/latex], and [latex]f_z[/latex], then use the Equation for [latex]\nabla{f}(x,y,z)[/latex].
a.
[latex]\hspace{1cm}\begin{align} 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,} \\ \nabla{f}(x,y,z)&=f_x(x,y,z){\bf{i}}+f_y(x,y,z){\bf{j}}+f_z(x,y,z){\bf{k}} \\ &=(10x-2y+3z){\bf{i}}+(-2x+2y-4z){\bf{j}}+(-4x+3y+2z){\bf{k}} \end{align}[/latex]
b.
[latex]\hspace{1cm}\begin{align} f_x(x,y,z)&=-2e^{-2z}\cos2x\cos 2y,f_y(x,y,z)=-2e^{-2z}\sin 2x\sin2y\text{ and }f_z(x,y,z)=-2e^{-2z}\sin 2x\cos 2y\text{ so,} \\ \nabla{f}(x,y,z)&=f_x(x,y,z){\bf{i}}+f_y(x,y,z){\bf{j}}+f_z(x,y,z){\bf{k}} \\ &=(2e^{-2z}\cos2x\cos 2y){\bf{i}}+(-2e^{-2z}){\bf{j}}+(-2e^{-2z}){\bf{k}} \\ &=2e^{-2z}(\cos2x\cos 2y{\bf{i}}-\sin 2x\sin2y{\bf{j}}-\sin 2x\cos 2y{\bf{k}}). \end{align}[/latex]
Try it
Find the gradient [latex]\nabla{f}(x,y,z)[/latex] of [latex]f(x,y,z)=\frac{x^2-3y^2+z^2}{2x+y-4z}[/latex].
Show Solution
[latex]\nabla{f}(x,y,z)=\frac{2x^2+2xy+6y^2-8xz-2z^2}{(2x+y-4z)^2}{\bf{i}}-\frac{x^2+12xy+3y^2-24yz+z^2}{(2x+y-4z)^2}{\bf{j}}+\frac{4x^2-12y^2-4z^2+4xz+2yz}{(2x+y-4z)^2}{\bf{k}}[/latex]
Watch the following video to see the worked solution to the above Try It
You can view the transcript for “CP 4.32” here (opens in new window).>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 [latex]\bf{u}[/latex] in standard form (i.e., the initial point is at the origin), this vector forms three different angles with the positive [latex]x-,y-[/latex] and [latex]z-[/latex]axes. Let’s call these angles [latex]\alpha,\beta[/latex] and [latex]\gamma[/latex]. Then the directional cosines are given by [latex]\cos\alpha,\cos\beta[/latex] and [latex]\cos\gamma[/latex]. These are the components of the unit vector [latex]\bf{u}[/latex]; since [latex]\bf{u}[/latex] is a unit vector, it is true that [latex]\cos^2\alpha+\cos^2\beta+\cos^2\gamma=1[/latex].
Definition
Suppose [latex]w=f(x,y,z)[/latex] is a function of three variables with a domain of [latex]D[/latex], Let [latex](x_0,y_0,z_0)\in{D}[/latex] and let [latex]{\bf{u}}=cos\alpha{\bf{i}}+\cos\beta{\bf{j}}+\cos\gamma{\bf{k}}[/latex] be a unit vector. Then, the directional derivative of [latex]f[/latex] in the direction of [latex]u[/latex] is given by
[latex]D_{\bf{u}}f(x_0,y_0,z_0)=\displaystyle{\lim_{t\to0}}\frac{f(x_0+t\cos\alpha,y_0+t\cos\beta,z_0+t\cos\gamma)-f(x_0,y_0,z_0)}t,[/latex]
providing 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 the dot product definition of the Directional Derivative of a Function of Two Variables.
Theorem: Directional derivative of a function of three variables
Let [latex]f(x,y,z)[/latex] be a differentiable function of three variables and let [latex]{\bf{u}}=\cos\alpha{\bf{i}}+\cos\beta{\bf{j}}+\cos\gamma{\bf{k}}[/latex] be a unit vector. Then, the directional derivative of [latex]f[/latex] in the direction of [latex]{\bf{u}}[/latex] is given by
[latex]\hspace{6cm}\begin{align} D_{\bf{u}}f(x,y,z)&=\nabla{f}(x,y,z)\cdot{\bf{u}} \\ &=f_x(x,y,z)\cos\alpha+f_y(x,y,z)\cos\beta+f_z(x,y,z)\cos\gamma. \end{align}[/latex]
The three angles [latex]\alpha,\beta[/latex], and [latex]\gamma[/latex] determine the unit vector [latex]\bf{u}[/latex]. In practice, we can use an arbitrary (nonunit) vector, then divide by its magnitude to obtain a unit vector in the desired direction.
Example: finding a directional derivative in three dimensions
Calculate [latex]D_{\bf{u}}f(1,-2,3)[/latex] in the direction of [latex]v=-{\bf{i}}+2{\bf{j}}+2{\bf{k}}[/latex] for the function
[latex]f(x,y,z)=5x^2-2xy+y^2-4yz+z^2+3xz[/latex].
Show Solution
First, we find the magnitude of [latex]{\bf{v}}[/latex]:
[latex]\|{\bf{v}}\|=\sqrt{(-1)^2+(2)^2+(2)^2}=3[/latex]
Therefore [latex]\frac{{\bf{v}}}{\|{\bf{v}}\|}=\frac{-{\bf{i}}+2{\bf{j}}+2{\bf{k}}}3=-\frac13{\bf{i}}+\frac23{\bf{j}}+\frac23{\bf{k}}[/latex] is a unit vector in the direction of [latex]{\bf{v}}[/latex], so [latex]\cos\alpha=-\frac13[/latex], [latex]\cos\beta=\frac23[/latex], and [latex]\cos\gamma=\frac23[/latex]. Next, we calculate the partial derivatives of [latex]f[/latex]:
[latex]\hspace{7cm}\begin{align} 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{align}[/latex]
Then substitute them into the Directional Derivative of a Function of Three Variables:
[latex]\hspace{5cm}\begin{align} D_{\bf{u}}f(x,y,z)&=10x-2y+3z \\ f_y(x,y,z)&=f_x(x,y,z)\cos\alpha+f_y(x,y,z)\cos\beta+f_z(x,y,z)\cos\gamma \\ &=(10x-2y+3z)(-\frac13)+(-2x+2y-4z)(\frac23)+(-4y+2z+3x)(\frac23) \\ &=-\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{align}[/latex]
Last, to find [latex]D_{\bf{u}}f(1,-2,3)[/latex], we substitute [latex]x=1[/latex], [latex]y=-2[/latex], and [latex]z=3[/latex]:
[latex]\hspace{5cm}\begin{align} D_{\bf{u}}f(1,-2,3)&=-\frac{8(1)}3-\frac{2(-2)}3-\frac{7(3)}3 \\ &=-\frac83+\frac43-\frac{21}3 \\ &=-\frac{25}3. \end{align}[/latex]
Try it
Calculate [latex]D_{\bf{u}}f(x,y,z)[/latex] and [latex]D_{\bf{u}}f(0,-2,5)[/latex] in the direction of [latex]{\bf{v}}=-3{\bf{i}}+12{\bf{j}}-4{\bf{k}}[/latex] for the function [latex]f(x,y,z)=3x^2+xy-2y^2+4yz-z^2+2xz[/latex].
Show Solution
[latex]\hspace{5cm}\begin{align} D_{\bf{u}}f(x,y,z)&=-\frac{3}{13}(6x+y+2z)-\frac{12}{13}(x-4y+4z)-\frac{4}{13}(2x+4y-2z) \\ D_{\bf{u}}f(0,-2,5)&=\frac{384}{13} \end{align}[/latex]
Watch the following video to see the worked solution to the above Try It
You can view the transcript for “CP 4.33” here (opens in new window).