Skip to content

Vector Calculus Overview

Chapters 2 to 4 gave you the objects — vectors, matrices, decompositions. Chapter 5 gives you the verb. The book opens by naming three problems it is for:

  • linear regression (Chapter 9), where you optimise weights to maximise a likelihood;
  • neural-network autoencoders, where you minimise a reconstruction error “by repeated application of the chain rule”;
  • Gaussian mixture models (Chapter 11), where you optimise the location and shape of each component.

All three are optimisation, all three run on gradients, and the whole chapter is about computing gradients of things that are not scalars.

Not a formula — a rule about shapes:

The derivative’s shape is the output’s shape followed by the input’s shape.

ff mapsderivativeshapebook
RR\mathbb{R} \to \mathbb{R}derivativescalarDef 5.2
RnR\mathbb{R}^n \to \mathbb{R}gradient1×n1 \times n (a row)Eq 5.40
RnRm\mathbb{R}^n \to \mathbb{R}^mJacobianm×nm \times nEq 5.56
RnR\mathbb{R}^n \to \mathbb{R}, twiceHessiann×nn \times nEq 5.147
RnRm\mathbb{R}^n \to \mathbb{R}^m, twicetensorm×n×nm \times n \times n§5.7 Remark
Rp×qRm×n\mathbb{R}^{p\times q} \to \mathbb{R}^{m\times n}tensor(m×n)×(p×q)(m\times n)\times(p\times q)§5.4

Every dimension error in the chapter is a violation of that one line, and if you can state the shape of every factor before computing any of them, the rest is bookkeeping. That is exactly why the book’s Exercises 5.7 and 5.8 ask for the dimensions explicitly rather than just the answers.

And there is really only one rule: Equation 5.32’s chain rule. §5.2, §5.3, §5.6 and §5.8 are all that same rule, at increasing levels of generality, always read as a left-to-right matrix product.

The book’s Figure 5.2, as a diagram:

diagram Diagram mermaid

The through-line, and what each page settles

Section titled “The through-line, and what each page settles”
#PageThe question it answers
5.1Differentiation of Univariate FunctionsWhat is a derivative, where does the difference quotient stop working in floating point, and what does a Taylor series actually promise?
5.2Partial Differentiation and GradientsWhy is the gradient a row, and are the two things everyone says about it — steepest ascent, perpendicular to the level set — actually true?
5.3Gradients of Vector-Valued FunctionsWhat does the Jacobian’s determinant measure, and where does that measurement break?
5.4Gradients of MatricesWhat shape is the derivative of a matrix with respect to a matrix, and how do you organise it?
5.5Useful Identities for Computing GradientsTen identities, each verified — and the two whose conditions are routinely dropped.
5.6Backpropagation and Automatic DifferentiationWhy does the derivative cost about what the function costs, and why is reverse mode the only option for a scalar loss?
5.7Higher-Order DerivativesWhat does “the Hessian measures curvature” mean as an equation, and when does the second-order test say nothing at all?
5.8Linearization and Multivariate Taylor SeriesHow are the gradient and the Hessian the first two terms of one series, and why does practice stop at the second?
Chapter 5 Exercises and SolutionsAll nine of the book’s exercises, worked and checked against finite differences.
Chapter 5 Formula SheetEvery definition, identity and measured number on one page.

If you are here for backpropagation (the shortest honest route): §5.1’s chain rule → §5.2’s gradient-as-a-row → §5.3’s Jacobian → §5.6. You can skip §5.4, §5.5, §5.7 and §5.8 and come back.

If you are here for optimisation (Chapter 7’s prerequisites): §5.1 → §5.2 → §5.7’s Hessian → §5.8’s Taylor series. §5.7 and §5.8 are what Newton’s method, trust regions and the Laplace approximation are built from.

Either way, do §5.5’s identities when you first need a closed-form gradient, not before.

What the chapter looks like once it has been measured

Section titled “What the chapter looks like once it has been measured”

Every number below is measured on the page it belongs to, not quoted from anywhere.

ClaimMeasured
“Let h0h \to 0central differences improve to about h=106h = 10^{-6}, then get worse — round-off beats truncation
The gradient is the steepest directionswept over 360 directions, nothing beats f\lVert\nabla f\rVert, and the exact gradient direction attains it to 101210^{-12}
The gradient is perpendicular to the level setworst normalised deviation across a whole field: 101210^{-12}
detJ\det\mathbf{J} is the local area factorfirst-order convergent — away from where detJ\det\mathbf{J} changes sign, where a signed area is not what you measured
“The derivative costs what the function costs”6 forward operations against 16 in the reverse sweep: 2.67×2.67\times, a constant
Reverse mode beats forward modecrossover at n=3n = 3 for a scalar loss; a network has millions of parameters
AD versus finite differences2.2×10162.2\times10^{-16} against the best of 200 central differences at 9.8×10129.8\times10^{-12}
Mixed partials commuteonly for twice continuously differentiable ff: the standard counterexample’s two iterated limits differ by exactly 22
Eigenvalue signs classify a critical pointexcept when one is zero — and three functions share one singular Hessian with three different answers
Newton’s method is better8 steps against gradient descent’s 426, and it lands exactly on the saddle of x12x22x_1^2 - x_2^2
Higher-order Taylor is betteras r0r \to 0: fitted orders 1.0671.067, 2.0052.005, 3.0193.019. At r=3.2r = 3.2 the quadratic model was five times worse than the constant
Why nobody goes past second order5.0×10115.0\times10^{11} distinct Hessian entries at a million parameters — 4 TB in float32

Before reading anything, get the shape rule into your hands:

sketch Which derivative do I need? p5.js
Pick what your function takes in and what it puts out, and how many times you are differentiating. The panel names the object, its shape, the book's equation number, and the page that covers it. This is the shape rule made clickable — the single most useful thing to internalise before starting the chapter.

Prerequisites, and the bridge if you need one

Section titled “Prerequisites, and the bridge if you need one”
You needFrom
vectors, matrices, matrix products, shapesChapter 2 — Linear Algebra
inner products, norms, orthogonalityChapter 3 — Analytic Geometry
symmetric matrices have real eigenvalues and an orthonormal eigenbasisChapter 4 — Eigenvalues and Eigenvectors
positive definiteness, and Cholesky as a cheap test for itChapter 4 — Cholesky Decomposition

School calculus helps but is not assumed — §5.1 rebuilds the derivative from Definition 5.1’s difference quotient. The one genuine dependency is Chapter 4’s spectral theorem: §5.7’s entire classification rests on the Hessian being symmetric, which is what makes its eigenvalues real.

SectionUsed in
§5.1 chain ruleeverywhere; §5.6 is this applied mechanically
§5.2 gradient as a rowChapter 7’s optimality conditions, Chapter 9’s normal equations
§5.3 JacobianChapter 6’s change of variables, normalising flows
§5.4 matrix gradientsChapter 9’s linear regression, Chapter 10’s PCA
§5.5 identitiesanywhere a closed-form gradient beats differentiating
§5.6 backpropagationevery neural network ever trained
§5.7 HessianChapter 7’s Newton and convexity, the Laplace approximation
§5.8 TaylorChapter 7’s trust regions, Gauss–Newton, the Laplace approximation
pch.quizTag Before you start
  1. What shape is the derivative of a function from R^n to R^m?

    pch.quizShowAnswer

    B — m by n — the output's shape followed by the input's shape, which is the rule the whole chapter runs on — The Jacobian, Equation 5.56. And the same rule gives the gradient as 1 by n, the Hessian as n by n, and a vector field's second derivative as m by n by n.

  2. Why does the book insist the gradient is a ROW vector?

    pch.quizShowAnswer

    B — So the chain rule is a plain left-to-right matrix product with the shapes lining up, and so the convention still works when the output becomes a vector — Equation 5.40 gives both reasons. The payoff shows up immediately at Equation 5.148, where grad f times (x - x0) needs no transpose, and again at every chain rule in the chapter.

  3. How many genuinely different rules does this chapter contain?

    pch.quizShowAnswer

    B — Essentially one: Equation 5.32's chain rule, applied at four levels of generality — scalar, vector input, vector output, and tensors — Section 5.5's identities are consequences, not new rules, and Section 5.6 is the chain rule applied mechanically to a graph. Recognising that the chapter is one rule at four scales is what stops it feeling like a list to memorise.

  4. Which prerequisite does Section 5.7 genuinely depend on?

    pch.quizShowAnswer

    B — Chapter 4's spectral theorem — the classification of critical points rests entirely on the Hessian being symmetric, which is what makes its eigenvalues real and its eigenvectors orthogonal — Equation 5.146 gives the symmetry, Chapter 4 turns symmetry into real eigenvalues, and the eigenvalue SIGNS are the whole second-order test. Take away the symmetry and the test does not exist.

  • The chapter is one rule at four scales. Equation 5.32’s chain rule, applied to a scalar, to a vector input, to a vector output, and to tensors — always as a left-to-right matrix product.
  • The shape rule: the derivative’s shape is the output’s shape followed by the input’s shape. Scalar of a vector is 1 by n, vector of a vector is m by n, twice-differentiated scalar of a vector is n by n, twice-differentiated vector field is m by n by n.
  • Equation 5.40 makes the gradient a ROW for two reasons the book gives: the chain rule becomes a plain matrix product, and the convention survives when the output becomes a vector.
  • State the shapes before computing anything. Every dimension error in the chapter violates the shape rule, which is why the book’s Exercises 5.7 and 5.8 ask for dimensions explicitly.
  • Figure 5.2’s map: the difference quotient defines partial derivatives, which are collected into the gradient, the Jacobian and the Hessian, which feed the Taylor series — and out into Chapters 6, 7, 9, 10, 11 and 12.
  • The Hessian is the last object in the chapter with a name. One more index and everything is “a tensor”, which is precisely where Section 5.8 stops being practical.
  • Section 5.7 depends on Chapter 4’s spectral theorem. Equation 5.146 gives symmetry, symmetry gives real eigenvalues, and the eigenvalue signs are the entire second-order test.
  • Two reading paths. For backpropagation: 5.1, 5.2, 5.3, 5.6. For optimisation: 5.1, 5.2, 5.7, 5.8. Do Section 5.5’s identities when you first need a closed-form gradient.

Start with: Differentiation of Univariate Functions — the derivative from Definition 5.1, and the point where “let h0h \to 0” stops being true in floating point.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading