Overview
A long-form pass through the mathematics ML engineers actually use: calculus, linear algebra, probability, and statistics. Worked examples connect classical physics and modern machine learning, with Python snippets embedded throughout so the math maps cleanly to code you'd recognise from PyTorch or NumPy.
The book was written first as a gift — to my girls, to show that the world is knowable if you stay curious and keep going when something feels hard. The dedication is below.
2026 revision
This edition preserves the original Chapters 1–8 intact (calculus, linear algebra, probability, and statistics — the math here is genuinely timeless) and refreshes the two ML-facing chapters.
- Chapter 9 keeps its original sections on PPO, DPO, and the transformer, and adds five new sections covering the ideas the field moved to between 2023 and 2025:
- Rotary Position Embeddings (RoPE) — 2D rotations in attention space
- Attention variants at scale — MQA, GQA, and Flash Attention's tiling trick
- Scaling laws — the power-law regression behind Chinchilla-optimal training
- GRPO — group-relative PPO, the training loop behind 2025's reasoning models
- Diffusion and flow matching — generative modelling as regression on noise
- Chapter 10 is rewritten from scratch as a reading walkthrough of the DeepSeek-R1 paper (2025), tagging every equation in the paper back to a chapter of this book. It closes the book with a worked example of using its own math to follow current research.
The earlier Chapter 10 capstone is archived; everything in it is now covered in the relevant earlier chapters.
To my girls
To my girls — Allyana, Emalina, and Milana — I want you to grow up with the confidence that the world is knowable. Not "easy," not "obvious," but understandable if you're willing to stay curious, ask good questions, and keep going when something feels hard. Mathematics is one of the clearest languages we have for that kind of understanding: it teaches you how to separate signal from noise, how to reason from first principles, and how to build truth step by step.
In the years ahead, intelligence — both human and machine — will shape nearly everything. My hope is that this book helps you see how intelligence is built: how patterns become models, how models become decisions, and how decisions can be made with humility and care. If you can learn to read the equations behind the world, you won't just use the future — you'll help create it.
Thank you to my wife, for believing in me, for holding our family together through the long stretches of work, and for reminding me what matters most. And thank you to my mom, for her steady love and support — for the sacrifices that made my education possible, and for the strength that taught me to finish what I start.
And thank you to my dad, for never once doubting me — for the quiet confidence that made me feel brave enough to try, and the steady presence that reminded me I could.
And to my mom, again — thank you for helping us day and night with the kids so I could do this work. Your love shows up in every page, even when your name isn't on the cover.
If you're reading this years from now: I love you. Always.
Read online vs. PDF
The web reader splits the book into eleven parts — preface and ten chapters — and renders inline math and code listings directly in the browser. The PDF is the same content in a single downloadable file.