Here is the payoff. Linear algebra gives AI its vocabulary — vectors, matrices, transformations. Calculus gives it the ability to learn. At the heart of almost every modern machine-learning system is one computational pattern: compute a scalar loss by composing many simple functions (the forward pass), take its gradient with respect to billions of parameters (the backward pass), and nudge the parameters downhill (gradient descent). The composing, the differentiating, and the nudging are the three subjects of this book, executed at industrial scale. This chapter assembles them.

Learning is minimizing a function

A model \(f_{\vtheta}\) has parameters \(\vtheta\); a loss \(L(\vtheta)\) measures how badly it fits the data. Training solves \[\vtheta^\star = \argmin_{\vtheta} L(\vtheta).\] Because \(L\) is a scalar function of many variables, this is precisely the multivariable optimization of Chapter [ch:optimization]: find where the gradient vanishes, approached iteratively by gradient descent. Every concept below serves this single goal.

The gradient is the learning signal

The gradient \(\grad_{\vtheta}L\) assembles the loss’s sensitivity to each parameter (Chapter [ch:multivariable]). It points uphill, so the update \[\vtheta \leftarrow \vtheta - \eta\,\grad_{\vtheta}L\] moves the model in the direction that decreases the loss fastest. This is the most important equation in machine learning, and it is just the derivative of Chapter [ch:derivative] applied in millions of dimensions.

Backpropagation is the chain rule in reverse

A deep network is a composition \(L = \ell\circ f_L\circ\cdots\circ f_1\). The multivariable chain rule (Chapter [ch:rules][ch:multivariable]) says its gradient is a product of per-layer Jacobians: \[\pd{L}{\vtheta} = \pd{L}{\vh_L}\,\pd{\vh_L}{\vh_{L-1}}\cdots\pd{\vh_1}{\vtheta}.\]

Backpropagation is the chain rule traversed in reverse on a computational graph. Because the loss is a single scalar, the leftmost factor is a row vector; multiplying by Jacobians from the left keeps a vector flowing backward, so we never build the enormous full Jacobians — each step is a vector–Jacobian product (VJP). This reverse-mode automatic differentiation computes the gradient with respect to all parameters in roughly the cost of one forward pass, which is exactly why it — and not forward mode — powers deep learning.

Forward-mode AD propagates derivatives input-to-output and is efficient when there are few inputs; reverse-mode propagates output-to-input and is efficient when there is one output (the loss) and many inputs (the parameters). Deep learning is the extreme “many parameters, one scalar loss” regime, so reverse mode wins overwhelmingly. Frameworks build the graph on the forward pass and replay it backward when you call .

Gradients you will derive again and again

A handful of gradients recur across models (consistent with Chapter [ch:multivariable] and the matrix-calculus appendix of the companion volume): \[\grad_{\vx}(\va^\top\vx)=\va,\qquad \grad_{\vx}(\vx^\top \mathbf{A}\vx)=(\mathbf{A}+\mathbf{A}^\top)\vx,\qquad \grad_{\vx}\norm{\vx}_2^2=2\vx.\] Two deserve special attention because nearly every model ends with them.

For \(L=\tfrac12\norm{\mathbf{X}\vtheta-\vy}_2^2\) (linear regression), the chain rule gives \(\grad_{\vtheta}L=\mathbf{X}^\top(\mathbf{X}\vtheta-\vy)\). Setting it to zero recovers the normal equations — calculus and linear algebra agreeing exactly.

The canonical classification head composes the softmax \(p_i=\dfrac{e^{z_i}}{\sum_j e^{z_j}}\) with cross-entropy loss \(L=-\sum_i y_i\ln p_i\). Despite the intimidating composition, the gradient with respect to the logits collapses to the beautifully simple \[\pd{L}{z_i} = p_i - y_i.\] “Predicted minus true.” This clean form — a small calculus miracle — is why softmax + cross-entropy is the default classifier loss: the backward pass is trivial and numerically stable.

Curvature: Hessians, Newton, and why deep nets are hard

The second-order Taylor model (Chapters [ch:series][ch:multivariable]) \(L(\vtheta+\Delta)\approx L+\grad L^\top\Delta+\tfrac12\Delta^\top\mathbf{H}\Delta\) explains optimization behavior. The Hessian’s eigenvalues are curvatures; their ratio (condition number) sets gradient descent’s zig-zag and the stable learning rate. Newton’s method steps \(\Delta=-\mathbf{H}^{-1}\grad L\) and converges in few iterations on well-behaved problems — but \(\mathbf{H}\) is \(n\times n\) for \(n\) in the billions, impossible to form or invert, so deep learning uses first-order methods plus curvature approximations (L-BFGS, K-FAC, Adam’s diagonal preconditioning).

In high dimensions, saddle points — where the Hessian has both positive and negative eigenvalues — vastly outnumber poor local minima. This reframed the old fear of “getting stuck in local minima”: the real obstacle is plateaus and saddles, which momentum and adaptive methods are designed to escape. Curvature analysis (the Hessian spectrum) is also why normalization and good initialization help: they improve conditioning so gradients descend efficiently.

Optimizers: smarter ways down the slope

Plain gradient descent is rarely used as-is. The standard variants are all calculus-motivated refinements:

  • Stochastic gradient descent (SGD): estimate \(\grad L\) on a mini-batch — a Monte Carlo estimate (Chapter [ch:appint]) of the full-data gradient. Convergence needs \(\sum\eta_t=\infty,\ \sum\eta_t^2<\infty\) (Chapter [ch:series]).

  • Momentum: accumulate an exponentially weighted average of past gradients to power through ravines and damp zig-zag.

  • Adam/RMSProp: scale each coordinate by a running estimate of its gradient magnitude — a cheap per-parameter curvature proxy.

The integral side: probability, entropy, and generative models

Calculus’s integral half runs the probabilistic part of AI (Chapters [ch:appint][ch:multiple]).

  • Losses as expectations. Risk is \(\E[\text{loss}]=\int \text{loss}\cdot p\,\dd x\), estimated by averaging over data — mini-batch training is Monte Carlo integration.

  • Cross-entropy and KL. Classification minimizes cross-entropy; variational methods minimize \(\KL(q\,\|\,p)\) — integrals of densities against logs.

  • The ELBO and the reparameterization trick. VAEs maximize the evidence lower bound \(\E_{q}[\ln p(x\mid z)]-\KL(q(z\mid x)\,\|\,p(z))\). To differentiate through the sampling of \(z\), write \(z=\mu+\sigma\,\epsilon\) with \(\epsilon\sim\mathcal N(0,I)\) (the reparameterization trick), moving the randomness off the path of differentiation so gradients flow.

  • Continuous-time models. Neural ODEs define \(\dydx{\vh}{t}=f_{\vtheta}(\vh,t)\) and integrate with an ODE solver; diffusion models are described by stochastic differential equations whose reverse-time dynamics involve the score \(\grad_{\vx}\log p\), and whose log-likelihood uses a divergence term (Chapter [ch:multiple]). Training again reduces to gradients of an integral objective.

The grand summary table

Calculus concept Ch. Where it powers AI
Limits & continuity [ch:limits] well-posed losses; saturation; numerical gradient checks
Derivative (rate of change) [ch:derivative] sensitivity of loss to a parameter
Chain rule [ch:rules] backpropagation; vanishing/exploding gradients
Activation derivatives [ch:rules] \(\sigma'=\sigma(1-\sigma)\), \(\tanh'\), ReLU\('\) in every backward pass
Optimization / critical points [ch:appderiv] training objective \(\grad L=\vzero\); Newton’s method
Taylor expansion [ch:series] linearization; 2nd-order optimization; Laplace approx.
Series convergence [ch:series] SGD step-size conditions; RL discounted returns
Integral & expectation [ch:integral],[ch:appint] risk as \(\E[\text{loss}]\); densities; Monte Carlo
Entropy / cross-entropy / KL [ch:appint] classification loss; variational objectives
Multiple integrals / Jacobian det [ch:multiple] joint densities; normalizing flows; evidence
Gradient [ch:multivariable] gradient descent: \(\vtheta\!\leftarrow\!\vtheta-\eta\grad L\)
Jacobian / VJP [ch:multivariable] reverse-mode autodiff (backprop)
Hessian / curvature [ch:multivariable] saddles, conditioning, Adam, L-BFGS, K-FAC
Lagrange multipliers [ch:optimization] SVMs, constraints, max-entropy \(\Rightarrow\) softmax
Differential equations [ch:optimization] neural ODEs; diffusion samplers; Euler \(\approx\) GD

Modern AI learns by differentiating. A model composes simple functions into a scalar loss; reverse-mode automatic differentiation — the chain rule on a graph — computes the gradient of that loss with respect to every parameter; an optimizer nudges the parameters downhill; and integrals (expectations, entropies, ELBOs) define the probabilistic objectives being optimized. Derivatives say which way to move, integrals say what to optimize, and the Fundamental Theorem ties the continuous-time generative models together. Master the concepts in the table and the training loop of any model — from logistic regression to a diffusion transformer — becomes a single, legible idea: calculus at scale.

Where to go next

Pair this with the companion Linear Algebra volume (vectors, matrices, the SVD) and you have the full mathematical core of machine learning. The natural next steps are probability and statistics (estimation, Bayes, the Gaussian), then optimization theory, and then the deep-learning curriculum proper — where these derivatives and integrals come alive in convolutional networks, Transformers, and generative models. You now understand the engine; the rest is engineering.

Chapter summary

  • Learning is minimizing a loss; the gradient is the learning signal and gradient descent the update.

  • Backpropagation is reverse-mode autodiff — the chain rule as vector–Jacobian products on a graph.

  • Key gradients (MSE \(\to\mathbf{X}^\top(\mathbf{X}\vtheta-\vy)\); softmax+cross-entropy \(\to p-y\)) recur everywhere.

  • The Hessian explains saddles, conditioning, and second-order/adaptive optimizers.

  • The integral side — expectations, entropy/KL, ELBO, ODEs/diffusion — defines and trains probabilistic and generative models.