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?).
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:
The second half (probability, information and optimisation) is the objective, the search and the honesty of the result:
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.
- 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.
- 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.
- 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¶
-
Vectors, dot products and the geometry of meaning
Embeddings as points, similarity as angle, and why high-dimensional space is mostly perpendicular.
-
Columns as images of the axes, multiplication as composition, rank, determinant, and the transpose that carries gradients.
-
Rotate, stretch, rotate: the best low-rank approximation, curvature and learning rates, and PCA from scratch.
-
Tensors, shapes and broadcasting
Shapes, strides, views, broadcasting rules, batched matmul and einsum: the grammar of model code.
-
The best linear approximation, the direction of steepest ascent, gradient descent and the losses it trains.
-
The multivariable chain rule and Jacobians
Jacobians compose by multiplication; reverse mode turns that into backprop at the cost of a forward pass.
-
Probability from first principles
Events, random variables, conditioning, Bayes' rule, expectation and variance.
-
Bernoulli, categorical, Gaussian and friends, and where each one hides inside a model.
-
Estimation: MLE, MAP and Bayes
Fitting parameters to data: likelihood, priors as regularisers, and full posteriors.
-
Entropy, cross-entropy and KL divergence
Surprise as a number, the loss every language model minimises, and the distance between distributions.
-
Convexity, convergence, stochastic gradients, momentum and adaptive methods.
-
Floating point, stability and log-sum-exp
How numbers are stored, how computations overflow, and the tricks that keep training stable.
-
Statistics for experiments and evals
Confidence intervals, significance and variance, so you know when a better score is real.
The five best resources for this track¶
If you only use five things alongside this site, use these.
- Mathematics for Machine Learning — Deisenroth, Faisal and Ong, Cambridge University Press, 2020 (free PDF). The one textbook that covers this whole track at the right level, with ML applications in Part II.
- Essence of linear algebra and Essence of calculus — 3Blue1Brown. The geometric intuition, animated; watch each chapter before the matching page.
- MIT 18.065: Matrix Methods in Data Analysis, Signal Processing, and Machine Learning — Gilbert Strang. Linear algebra taught for machine learning by its best teacher. If you need the basics first, take 18.06.
- The Matrix Calculus You Need For Deep Learning — Terence Parr and Jeremy Howard, 2018. The bridge from school calculus to the gradients of vector functions.
- Information Theory, Inference, and Learning Algorithms — David MacKay, 2003 (free online). Probability and information theory written by a physicist who loved machine learning; the companion to the second half of this track.
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¶
- Your workbench: Python, notebooks, PyTorch, MLX — every page has NumPy code to run.
- How to study AI so it sticks — the derive–code–explain loop these pages are designed for.
- The map of AI at 10,000 ft — optional, for where the maths sits in the whole field.
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.