The Gradient and Directional Derivatives
Partial derivatives give the slope due east and due north. What about north-east? Or any other direction?
Collecting the partials into a vector answers all of them at once.
The gradient
Read "grad " or "del ". Input a point, output a vector.
For :
At the point :
Directional derivatives
The rate of change in the direction of a unit vector is
The vector must be a unit vector. If you are given a direction of arbitrary length, divide by its magnitude first. Skipping this is the single most common error in this topic, and it scales the answer wrongly.
For the direction , whose length is :
Sanity checks the partials give you free
Taking gives , and gives . The partial derivatives are just directional derivatives along the axes — a special case, not a separate idea.
Why the gradient points uphill
Write the dot product using the angle between and :
since . The only thing you control is , and is largest when .
| Direction | Rate of change | |
|---|---|---|
| Along | $+ | |
| Against | $- | |
| Perpendicular to | — along a level curve |
Three facts fall out of one line of algebra:
- points in the direction of steepest increase
- is that steepest rate
- is perpendicular to the level curve through the point
The third fact, from the previous topic
Moving along a level curve keeps constant, so the rate of change is zero. Zero rate means , so . The gradient is normal to the contour — which is why, on a map, the steepest way up a hill is at right angles to the contour lines.
Where it is used
Gradient descent, the workhorse of machine learning, is this fact turned into an algorithm: to minimise a function, repeatedly step in the direction . Module 4 makes it explicit.