From a Gradient to a Rate in a Specified Direction
A gradient records the partial derivatives of a scalar-valued function at a point. A directional derivative asks for a more specific piece of information: the instantaneous rate at which the function changes when we move from that point in a chosen direction.
For this tutorial, the calculation is based on a key result from the gradient formula: when \(f\) is differentiable at a point and \(\mathbf{u}\) is a unit vector, the directional derivative is the dot product of the gradient at that point with \(\mathbf{u}\). The practical work is to compute the gradient correctly, evaluate it at the specified point, and then take that dot product.
What the Formula Requires
For a function of two variables, \(f(x,y)\), the gradient is the vector of first partial derivatives. For a function of three variables, \(f(x,y,z)\), it contains the three first partial derivatives. In either case, the gradient must be defined at the point in question, and the function must be differentiable there for the formula to apply.
A direction for this formula is a unit vector: its length is \(1\). This matters because the derivative measures change per unit of distance in that direction. If a problem supplies a vector that is not a unit vector, first replace it with the unit vector pointing the same way by dividing by its length. A zero vector has no direction and cannot be normalized.
The dot product pairs corresponding components and adds the products. Thus, in two variables, \(\langle a,b\rangle\cdot\langle c,d\rangle=ac+bd\); in three variables, one more component product is included. The result is a scalar, not a vector.
A Reliable Evaluation Process
It is useful to keep the stages of the calculation separate. First differentiate the function to obtain the gradient as a function of its variables. Next substitute the specified point into every component. Only then take the dot product with the given unit direction.
Compute all required first partial derivatives and arrange them as a vector.
Substitute the coordinates of the specified point into every component of the gradient.
Confirm that the direction vector has length \(1\). Normalize it first if the problem gives a nonzero vector that is not a unit vector.
Multiply corresponding components and add. The resulting scalar is the directional derivative.
Why the Dot Product Gives the Rate
The formula follows from the chain rule applied to a straight-line path. Starting at \(\mathbf{a}\) and moving in the unit direction \(\mathbf{u}\), describe position by \(\mathbf{r}(t)=\mathbf{a}+t\mathbf{u}\). At \(t=0\), the position is \(\mathbf{a}\), and because \(\mathbf{u}\) is a unit vector, \(t\) measures distance along the line near that point.
Define the single-variable function \(g(t)=f(\mathbf{r}(t))\). The chain rule says that the rate of change of \(g\) at \(0\) is the gradient of \(f\) at \(\mathbf{a}\) dotted with the velocity \(\mathbf{r}'(0)\). Since \(\mathbf{r}'(t)=\mathbf{u}\), this gives the directional derivative formula. Differentiability of \(f\) at \(\mathbf{a}\) is the condition that justifies using the gradient and chain rule in this way.
This reasoning explains both the order of the calculation and the role of the unit-length condition. The gradient is taken at the starting point, while the direction vector specifies how position is changing.
Worked Examples
Worked Example: A Directional Derivative in Two Variables
Find the directional derivative of \(f(x,y)=x^2y+3y^2\) at \((1,-1)\) in the direction \(\mathbf{u}=\left\langle\frac35,\frac45\right\rangle\).
First compute both partial derivatives. Treating \(y\) as constant when differentiating with respect to \(x\), and \(x\) as constant when differentiating with respect to \(y\), gives
Therefore, the gradient is \(\nabla f(x,y)=\langle 2xy,x^2+6y\rangle\). Evaluate it at \((1,-1)\):
Check that the given direction is a unit vector:
Now take the dot product of the evaluated gradient and the direction:
The directional derivative is \(-26/5\). As a check on the dot-product arithmetic, the two component contributions are \(-6/5\) and \(-20/5\), whose sum is \(-26/5\). The negative result means that \(f\) is decreasing to first order when moving from \((1,-1)\) in the specified direction.
Worked Example: A Directional Derivative in Three Variables
Let \(f(x,y,z)=xy+yz^2+x^2z\). Find its directional derivative at \((1,2,-1)\) in the direction \(\mathbf{u}=\left\langle\frac23,-\frac13,\frac23\right\rangle\).
Differentiate with respect to each variable, holding the other two fixed:
Thus, \(\nabla f(x,y,z)=\langle y+2xz,x+z^2,2yz+x^2\rangle\). At \((1,2,-1)\), its components are
So \(\nabla f(1,2,-1)=\langle0,2,-3\rangle\). The direction has length
Use the dot product, showing each contribution:
The answer is \(-8/3\). Checking the component products gives \(0\), \(-2/3\), and \(-2\); their sum is indeed \(-8/3\). The negative sign indicates a decrease in the chosen direction at the specified point.
Worked Example: A Positive Rate and a Nonlinear Function
Find the directional derivative of \(f(x,y)=\ln(x^2+y^2)\) at \((1,1)\) in the direction \(\mathbf{u}=\left\langle\frac1{\sqrt5},\frac2{\sqrt5}\right\rangle\).
The function is defined when \(x^2+y^2>0\); in particular, it is defined and differentiable at \((1,1)\). By the chain rule for partial derivatives,
At \((1,1)\), the denominator in each component is \(1^2+1^2=2\), so
Verify that the direction is a unit vector:
Now evaluate the dot product:
The result is \(3/\sqrt5\), which is positive. As an arithmetic check, both gradient components are \(1\), so the dot product is the sum of the two direction components, \(1/\sqrt5+2/\sqrt5=3/\sqrt5\).
A Common Mistake: Using the Wrong Vector or Point
Two errors often occur in this calculation. One is taking the dot product with a vector before checking that it has unit length. The other is evaluating the gradient at the wrong point, or not evaluating it at all. For example, suppose the gradient at a point is \(\langle3,4\rangle\), and the direction is \(\langle1,1\rangle\). A tempting calculation is
That is not the directional derivative in the direction of \(\langle1,1\rangle\), because this vector has length \(\sqrt{1^2+1^2}=\sqrt2\), not \(1\). Normalize it:
Thus the value \(7\) uses a vector \(\sqrt2\) times as long as the unit direction and does not match the requested rate per unit distance. Normalize first, then take the dot product. Also keep the point visible in your work: \(\nabla f(\mathbf{a})\) is the gradient at the specified point, not the gradient at a different point or a vector of unevaluated partial-derivative formulas.
Interpreting the Result
The directional derivative is a signed scalar rate. A positive value means the function increases to first order in the chosen direction; a negative value means it decreases to first order; and zero means its first-order rate in that direction is zero. The number is local: it describes the rate at the specified point, not the total change over a finite journey.
Units can help check the interpretation. If \(f\) measures temperature in degrees and position is measured in metres, a directional derivative has units of degrees per metre. The direction vector itself is unitless: it specifies orientation, while the derivative gives change in the function per unit distance. A result with the wrong kind of units may indicate that the variables or their units have been confused.
For a correct evaluation, confirm these three items before reporting the answer: the gradient components are correct, the gradient is evaluated at the requested point, and the direction used in the dot product has length \(1\). Then check the component products and their sum. These checks are brief, but they catch most computational errors.
Check Your Understanding
For each question, show the gradient at the point and the dot product used to obtain the rate.
- For \(f(x,y)=x^2+y^2\), find the directional derivative at \((1,2)\) in the direction \(\left\langle\frac35,\frac45\right\rangle\).
- For \(f(x,y,z)=xy+z^2\), find the directional derivative at \((2,1,-1)\) in the direction \(\left\langle\frac1{\sqrt2},0,\frac1{\sqrt2}\right\rangle\).
- What condition must a direction vector satisfy in the gradient dot-product formula?
- If the directional derivative is negative, what does that say about the function's local change in the specified direction?
- A problem gives a nonzero direction vector of length \(5\). What must you do before using it in the formula for a rate per unit distance?