Skip to content
Mathematical foundations Foundation 6 min read

Why the maths matters

Modern AI rests on five pieces of mathematics: linear algebra to represent things, calculus to improve them, probability to reason about uncertainty, information theory to measure surprise, and optimisation to search. You do not need all of mathematics. You need these five, deeply enough to derive what you use, and this track teaches exactly that, each idea tied to the place it appears in a real model.

10,000 ft

A language model is a function built from matrix multiplications (linear algebra), trained by following gradients computed with the chain rule (calculus), to maximise the probability of real text (probability), measured by cross-entropy (information theory), using a stochastic optimiser such as AdamW (optimisation), all in 16-bit floating point that would overflow without care (numerics), and judged by experiments that need statistics to mean anything. Every other track on this site assumes these ideas. Learn them once, properly, and you can read papers instead of summaries of papers: when a paper writes \(\operatorname{softmax}(QK^\top/\sqrt{d_k})V\) or \(\mathbb{E}_{x\sim p}[-\log q(x)]\), you will see the geometry and the reason, not just symbols.

The map

Each pillar answers one question that every learning system has to answer.

Pillar The question it answers Where you meet it in AI
Linear algebra How do we represent things and transform them? embeddings, layers, attention, LoRA, PCA
Calculus Which way should every parameter move? gradients, backpropagation, autodiff
Probability How do we reason when we are uncertain? language modelling, sampling, Bayesian methods, diffusion
Information theory How surprised is the model, and how far apart are two distributions? cross-entropy loss, perplexity, KL penalties in RLHF, compression
Optimisation How do we find good parameters in a huge non-convex landscape? SGD, Adam, learning-rate schedules, convergence

Two supporting topics make the five work in practice: numerical computing (floating point, stability, log-sum-exp) and statistics (is that improvement real, or noise?).

Five pillars and what they power
Five pillars and what they power. Linear algebra, Calculus, Probability, Information theory, Optimisation, the model: layers, attention, embeddings, gradients via backprop, the loss: cross-entropy, KL, training: SGD, Adam, Jacobians are matricesFive pillars and what they power. Linear algebra, Calculus, Probability, Information theory, Optimisation, the model: layers, attention, embeddings, gradients via backprop, the loss: cross-entropy, KL, training: SGD, Adam, Jacobians are matrices

How the pages depend on each other

The first half of the track (linear algebra and calculus) is the machinery of the model and its gradients:

Linear algebra and calculus: reading order
Linear algebra and calculus: reading order. Vectors and dot products, Matrices as linear maps, Eigenvectors, SVD, PCA, Tensors and broadcasting, Derivatives and gradients, Chain rule and Jacobians, shapes of gradientsLinear algebra and calculus: reading order. Vectors and dot products, Matrices as linear maps, Eigenvectors, SVD, PCA, Tensors and broadcasting, Derivatives and gradients, Chain rule and Jacobians, shapes of gradients

The second half (probability, information and optimisation) is the objective, the search and the honesty of the result:

Probability, information and optimisation: reading order
Probability, information and optimisation: reading order. Probability from first principles, The distributions that run AI, Estimation: MLE, MAP, Bayes, Entropy, cross-entropy, KL, Optimisation: convex and not, Floating point and log-sum-exp, Statistics for experiments and evals, max likelihood = min cross-entropy, fitting is optimising, stable softmaxProbability, information and optimisation: reading order. Probability from first principles, The distributions that run AI, Estimation: MLE, MAP, Bayes, Entropy, cross-entropy, KL, Optimisation: convex and not, Floating point and log-sum-exp, Statistics for experiments and evals, max likelihood = min cross-entropy, fitting is optimising, stable softmax

How to work through this track

Before you start. School algebra and a working Python/NumPy setup (your workbench). Nothing else is assumed; each page builds from first principles. Read how to study AI so it sticks once: the method there (derive it, code it, explain it) is how these pages are meant to be used.

Three routes.

  1. Builder's route (start shipping models soon, about 8 hours): vectors → matrices → tensors → derivatives → chain rule → probability → cross-entropy and KL. Then go to deep learning and come back for the rest when a page sends you here.
  2. Full route (the whole track in order, roughly two working weeks at 1–2 hours a day): every page below, top to bottom. The pages in the first half list their study times (60–90 minutes each); the second half is of similar size.
  3. Researcher's route: the full route, plus every collapsed derivation and every "hard" question, plus the papers marked as primary sources in each Go-deeper list. Re-derive the key results on paper without looking: the dot-product variance behind \(\sqrt{d_k}\), PCA via the Rayleigh quotient, \(\mathbf{p}-\mathbf{y}\) for softmax cross-entropy, the descent lemma, the VJP of a linear layer.

How each page is built. A 10,000-ft box (why it matters), a 2,000-ft box (the mechanism as a map), then ground level, first principles, the maths, runnable NumPy with real output, questions with hidden answers, and curated primary sources. Read the two altitude boxes of every page in the track first, in one sitting, to build the map; then go to ground level page by page.

How much maths do you actually need?

  • To use models through APIs you need almost none of this, but the vectors page (embeddings, cosine similarity) and the information-theory page (what log-probabilities and temperature mean) pay off immediately.
  • To train and fine-tune models you need the builder's route solidly: shapes, gradients, cross-entropy, and enough optimisation to choose a learning rate.
  • To read and do research you need all of it, fluently enough that the maths in a paper reads as an argument rather than a wall of symbols.

The pages

The five best resources for this track

If you only use five things alongside this site, use these.

For proofs, add Linear Algebra Done Right (Axler) and Convex Optimization (Boyd and Vandenberghe). For the modern view of derivatives as linear operators, MIT 18.S096 Matrix Calculus.

Prerequisites from other tracks

Where this leads

  • Classical machine learning — linear and logistic regression are the first payoff of vectors, gradients and likelihood.
  • Deep learning — backpropagation is the chain rule; every layer is a matrix.
  • Transformers and LLMs — attention is dot products and softmax; the loss is cross-entropy.
  • Formula sheet — the key results of this track on one page, for revision.