Tutorials › Calculus III › Directional Derivatives from First Principles

Directional Derivatives and Gradients · Tutorial 381 of 999

Directional Derivatives from First Principles

Compute directional derivatives directly from difference quotients and determine when the gradient shortcut is not justified.

Intermediate 9 min read

What You'll Learn

  • Set up the signed difference quotient along a unit direction
  • Evaluate directional derivatives directly by substitution and simplification
  • Distinguish a two-sided directional derivative from a one-sided rate
  • Identify why partial derivatives alone do not justify the gradient formula
  • Check directional limits where differentiability fails

Why Start from the Limit?

A directional derivative measures how a function changes as its input moves along a specified line. When the function is differentiable, the gradient formula gives a convenient way to calculate that rate. But the formula has a condition: differentiability at the point. If that condition is not known, the direct method is to follow the line and evaluate the defining limit.

This distinction matters at points where a function is not differentiable. A directional derivative may still exist in a chosen direction, or the defining limit may fail to exist. The limit itself decides which case applies.

Definition: Let \(f\) be defined in a neighborhood of \(\mathbf{a}\in\mathbb{R}^n\), and let \(\mathbf{u}\) be a unit vector. The directional derivative of \(f\) at \(\mathbf{a}\) in direction \(\mathbf{u}\), when it exists, is the two-sided limit $$ D_{\mathbf{u}}f(\mathbf{a}) = \lim_{t\to 0} \frac{f(\mathbf{a}+t\mathbf{u})-f(\mathbf{a})}{t}. $$

The parameter \(t\) is signed: positive \(t\) moves along \(\mathbf{u}\), while negative \(t\) moves in the opposite direction. Thus this definition requires the same finite limit from both sides. The unit-vector condition makes the rate correspond to unit distance along the line. If the function is defined only on a restricted domain, the points \(\mathbf{a}+t\mathbf{u}\) must belong to that domain for the values of \(t\) used in the limit; at a boundary, a one-sided limit may be considered separately, but it is not the two-sided derivative defined here.

Follow the Line, Then Take the Limit

The main practical step is to substitute the line \(\mathbf{a}+t\mathbf{u}\) into the function. This turns the multivariable expression into a one-variable expression in \(t\). Subtract the value at the base point, divide by \(t\), simplify, and only then take the limit.

1
Check the direction.
Confirm that the specified vector is a unit vector, or normalize it if the problem asks for a rate per unit distance.
2
Parameterize the line.
Use \(\mathbf{a}+t\mathbf{u}\), keeping the signed parameter \(t\).
3
Form the quotient.
Compute \(\bigl(f(\mathbf{a}+t\mathbf{u})-f(\mathbf{a})\bigr)/t\).
4
Evaluate the two-sided limit.
Simplify the quotient first; conclude that the directional derivative exists only if the finite two-sided limit exists.

Worked Example: A Polynomial Along a Unit Direction

Let \(f(x,y)=x^2+xy\). Find the directional derivative at \((1,2)\) in the direction \(\mathbf{u}=(3/5,4/5)\), directly from the definition.

The direction is a unit vector because \(\sqrt{(3/5)^2+(4/5)^2}=\sqrt{9/25+16/25}=1\). The point on the line is \((1,2)+t(3/5,4/5)=(1+3t/5,2+4t/5)\). At the base point, \(f(1,2)=1^2+(1)(2)=3\).

$$ \begin{aligned} f(1+3t/5,2+4t/5) &=(1+3t/5)^2+(1+3t/5)(2+4t/5)\\ &=1+\frac{6t}{5}+\frac{9t^2}{25} +2+\frac{4t}{5}+\frac{6t}{5}+\frac{12t^2}{25}\\ &=3+\frac{16t}{5}+\frac{21t^2}{25}. \end{aligned} $$

Subtract the base value and divide by \(t\), for \(t\ne 0\): \(\bigl(3+16t/5+21t^2/25-3\bigr)/t=16/5+21t/25\). Therefore, \[ D_{\mathbf{u}}f(1,2) =\lim_{t\to0}\left(\frac{16}{5}+\frac{21t}{25}\right) =\frac{16}{5}. \]

Check the substitution numerically at \(t=1\): the point is \((8/5,14/5)\), and \(f(8/5,14/5)=64/25+112/25=176/25=7.04\). The expanded expression gives \(3+16/5+21/25=75/25+80/25+21/25=176/25\), agreeing with direct evaluation. The derivative is the limit of the quotient, not the value at \(t=1\).

When the Gradient Formula Is Justified

The gradient formula is a consequence of differentiability, not a replacement for checking it. For a function differentiable at \(\mathbf{a}\), its first-order approximation has a remainder that becomes negligible relative to the distance from \(\mathbf{a}\).

Theorem: If \(f:\mathbb{R}^n\to\mathbb{R}\) is differentiable at \(\mathbf{a}\), then for every unit vector \(\mathbf{u}\), $$ D_{\mathbf{u}}f(\mathbf{a})=\nabla f(\mathbf{a})\cdot\mathbf{u}. $$

Here differentiability means that \(f(\mathbf{a}+\mathbf{h})=f(\mathbf{a})+\nabla f(\mathbf{a})\cdot\mathbf{h}+r(\mathbf{h})\), where \(r(\mathbf{h})/\|\mathbf{h}\|\to0\) as \(\mathbf{h}\to\mathbf{0}\), with \(\mathbf{h}\ne\mathbf{0}\). To justify the theorem, put \(\mathbf{h}=t\mathbf{u}\). For \(t\ne0\), the difference quotient becomes \[ \frac{f(\mathbf{a}+t\mathbf{u})-f(\mathbf{a})}{t} =\nabla f(\mathbf{a})\cdot\mathbf{u}+\frac{r(t\mathbf{u})}{t}. \] Since \(\|\mathbf{u}\|=1\), the absolute value of the remainder term satisfies \[ \left|\frac{r(t\mathbf{u})}{t}\right| =\frac{|r(t\mathbf{u})|}{\|t\mathbf{u}\|} \longrightarrow 0. \] Thus the quotient has the stated limit. Without differentiability, this argument does not apply; computing the limit directly avoids assuming a condition that may fail.

A Directional Derivative Can Exist Without Differentiability

Worked Example: Direct Evaluation at a Point Where the Gradient Rule Fails

Define \(f(x,y)=x^2y/(x^2+y^2)\) when \((x,y)\ne(0,0)\), and set \(f(0,0)=0\). Find the directional derivative at the origin in direction \(\mathbf{u}=(1/\sqrt{2},1/\sqrt{2})\).

The vector is a unit vector because its squared length is \(1/2+1/2=1\). Along the line \(t\mathbf{u}\), the coordinates are \(x=t/\sqrt{2}\) and \(y=t/\sqrt{2}\). For \(t\ne0\), \[ x^2y=\frac{t^2}{2}\frac{t}{\sqrt{2}}=\frac{t^3}{2\sqrt{2}}, \qquad x^2+y^2=\frac{t^2}{2}+\frac{t^2}{2}=t^2. \] Consequently \(f(t\mathbf{u})=t/(2\sqrt{2})\), and \(f(0,0)=0\). The difference quotient is \[ \frac{f(t\mathbf{u})-f(0,0)}{t} =\frac{t/(2\sqrt{2})}{t} =\frac{1}{2\sqrt{2}}. \] It is constant for \(t\ne0\), so the two-sided limit exists and \(D_{\mathbf{u}}f(0,0)=1/(2\sqrt{2})\).

However, the partial derivatives at the origin are both zero: along either coordinate axis the function is zero. Those partial derivatives do not justify the gradient formula here. Indeed, along \(y=x=s\ne0\), \(f(s,s)=s/2\), while the distance to the origin is \(\sqrt{2}|s|\). Hence \[ \frac{|f(s,s)-f(0,0)|}{\sqrt{s^2+s^2}} =\frac{|s|/2}{\sqrt{2}|s|} =\frac{1}{2\sqrt{2}}, \] which does not tend to zero. The function is therefore not differentiable at the origin. The directional derivative found above is valid because it came from its own limit, not from an unjustified gradient calculation.

A Directional Derivative May Fail to Exist

Worked Example: A Two-Sided Limit That Does Not Exist

Let \(g(x,y)=\sqrt{x^2+y^2}\). Find whether the directional derivative at \((0,0)\) exists in the direction \(\mathbf{u}=(3/5,4/5)\).

The direction is unit length, and \(g(0,0)=0\). Along the line, \[ g(3t/5,4t/5) =\sqrt{\frac{9t^2}{25}+\frac{16t^2}{25}} =\sqrt{t^2} =|t|. \] Thus the difference quotient is \(|t|/t\) for \(t\ne0\). If \(t>0\), this quotient is \(1\); if \(t<0\), it is \(-1\). The one-sided limits differ, so the two-sided limit does not exist. Therefore \(D_{\mathbf{u}}g(0,0)\) does not exist under the definition used here.

If a problem explicitly asks for the rate only in the forward direction, it may instead define a one-sided limit with \(t\to0^+\). That limit is \(1\) in this example. It is not the same as the two-sided directional derivative, so the convention must be checked before reporting a value.

Common Pitfall: Losing a Term in the Expansion

In a direct-limit calculation, an algebra error in the line substitution changes the quotient and therefore changes the claimed derivative. For example, in the first worked example, an incorrect expansion might write \[ (1+3t/5)(2+4t/5)=2+2t+\frac{12t}{25}. \] This is wrong: the product of the two terms containing \(t\) is \((3t/5)(4t/5)=12t^2/25\), not \(12t/25\). The correct expansion is \[ (1+3t/5)(2+4t/5)=2+2t+\frac{12t^2}{25}. \] Including that quadratic term gives the correct total \(3+16t/5+21t^2/25\), and the quotient becomes \(16/5+21t/25\). Its limit is \(16/5\). A useful check is to substitute a convenient nonzero value of \(t\) into both the original function and the expanded expression, as done above.

How to Report the Result

A complete answer should make clear both the computation and its status. If the simplified quotient tends to a finite value from both sides, state that value as the directional derivative. If the one-sided limits disagree, say that the two-sided directional derivative does not exist; do not average the one-sided values or report just the forward rate without naming it.

The method is especially useful when differentiability has not been established. It also provides a check on any gradient-based calculation: when differentiability is known, the direct limit and the gradient formula must agree. When it is not known, the limit definition remains the criterion.

Check Your Understanding

For each question, use the signed parameter in the definition and distinguish existence of a two-sided limit from a one-sided rate.

  1. What does the parameter \(t\) represent in \(\mathbf{a}+t\mathbf{u}\), and why does its sign matter?
  2. For \(f(x,y)=x^2+xy\) at \((1,2)\), what is the difference quotient along \((3/5,4/5)\) after simplification?
  3. What condition justifies replacing the defining limit by \(\nabla f(\mathbf{a})\cdot\mathbf{u}\)?
  4. For \(g(x,y)=\sqrt{x^2+y^2}\) at the origin, why does the two-sided directional derivative fail even though the forward one-sided limit exists?
  5. In the rational-function example, why do zero partial derivatives at the origin not justify using the gradient formula?