# The Gradient of Functions of Several Variables

Recall from the Directional Derivatives page that if $z = f(x, y)$, then the directional derivative of $f$ at $(x, y) \in D(f)$ in the direction of the unit vector $\vec{u} = (a, b)$ is given by the following formula:

(1)For a three variable function $w = f(x, y, z)$, then the directional derivative of $f$ at $(x, y, z) \in D(f)$ in the direction of the unit vector $\vec{u} = (a, b, c)$ is given by the following formula:

(2)Thus, this directional derivative can be obtained by the vector dot product between the vector whose components are the partial derivatives of $f$ and the unit vector $\vec{u}$.

Definition: Let $z = f(x, y)$ be a two variable real-valued function. Then Gradient of $f$ denoted $\nabla f (x, y)$ of $\mathbf{grad}\: f (x, y)$ is $\nabla f (x, y) = \left ( f_x (x, y) , f_y (x, y) \right ) = f_x (x, y) \vec{i} + f_y (x, y) \vec{j}$, a vector-valued function whose components are the partial derivatives of $f$. If $w = f(x, y, z)$ then $\nabla f(x, y, z) = \left ( f_x (x, y, z), f_y (x, y, z), f_z (x, y, z) \right )$. |

*Of course the gradient can be written as $\nabla f (x, y) = \frac{\partial z}{\partial x} \vec{i} + \frac{\partial z}{\partial y} \vec{j}$ for a two variable real-valued function $z = f(x, y)$, and $\nabla f(x, y, z) = \frac{\partial w}{\partial x} \vec{i} + \frac{\partial w}{\partial y} \vec{j} + \frac{\partial w}{\partial z} \vec{k}$ for a three variable real-valued function $w = f(x, y, z)$.*

We can now reformulate the definition of a directional derivative in terms of the gradient vector:

(3)## Example 1

**Let $z = f(x, y) = 2x^2 e^x \sin y + 2y$. Find $\nabla f (x, y)$.**

We note that $\frac{\partial z }{\partial x} = (4xe^x + 2x^2e^x)\sin y$, and $\frac{\partial z}{\partial y} = 2x^2 e^x \cos y + 2$. Therefore we have that:

(5)## Example 2

**Let $w = f(x, y, z) = \cos x \cos y \cos z + xyz$. Find $\nabla f(x, y, z)$.**

We note that $\frac{\partial w}{\partial x} = -\sin x \cos y \cos z + yz$, $\frac{\partial w}{\partial y} = -\cos x \sin y \cos z + xz$, and $\frac{\partial w}{\partial z} = -\cos x \cos y \sin z + xy$. Therefore we have that:

(6)