Mathwords logoMathwords

Directional Derivative — Definition, Formula & Examples

The directional derivative measures the rate at which a function changes as you move from a point in a specific direction. It generalizes partial derivatives, which only measure change along the coordinate axes.

Given a differentiable function f:RnRf : \mathbb{R}^n \to \mathbb{R}, the directional derivative of ff at a point a\mathbf{a} in the direction of a unit vector u\mathbf{u} is defined as Duf(a)=limh0f(a+hu)f(a)hD_{\mathbf{u}}f(\mathbf{a}) = \lim_{h \to 0} \frac{f(\mathbf{a} + h\mathbf{u}) - f(\mathbf{a})}{h}. When ff is differentiable, this equals f(a)u\nabla f(\mathbf{a}) \cdot \mathbf{u}.

Key Formula

Duf=fu=fxu1+fyu2D_{\mathbf{u}}f = \nabla f \cdot \mathbf{u} = f_x u_1 + f_y u_2
Where:
  • DufD_{\mathbf{u}}f = Directional derivative of f in the direction of u
  • f\nabla f = Gradient vector of f (vector of all partial derivatives)
  • u\mathbf{u} = Unit vector specifying the direction
  • fx,fyf_x, f_y = Partial derivatives of f with respect to x and y
  • u1,u2u_1, u_2 = Components of the unit vector u

How It Works

To compute a directional derivative, you first find the gradient f\nabla f at the point of interest. Then you ensure the direction vector is a unit vector (divide by its magnitude if needed). Finally, take the dot product of the gradient with the unit vector. The result is a scalar telling you how fast ff increases in that direction. A positive value means ff is increasing; negative means decreasing. The maximum directional derivative occurs in the direction of the gradient itself.

Worked Example

Problem: Find the directional derivative of f(x,y)=x2+3xyf(x, y) = x^2 + 3xy at the point (1,2)(1, 2) in the direction of the vector 3,4\langle 3, 4 \rangle.
Find the gradient: Compute the partial derivatives and form the gradient vector.
f=2x+3y,  3xf(1,2)=2(1)+3(2),  3(1)=8,3\nabla f = \langle 2x + 3y,\; 3x \rangle \quad \Rightarrow \quad \nabla f(1,2) = \langle 2(1)+3(2),\; 3(1) \rangle = \langle 8, 3 \rangle
Normalize the direction vector: Divide the given vector by its magnitude to get a unit vector.
u=3,432+42=3,45=35,45\mathbf{u} = \frac{\langle 3, 4 \rangle}{\sqrt{3^2 + 4^2}} = \frac{\langle 3, 4 \rangle}{5} = \left\langle \frac{3}{5}, \frac{4}{5} \right\rangle
Compute the dot product: Take the dot product of the gradient with the unit vector.
Duf=8,335,45=245+125=365D_{\mathbf{u}}f = \langle 8, 3 \rangle \cdot \left\langle \frac{3}{5}, \frac{4}{5} \right\rangle = \frac{24}{5} + \frac{12}{5} = \frac{36}{5}
Answer: The directional derivative is 365=7.2\dfrac{36}{5} = 7.2. The function increases at a rate of 7.2 units per unit distance in the direction of 3,4\langle 3, 4 \rangle.

Why It Matters

Directional derivatives appear whenever you need the rate of change along a path that is not aligned with the coordinate axes. In physics, they describe how temperature or pressure changes along an arbitrary direction in a field. In machine learning, they underpin gradient descent, where you choose the direction of steepest descent to minimize a loss function.

Common Mistakes

Mistake: Using a direction vector that is not a unit vector in the dot product formula.
Correction: Always normalize the direction vector first by dividing it by its magnitude. If you skip this step, you scale the derivative by the length of the vector and get an incorrect rate of change.