Foundations

Derivatives and gradients, geometrically

Derivatives measure local sensitivity; gradients collect those sensitivities into the direction of steepest increase.

Updated

1

Concept

A derivative measures local sensitivity. For a one-variable function f(x)f(x), the derivative at xx is the slope approached by increasingly small secant lines:

f(x)=limh0f(x+h)f(x)h.f'(x)=\lim_{h\to0}\frac{f(x+h)-f(x)}{h}.

If f(x)=3f'(x)=3, a sufficiently small positive change Δx\Delta x produces an output change of roughly 3Δx3\Delta x. This is a local linear approximation, not a promise about large moves or distant regions.

Geometrically, the derivative is the slope of the tangent line. A positive value rises as xx increases; a negative value falls; zero means locally flat, though not necessarily a minimum. The point might be a maximum, a minimum, or a flat inflection. Derivatives describe nearby behavior. They do not automatically reveal the best point over an entire function.

Neural networks depend on many parameters, so their loss is a function L(θ1,,θn)L(\theta_1,\ldots,\theta_n). A partial derivative L/θi\partial L/\partial\theta_i asks how loss changes when parameter ii moves slightly while the others are held fixed. Collecting all partial derivatives gives the gradient:

L=(Lθ1,,Lθn).\nabla L=\left(\frac{\partial L}{\partial\theta_1},\ldots,\frac{\partial L}{\partial\theta_n}\right).

The gradient points in the direction of steepest local increase under Euclidean distance. Its negative points toward steepest local decrease. Gradient descent uses the update θθηL\theta\leftarrow\theta-\eta\nabla L, where the learning rate η\eta sets the step size. Too small can make progress slow; too large can overshoot a valley or become unstable. Curvature means the useful step can vary by direction and over time.

The chain rule connects local sensitivities through a composition. If y=f(u)y=f(u) and u=g(x)u=g(x), then dy/dx=(dy/du)(du/dx)dy/dx=(dy/du)(du/dx). A neural network is a long composition of matrix multiplications, activations, normalization, and loss computation. Backpropagation applies the chain rule efficiently, reusing intermediate derivatives instead of separately expanding every path from every parameter to the loss.

Gradients have units and scale. Multiplying the loss by one thousand multiplies its gradient by one thousand without changing which parameters represent a solution. Features with very different scales can make the surface poorly conditioned: one direction may be steep while another is shallow. Normalization, initialization, adaptive optimizers, and learning-rate schedules all help manage the geometry, but none changes the basic meaning of the derivative.

Not every operation is differentiable everywhere. ReLU has a corner at zero; software chooses a conventional subgradient there. Token selection is discrete, so training differentiates through probabilities and continuous representations rather than through a sampled word choice. Numerical finite differences can check a small implementation by perturbing a parameter, but analytic automatic differentiation is far cheaper for millions or billions of parameters.

The crucial mental model is a local map. Loss is terrain over parameter space. A partial derivative is a slope along one coordinate; the gradient is the combined uphill arrow; the negative gradient suggests a downhill move. Optimization is difficult not because the definition is mysterious, but because the terrain is enormous, noisy, curved, and observed through batches. Geometry explains both why gradient methods work and why one local arrow cannot guarantee the global destination.

2

Explain it like I am five

Stand on a foggy hillside with a device that measures slope under each foot. A derivative reports the uphill tilt along one chosen path. The gradient combines every coordinate’s tilt into an arrow pointing toward the steepest local ascent. To descend, step against that arrow. The instrument only describes the ground near your boots, so a large leap may land beyond the patch its reading accurately described.

3

Teach it back

Explain the derivative, partial derivative, gradient, and learning-rate step using a loss surface, including the word local.

Minimum: 80 characters and 15 words. Your text stays only in this browser.

Saved only on this device.

Show a model answer

A derivative measures how one output changes under a tiny change in one input. For a loss with many parameters, each partial derivative varies one parameter while holding the others fixed. The gradient collects all partials and points toward steepest local increase. Gradient descent updates parameters in the opposite direction, scaled by a learning rate. Because the gradient is local, an excessively large step can overshoot or increase loss.

4

Check your understanding

1. What does the gradient of a scalar function point toward?
Answer and explanation

Steepest local increase — The negative gradient is therefore the steepest local descent direction under the usual Euclidean geometry.

2. What does the chain rule enable in a neural network?
Answer and explanation

Combining local derivatives through composed operations — A network is a composition; the chain rule propagates sensitivity through that composition.

Complete the teach-back and answer the quiz correctly to finish this lesson.

Sources

  1. Ian Goodfellow, Yoshua Bengio, and Aaron Courville (2016). Deep Learning.