Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.The uphill arrow
At every spot on a hill, imagine an arrow pointing in the direction where the ground rises fastest. Its length shows how steep that is. That arrow is the gradient.
Two facts make it special:
- A ball let go on the hill rolls the opposite way, straight downhill.
- The arrow always crosses the contour lines at a right angle. Walking along a contour keeps your height the same, so the uphill direction must be perpendicular to it.
Training an AI model means walking downhill on a “mistake landscape” with millions of directions, by stepping against the gradient again and again. Some robots navigate the same way: they roll downhill on an invisible landscape that’s low at the goal and high around obstacles.
- 1. A ball on a hill rolls…
- 2. Gradient arrows cross contour lines at…
- 3. A longer gradient arrow means the ground is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.Definition
Examples.
- points straight away from the origin. At , it is , with length 10.
- is the same arrow everywhere, because the function is a tilted plane.
- At a minimum, maximum or saddle, .
Three facts (proved at Level 3):
- points in the direction of steepest ascent.
- is that steepest rate.
- is perpendicular to the level set through the point.
- 1. ∇(x² + y²) at (1, 2)?
- 2. |∇(x² + y²)| at (3, 4)?
- 3. ∇f at a minimum is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.Tangent lines and normals from the gradient
Because is normal to the level set, the tangent line (or tangent plane, in 3-D) of at is
For the circle at : , which is , with slope . The unit normal is . This is how renderers shade implicit surfaces, and how robots get contact normals from signed distance fields.
Gradient descent
For an -smooth (curvature at most ), any step decreases near a minimum, and is safe everywhere (the descent lemma, A3.1-4). With uneven curvature (a long, narrow valley, large), the gradient points mostly across the valley, so the iterates zig-zag. That is why conditioning matters (A2.3-8).
- 1. The slope of the tangent to x² + y² = 25 at (3, 4)?
- 2. One gradient step on x² + y² from (1, 1) with η = 0.25 gives x = ?
- 3. The largest stable η for x² + 10y²?
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.Proofs of the three facts
Steepest ascent and its rate. For unit , by Cauchy–Schwarz, with equality iff . ∎
Orthogonality to level sets. Let be any curve inside . Then for all . The chain rule (A3.2-4) gives . So the gradient is perpendicular to every tangent direction of the level set. ∎
Gradient flow decreases f. Along : , with equality only at critical points. ∎ Gradient descent is the Euler discretization of this flow (Practice Code 4).
“Steepest” depends on how you measure distance
The gradient is the steepest direction for the Euclidean length of a step. If step length is measured by , the steepest direction becomes . Choosing gives Newton’s method. Choosing the Fisher information gives the natural gradient (Amari, 1998). Preconditioners like Adam use cheap diagonal approximations. Practice Code 5 shows one preconditioned step solving a valley that takes plain descent 882 steps.
Exercise 3.1: Show that gradient descent with optimal fixed step on ½xᵀAx contracts by (κ−1)/(κ+1)
In the eigenbasis, each coordinate is multiplied by . The best balances the extremes, giving .
- 1. Along the gradient flow with ‖∇f‖ = 3, df/dt = ?
- 2. The orthogonality proof uses…
- 3. With metric M, steepest descent moves along…
Level 4: Expert
★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.Potential fields: robots that roll downhill
Khatib (1986) proposed letting a robot follow , where . Here pulls toward the goal, and grows near obstacles. It is fast and reactive, and still used for local collision avoidance on manipulators and drones. Its known flaw is spurious local minima where away from the goal (Koditschek and Rimon’s navigation functions fix this for some environments).
The gradient in modern research
- Deep learning is gradient descent at scale. Stochastic gradients (Robbins and Monro, 1951), momentum (Polyak, 1964), and adaptive preconditioning (Adam; Kingma and Ba, 2015) are all ways of choosing a better step from .
- Convergence theory. For -strongly convex, -smooth , gradient descent with converges linearly at rate . For non-convex , it finds in steps (Nesterov, 2004).
- Trajectory optimization. CHOMP and TrajOpt move whole robot trajectories along functional gradients of smoothness-plus-obstacle costs (Ratliff et al., 2009). Diffusion policies denoise actions using learned gradients of log-densities, called score functions (Chi et al., 2023).
- Adversarial examples. The fast gradient sign method perturbs an input by (Goodfellow, Shlens and Szegedy, 2015). The gradient with respect to the input reveals a model’s most sensitive direction.
References
- A.-L. Cauchy (1847). “Méthode générale pour la résolution des systèmes d’équations simultanées.” Comptes rendus, 25. (Gradient descent.)
- O. Khatib (1986). “Real-time obstacle avoidance for manipulators and mobile robots.” IJRR, 5(1).
- D. Koditschek, E. Rimon (1990). “Robot navigation functions on manifolds with boundary.” Advances in Applied Mathematics, 11(4).
- S. Amari (1998). “Natural gradient works efficiently in learning.” Neural Computation, 10(2).
- Y. Nesterov (2004). Introductory Lectures on Convex Optimization. Springer.
- D. Kingma, J. Ba (2015). “Adam: A method for stochastic optimization.” ICLR.
- I. Goodfellow, J. Shlens, C. Szegedy (2015). “Explaining and harnessing adversarial examples.” ICLR.
- C. Chi, S. Feng, Y. Du, Z. Xu, E. Cousineau, B. Burchfiel, S. Song (2023). “Diffusion policy: Visuomotor policy learning via action diffusion.” RSS.