skipnothing/Math for Machine Learning

Gradients & Directional Derivatives

Last topic you measured a hill's steepness one axis at a time, north then east, landing two numbers like `(+8, -3)`, yet neither points the steepest way to walk. Stack them into one arrow and it aims straight uphill.

  • Measure a hilltop north and east and you hold two slopes; the steepest way out is usually neither.
  • Those two slopes, stacked into one arrow, aim exactly uphill and their combined length is how fast you climb.
  • Flip that arrow and you have the one move every model repeats to walk its error downhill.
BUILDS ON
01

The single steepest direction

You left the last topic able to stand on two-input terrain and ask its steepness along one axis at a time: how hard it climbs if you walk due north, then, separately, due east. At one spot that might read +8 going north and -3 going east, the ground rises to the north and falls away to the east. Fine. But nobody walks only north or only east. Point yourself northeast, or north-by-northwest, and the ground has a steepness that way too, and it is not either of the two numbers you measured.

So a real question hangs over that spot: of all the directions you could step, which one climbs the hardest? Sweep a heading slowly around the full circle and read the rise-per-step at each angle. The reading is not flat and it is not random: it swells to a single maximum at one heading, sinks to its most negative exactly opposite, and passes through zero twice on the way.

There is one steepest direction, and at this spot it is a diagonal, tilted toward north because north climbs and away from east because east drops. The two axis measurements are just two samples of a smooth fan of steepnesses, and the winner sits between them. Finding that winning heading, and reading how steep it is, is the whole of this topic.

SWEEP A HEADING, FIND THE STEEPEST ONE

Keep going, sign up to unlock the rest

3 more parts in this topic, plus 19+ more topics in Math for Machine Learning.

Sign up, it's freeSee the full Math for Machine Learning
Calculus for ML0/6#8 The Chain Rule
#10 Integrals (Basics)