§ Gradients · Interactive Graduate Primer
Tensor by Tensor · expanded

Gradient prerequisites

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.

2. Prerequisites Recap

Introduction

Near a smooth point, a complicated function behaves approximately like a flat tilted surface. A small move can therefore be paired with a slope vector through a dot product to predict the nearby change.

Learning goal

Use differentiability and inner products to understand and calculate the local linear approximation behind gradient methods.

Before you start

Functions, vectors, dot products, limits as an idea, and one-variable derivatives.

Lesson plan

  1. Interpret differentiability as a reliable linear prediction for sufficiently small moves.
  2. Review the inner product as a measure of aligned vector components.
  3. Combine a gradient and displacement to predict a function's local change.

Readiness check: for f(x)=x², can you calculate f(3)=9 and understand that a small change in x changes f(x)? The next sections define all multi-input notation from that starting point.

2.1 Differentiability

Definition

$f:\mathbb{R}^n\to\mathbb{R}$ is differentiable at $x$ iff there is a linear map $Df(x)$ such that $f(x+h) = f(x) + Df(x)\cdot h + o(\|h\|)$. The gradient $\nabla f(x)$ is the vector representing this map under the standard inner product: $Df(x)\cdot h = \langle \nabla f(x),\, h\rangle$.

2.2 Inner product

On $\mathbb{R}^n$, $\langle a,b\rangle = a^\top b$. Cauchy–Schwarz: $|\langle a,b\rangle|\le\|a\|\|b\|$, with equality iff $a$ and $b$ are parallel. This single inequality drives the steepest-ascent theorem in §6.