§ Gradients · Interactive Graduate Primer
Tensor by Tensor · expanded

Directional derivatives

Learn how changing several inputs changes one output. Begin with partial derivatives, then explore gradient descent, backpropagation, and optimizers. The later sections include proofs and deeper mathematical detail.
A first reading path

Start with sections 2–4, then section 7. Return to the directional-derivative proof after you understand a gradient-descent update. An optimizer is a rule for updating the model’s adjustable numbers.

For L(a, b) = a² + 2b², the gradient at (1, 2) is [2, 8]. The first entry measures change along a while b stays fixed. The second measures change along b while a stays fixed. With step size 0.1, subtract [0.2, 0.8] to reach (0.8, 1.2). The loss falls from 9 to 3.52.

Check: why subtract the gradient?

The gradient points toward the steepest local increase under the usual Euclidean length measure. Subtracting it moves toward a local decrease when the step is small enough. A large step can still overshoot and increase the loss.

5. Directional Derivatives

Introduction

The gradient 4, 3 predicts different rates for different unit directions. Moving along the first axis gives rate 4, while moving along the normalized gradient gives the largest rate, 5.

Learning goal

Calculate directional derivatives as vector projections and compare local rates for several chosen unit directions.

Before you start

Gradients, dot products, vector length, unit vectors, and basic trigonometry.

Lesson plan

  1. Represent a chosen two-dimensional movement direction correctly as a unit vector.
  2. Project the gradient onto that direction using a dot product.
  3. Explore how rotating the direction changes the rate and reveals the maximum.

Check a direction: with gradient [4,3] and unit direction [1,0], the directional derivative is 4. Moving only along the second axis gives 3. A mixed direction combines both through a dot product.

Definition

For a unit vector $u$, the directional derivative is $D_u f(x) = \lim_{h\to 0}[f(x+hu)-f(x)]/h$. If $f$ is differentiable, $D_u f(x) = \langle \nabla f(x),\,u\rangle$.

5.1 Direction explorer

Fix a point. Rotate the direction vector $u$ and watch the rate $D_u f = \|\nabla f\|\cos\theta$ vary sinusoidally with the angle $\theta$ between $u$ and $\nabla f$. The maximum rate is $\|\nabla f\|$, achieved when $u$ points along the gradient.

Interactive · Directional derivative $D_u f$ at a fixed point