Free Math Textbooks: The 2027 Guide to Free Math Books for Programmers and Machine Learning
A curated, opinionated list of free math textbooks for programmers, computer science students and anyone learning math for machine learning: discrete math, proofs, linear algebra, calculus, probability, statistics, optimization, information theory and the theory behind modern ML. Every book here is legally free, published by its authors, a university or an open-textbook project, so you can download the PDF or read it online without pirate sites.
Last reviewed: December 2026. “Free” means free to read online or download from an official source at the time of review. Many of these books are also sold in print; if one changes your life, buying a copy supports the author.
Table of Contents
- Who This Is For
- How to Use This List
- Quick Picks: One Book per Subject
- Roadmaps
- Stage 0: Refreshers (Algebra, Precalculus)
- Proofs and Logic
- Discrete Mathematics
- Combinatorics and Graph Theory
- Linear Algebra
- Calculus
- Matrix Calculus and Differentiable Programming
- Real Analysis
- Probability
- Statistics
- Bayesian Statistics
- Causal Inference
- Optimization
- Numerical Methods
- Information Theory
- Number Theory and Abstract Algebra (for Cryptography)
- Math for Machine Learning (All-in-One Books)
- Learning Theory and High-Dimensional Probability
- Free Courses and Videos That Pair Well
- Comparison Tables
- Practice: Exercises and Projects
- How to Study a Math Textbook
- FAQ
- Where to Go Next
- Contributing
- License
Who This Is For
- Self-taught developers who skipped university math and want to understand algorithms, graphics, cryptography or data work.
- CS students looking for a free alternative (or a second explanation) to an expensive course textbook.
- Aspiring ML engineers and data scientists who keep hitting walls of notation in papers and want the linear algebra, calculus, probability and statistics behind them.
- Researchers moving into ML theory who need concentration inequalities, convex optimization and learning theory.
You do not need all of these books. Pick one per subject, finish it, do the exercises.
How to Use This List
Each entry follows the same shape:
- Title, author(s), and a link to the official free version.
- Level:
Beginner,Intermediate,Advanced. - Format:
HTML,PDF,Interactive(embedded applets or code),Notebooks(Jupyter). - Best for: who should read it and why.
Symbols used: ⭐ = the best pick in its section. 💲 = paid book mentioned only for context (the free alternatives are listed first).
Quick Picks: One Book per Subject
If you only want one free book per subject, take these:
| Subject | Best free pick | Why |
|---|---|---|
| Proofs | Book of Proof | Gentle, complete, full of exercises, ideal first proof book |
| Discrete math for CS | Mathematics for Computer Science | Written for MIT’s 6.042 course, covers exactly what CS needs |
| Linear algebra (intuition + computation) | Introduction to Applied Linear Algebra (VMLS) | Vectors, matrices and least squares with applications, no fluff |
| Linear algebra (theory) | Linear Algebra Done Right | The standard proof-based text, now open access |
| Calculus | OpenStax Calculus, Volumes 1 to 3 | Full university calculus sequence, peer reviewed |
| Probability | Introduction to Probability (Stat 110 book) | Story proofs and intuition from a famous Harvard course |
| Statistics | OpenIntro Statistics | Clear, modern intro used in many colleges |
| Bayesian stats | Bayes Rules! | Friendly, code-first, free online |
| Optimization | Convex Optimization | The reference for convex problems in ML and engineering |
| Information theory | Information Theory, Inference, and Learning Algorithms | Connects coding, inference and neural networks |
| Math for ML | Mathematics for Machine Learning | Linear algebra, calculus, probability and optimization in one book, aimed at ML |
Roadmaps
Time estimates assume about 6 to 8 focused hours a week. Double them if you do every exercise, halve them if you already know part of the material.
Roadmap A: Math for Software Engineers (about 4 months)
Goal: be comfortable with proofs, big-O reasoning, combinatorics, graphs and basic probability, the math behind algorithms and system design.
| Stage | Weeks | Read | Do |
|---|---|---|---|
| 1. Logic and proofs | 3 | Book of Proof, Parts I and II | Prove 20 small statements by induction and contradiction |
| 2. Discrete math core | 6 | Mathematics for Computer Science, Parts I to III | Solve recurrences, count graphs, analyze loops |
| 3. Probability for programmers | 4 | Mathematics for Computer Science, Part IV | Simulate the birthday paradox and hashing collisions in code |
| 4. Linear algebra basics | 3 | VMLS, Chapters 1 to 10 | Implement vector and matrix ops without libraries |
Roadmap B: Math for Machine Learning (about 6 to 9 months)
Goal: read ML papers and textbooks (for example Deep Learning or Pattern Recognition and Machine Learning) without getting stuck on the math.
| Stage | Weeks | Read | Do |
|---|---|---|---|
| 0. Refresh algebra and functions | 2 to 4 | OpenStax College Algebra or Precalculus (only weak spots) | Khan Academy unit tests until you pass |
| 1. Linear algebra | 6 to 8 | VMLS, then Mathematics for Machine Learning Chapters 2 to 4 | Implement least squares, PCA via SVD with NumPy |
| 2. Calculus | 6 to 8 | OpenStax Calculus Vol. 1 (derivatives, integrals), Vol. 3 (partial derivatives, gradients) | Derive gradients for linear and logistic regression by hand |
| 3. Matrix calculus | 2 | The Matrix Calculus You Need for Deep Learning | Write backprop for a 2-layer network from scratch |
| 4. Probability | 6 to 8 | Introduction to Probability (Stat 110 book), Chapters 1 to 7 | Simulate every distribution you meet; check against formulas |
| 5. Statistics | 4 to 6 | OpenIntro Statistics, then Think Stats | Run a real A/B test analysis on a public dataset |
| 6. Optimization | 3 to 4 | Mathematics for Machine Learning Ch. 7, then Convex Optimization Ch. 1 to 5 (skim) | Implement gradient descent, momentum, Adam on a toy problem |
| 7. Glue it together | 2 to 4 | Mathematics for Machine Learning Part II | Re-derive linear regression, PCA, GMMs and SVMs from the book |
Roadmap C: Theory Track for ML Research (12+ months)
Goal: read and write theory papers.
- Proof fluency (2 months): Book of Proof, then Basic Analysis Volume I.
- Rigorous linear algebra (2 months): Linear Algebra Done Right.
- Measure-light probability (2 months): Probability: Theory and Examples (first chapters), with the Stat 110 book as a companion.
- Convex optimization (2 months): Convex Optimization, Parts I and II, with exercises.
- High-dimensional probability (2 months): High-Dimensional Probability.
- Learning theory (2+ months): Understanding Machine Learning: From Theory to Algorithms, then Learning Theory from First Principles.
Stage 0: Refreshers (Algebra, Precalculus)
If fractions, exponents, logarithms or trigonometry feel shaky, fix them first. It saves weeks later.
- OpenStax College Algebra 2e, Jay Abramson et al.
BeginnerHTML/PDF. Functions, polynomials, exponentials, logarithms, systems of equations. Best for: rebuilding fundamentals. - ⭐ OpenStax Precalculus 2e, Jay Abramson et al.
BeginnerHTML/PDF. Everything you need before calculus, including trig. Best for: the direct on-ramp to calculus. - Stitz-Zeager Precalculus, Carl Stitz and Jeff Zeager.
BeginnerPDF. A thorough open-source precalculus with many worked examples. Best for: learners who like a lot of practice problems. - Khan Academy Math (not a book). Free practice with instant feedback. Best for: diagnosing gaps quickly.
Proofs and Logic
Proofs are the skill that unlocks every advanced book on this page. Spend time here even if you “just want ML”.
- ⭐ Book of Proof, Richard Hammack.
BeginnerPDF. Sets, logic, direct proof, contrapositive, contradiction, induction, relations, functions, cardinality. Best for: your first proof book; the writing is patient and the exercises have selected solutions. - forall x: Calgary, P.D. Magnus, Tim Button, and others.
BeginnerPDF. Formal logic: truth tables, natural deduction, first-order logic. Best for: anyone heading toward programming language theory, verification or SAT solvers. - Mathematics for Computer Science, Eric Lehman, F. Thomson Leighton, Albert R. Meyer.
IntermediatePDF. Part I is a proof crash course with CS-flavored examples (state machines, invariants). - 💲 How to Prove It (Velleman, Cambridge University Press) is a popular paid alternative if you want a printed book.
Discrete Mathematics
The math of algorithms: counting, recurrences, graphs, number theory and discrete probability.
- ⭐ Mathematics for Computer Science (MIT 6.042), Lehman, Leighton, Meyer.
IntermediatePDF, about 1,000 pages. Proofs, number theory, graphs, counting, generating functions, discrete probability, random walks. Best for: CS students and engineers who want the whole package. Pair with the MIT OpenCourseWare 6.042J lectures. - Discrete Mathematics: An Open Introduction, Oscar Levin.
BeginnerHTML/PDFInteractive. Counting, sequences, logic, graph theory, with many exercises. Best for: a gentler start than MIT’s book; widely used as a free course textbook. - Applied Discrete Structures, Al Doerr and Ken Levasseur.
BeginnerHTML/PDF. Sets, logic, relations, graphs, trees, algebraic structures, with SageMath examples. Best for: learners who want code alongside math. - Foundations of Computer Science, Alfred Aho and Jeffrey Ullman.
BeginnerPDF. A classic that teaches discrete math through data structures and C code. Best for: programmers who learn best from concrete code. - 💲 Discrete Mathematics and Its Applications (Rosen) and Concrete Mathematics (Graham, Knuth, Patashnik) are the famous paid texts; the free books above cover the same core.
Combinatorics and Graph Theory
- ⭐ Applied Combinatorics, Mitchel T. Keller and William T. Trotter.
IntermediateHTML/PDF. Counting, inclusion-exclusion, generating functions, recurrences, graph theory, network flows. Best for: algorithm designers and competitive programmers. - Graph Theory (free electronic edition), Reinhard Diestel.
AdvancedPDF. The standard graduate graph theory text; the author offers a free, reduced-features electronic edition. Best for: deep theory after a first course. - generatingfunctionology, Herbert Wilf.
IntermediatePDF. The classic short book on generating functions, released free by the author. Best for: counting problems and solving recurrences. - Analytic Combinatorics, Philippe Flajolet and Robert Sedgewick.
AdvancedPDF. Asymptotic counting and analysis of algorithms. Best for: people analyzing algorithms precisely.
Linear Algebra
The single most important subject for ML, graphics, robotics and scientific computing. Two tracks: applied (compute and use) and theoretical (prove and understand). Most programmers should start applied.
Applied and computational
- ⭐ Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares (VMLS), Stephen Boyd and Lieven Vandenberghe.
BeginnerPDF, with Python and Julia companions. Covers vectors, matrices, least squares, data fitting, classification and control. Best for: programmers and ML beginners; it gets you to useful applications fast. - Interactive Linear Algebra, Dan Margalit and Joseph Rabinoff.
BeginnerHTMLInteractive. Geometric intuition with interactive demos. Best for: visual learners. - Understanding Linear Algebra, David Austin.
BeginnerHTMLInteractive. Activity-driven, with Sage cells to run code in the page. - Immersive Linear Algebra, J. Ström, K. Åström, T. Akenine-Möller.
BeginnerHTMLInteractive. Claims to be the first linear algebra book with fully interactive figures; great for graphics people.
Proof-based
- ⭐ Linear Algebra Done Right, 4th edition, Sheldon Axler.
IntermediatePDF. Open access since the 4th edition (Springer). Determinant-free approach to vector spaces, eigenvalues, inner products, operators. Best for: ML researchers and anyone who wants real understanding. - Linear Algebra, Jim Hefferon.
Beginner/IntermediatePDF. A first proof-based course with full exercise answers. - A First Course in Linear Algebra, Robert Beezer.
Beginner/IntermediateHTML/PDF. Open source, rigorous and complete. - Linear Algebra Done Wrong, Sergei Treil.
IntermediatePDF. A free, proof-based alternative whose title is a playful nod to Axler’s book.
Reference
- The Matrix Cookbook, Kaare Brandt Petersen and Michael Syskind Pedersen.
ReferencePDF. Identities for matrix derivatives, inverses and decompositions. Keep it open while reading ML papers.
Calculus
- ⭐ OpenStax Calculus Volume 1, Volume 2, Volume 3, Gilbert Strang, Edwin “Jed” Herman et al.
BeginnerHTML/PDF. A full single-variable and multivariable sequence. For ML, Volume 1 (limits, derivatives, integrals) and Volume 3 (partial derivatives, gradients, multiple integrals) matter most. - Active Calculus, Matt Boelkins et al.
BeginnerHTML/PDF. Learn-by-doing activities, single and multivariable. - Calculus (MIT OpenCourseWare), Gilbert Strang.
BeginnerPDF. A complete textbook by a famous teacher, hosted free by MIT. - Calculus Made Easy, Silvanus P. Thompson (public domain, Project Gutenberg).
Beginner. A charming 1910 book that demystifies derivatives and integrals. Best for: people scared of calculus. - Video companion: 3Blue1Brown, Essence of Calculus.
Matrix Calculus and Differentiable Programming
This is the calculus of deep learning: gradients of vector and matrix functions, the chain rule in many dimensions, automatic differentiation.
- ⭐ The Matrix Calculus You Need for Deep Learning, Terence Parr and Jeremy Howard.
Beginner/IntermediateHTML. Short, practical, exactly what you need for backprop. - Matrix Calculus online tool. Computes matrix derivatives symbolically; use it to check your work.
- The Elements of Differentiable Programming, Mathieu Blondel and Vincent Roulet.
AdvancedPDF (arXiv). Autodiff, differentiable control flow, smoothing, and the math behind JAX and PyTorch. - Alice’s Adventures in a Differentiable Wonderland, Volume I, Simone Scardapane.
IntermediatePDF (arXiv). A modern primer on differentiable models from tensors to transformers.
Real Analysis
Needed for research-level probability, optimization and learning theory, not for applied ML.
- ⭐ Basic Analysis: Introduction to Real Analysis, Jiří Lebl.
IntermediatePDF/HTML. A free, complete one- or two-semester course. Volume II covers multivariable analysis. - 💲 Analysis I (Tao) and Understanding Analysis (Abbott) are popular paid alternatives.
Probability
- ⭐ Introduction to Probability, 2nd edition (Stat 110 book), Joseph K. Blitzstein and Jessica Hwang.
Beginner/IntermediateHTML(free online version; not a download). Story proofs, strategies, and many worked examples. Pair with the Stat 110 course site (free lectures, handouts and practice problems). - Introduction to Probability, Charles Grinstead and J. Laurie Snell.
BeginnerPDF(GNU FDL). A long-running free classic with simulation-minded exercises. - Introduction to Probability, Statistics, and Random Processes, Hossein Pishro-Nik.
Beginner/IntermediateHTML. Free online, with solved problems; strong on random processes for engineers. - Introduction to Probability for Data Science, Stanley H. Chan.
IntermediatePDF. Probability written for ML and signal processing students, with Python examples; free PDF from the author. - Probability and Statistics: The Science of Uncertainty, Michael Evans and Jeffrey Rosenthal.
IntermediatePDF. Probability and statistics in one free text. - Probability: Theory and Examples, Rick Durrett.
AdvancedPDF. Measure-theoretic graduate probability, free from the author. - Seeing Theory, Brown University.
BeginnerInteractive. Visual introduction to probability and statistics in the browser.
Statistics
- ⭐ OpenIntro Statistics, David Diez, Mine Çetinkaya-Rundel, Christopher Barr.
BeginnerPDF(free; pay-what-you-want options). Distributions, inference, regression. Clear and widely adopted. - Introduction to Modern Statistics, Mine Çetinkaya-Rundel and Johanna Hardin.
BeginnerHTML/PDF. A modern, simulation-first take with randomization and bootstrapping. - Think Stats, 3rd edition, Allen B. Downey.
BeginnerNotebooks. Exploratory data analysis and statistics with Python and pandas. Best for: programmers who would rather compute than derive. - OpenStax Introductory Statistics 2e.
BeginnerHTML/PDF. Standard intro course, no programming required. - StatLect, Marco Taboga.
IntermediateHTML. Digital textbook on probability and mathematical statistics with proofs. - An Introduction to Statistical Learning (ISL), James, Witten, Hastie, Tibshirani (and Taylor for the Python edition).
Beginner/IntermediatePDF. The bridge from statistics to ML; free from the authors in R and Python editions. - The Elements of Statistical Learning (ESL), Hastie, Tibshirani, Friedman.
AdvancedPDF. The graduate follow-up to ISL.
Bayesian Statistics
- ⭐ Bayes Rules! An Introduction to Applied Bayesian Modeling, Alicia A. Johnson, Miles Q. Ott, Mine Dogucu.
BeginnerHTML. Friendly, R-based, with exercises. - Think Bayes 2, Allen B. Downey.
BeginnerNotebooks. Bayesian thinking in Python with simple code instead of heavy math. - Bayesian Data Analysis, 3rd edition, Gelman, Carlin, Stern, Dunson, Vehtari, Rubin.
AdvancedPDF. The reference text; the authors provide a free PDF for non-commercial use. - Regression and Other Stories, Andrew Gelman, Jennifer Hill, Aki Vehtari.
IntermediatePDF. Applied regression with a free PDF from the authors’ site. - 💲 Statistical Rethinking (McElreath) is paid, but the lectures and course materials are free and excellent.
Causal Inference
- ⭐ Causal Inference: What If, Miguel Hernán and James Robins.
IntermediatePDF. Free from the authors. - Causal Inference: The Mixtape, Scott Cunningham.
Beginner/IntermediateHTML. Econometrics-style causal inference with code, free online.
Optimization
- ⭐ Convex Optimization, Stephen Boyd and Lieven Vandenberghe.
Intermediate/AdvancedPDF. Convex sets and functions, duality, algorithms. Free PDF from the authors. Paired with Stanford’s EE364a lectures. - Algorithms for Optimization, Mykel J. Kochenderfer and Tim A. Wheeler (MIT Press).
IntermediatePDF. Derivative-based, stochastic, population and surrogate methods, with Julia code. The authors provide the full PDF. - Mathematics for Machine Learning, Chapter 7. A short, ML-focused introduction to gradient descent and constrained optimization.
Numerical Methods
How math meets floating point: stability, conditioning, solving linear systems, ODEs.
- ⭐ Fundamentals of Numerical Computation, Tobin A. Driscoll and Richard J. Braun.
IntermediateHTML. Free online, with code (Julia, Python and MATLAB versions exist). - Numerical Recipes (official site). The official site lets you read the 3rd edition (C++) online free with occasional nag screens, and the older 2nd editions in C and Fortran free. Print and code downloads are paid. Best for: practical algorithms.
Information Theory
- ⭐ Information Theory, Inference, and Learning Algorithms, David J.C. MacKay.
Intermediate/AdvancedPDF. Entropy, compression, error-correcting codes, Bayesian inference, neural networks. Free on the author’s site with Cambridge University Press’s permission. Best for: understanding cross-entropy, KL divergence and why compression and prediction are the same problem.
Number Theory and Abstract Algebra (for Cryptography)
- ⭐ A Computational Introduction to Number Theory and Algebra, Victor Shoup.
IntermediatePDF. Written with cryptography in mind; free from the author. - Elementary Number Theory: Primes, Congruences, and Secrets, William Stein.
BeginnerPDF. Number theory with RSA, Diffie-Hellman and SageMath. - Abstract Algebra: Theory and Applications, Thomas W. Judson.
IntermediateHTML/PDF. Groups, rings, fields, with applications to coding theory and cryptography. - Practice: CryptoHack turns this math into hands-on challenges.
Math for Machine Learning (All-in-One Books)
- ⭐ Mathematics for Machine Learning, Marc Peter Deisenroth, A. Aldo Faisal, Cheng Soon Ong.
IntermediatePDF. Part I: linear algebra, analytic geometry, matrix decompositions, vector calculus, probability, optimization. Part II: regression, PCA, GMMs, SVMs. The best single free book for ML math. - A Programmer’s Introduction to Mathematics, Jeremy Kun.
IntermediatePDF(pay what you want, including zero). Math explained through programs: polynomials, graphs, calculus, linear algebra, eigenvectors, groups. - Mathematics for Machine Learning (lecture notes), Garrett Thomas (UC Berkeley).
IntermediatePDF. A 40-page survival guide; great as a refresher before CS 189-style courses. - Dive into Deep Learning: Mathematics appendix.
IntermediateHTMLNotebooks. Linear algebra, calculus, probability and information theory with runnable code. - Algebra, Topology, Differential Calculus, and Optimization Theory for Computer Science and Machine Learning, Jean Gallier and Jocelyn Quaintance.
AdvancedPDF. Over 2,000 pages of rigorous background; use it as a reference. - Probabilistic Machine Learning: An Introduction, Kevin P. Murphy.
IntermediatePDF. Its opening chapters are an efficient refresher on probability, statistics, linear algebra and optimization for ML. - Foundations of Data Science, Avrim Blum, John Hopcroft, Ravindran Kannan.
AdvancedPDF. High-dimensional geometry, SVD, random walks, random graphs and algorithms for massive data.
Learning Theory and High-Dimensional Probability
- ⭐ Understanding Machine Learning: From Theory to Algorithms, Shai Shalev-Shwartz and Shai Ben-David.
AdvancedPDF. PAC learning, VC dimension, regularization, stability. Free PDF for personal use. - Foundations of Machine Learning, Mehryar Mohri, Afshin Rostamizadeh, Ameet Talwalkar.
AdvancedPDF. Rademacher complexity, boosting, kernels, online learning. - Learning Theory from First Principles, Francis Bach (MIT Press).
AdvancedPDF. Modern theory including kernels, neural networks and optimization, with a free PDF from the author. - High-Dimensional Probability, Roman Vershynin.
AdvancedPDF. Concentration inequalities, random matrices, and their use in data science. - Patterns, Predictions, and Actions, Moritz Hardt and Benjamin Recht.
Intermediate/AdvancedHTML/PDF. A modern, critical look at ML theory, from prediction to decisions and causality.
Free Courses and Videos That Pair Well
| Subject | Course or channel | Pair with |
|---|---|---|
| Linear algebra | MIT 18.06 Linear Algebra (OCW) | VMLS or Interactive Linear Algebra |
| Linear algebra intuition | 3Blue1Brown: Essence of Linear Algebra | Any linear algebra book, watch first |
| Single-variable calculus | MIT 18.01SC | OpenStax Calculus Vol. 1 |
| Multivariable calculus | MIT 18.02SC | OpenStax Calculus Vol. 3 |
| Discrete math | MIT 6.042J | Mathematics for Computer Science |
| Probability | Harvard Stat 110 | Introduction to Probability (Stat 110 book) |
| Probability and statistics | MIT 18.05 | OpenIntro Statistics |
| Mathematical statistics | MIT 18.650 | StatLect |
| Statistics intuition | StatQuest (YouTube) | ISL |
| Bayesian modeling | Statistical Rethinking lectures | Bayes Rules! |
More open textbooks: the American Institute of Mathematics open textbook list and the Open Textbook Library both review and catalog free, openly licensed math books.
Comparison Tables
Linear algebra: which free book?
| Book | Style | Proofs | Code | Length | Best for |
|---|---|---|---|---|---|
| VMLS | Applied | Few | Julia/Python companions | ~470 pp | Programmers, ML beginners |
| Interactive Linear Algebra | Geometric | Some | Applets | Medium | Visual intuition |
| Understanding Linear Algebra | Activity-based | Some | Sage cells | Medium | Self-study with practice |
| Hefferon | First proof course | Yes | No | ~500 pp | Math-curious engineers |
| Linear Algebra Done Right | Abstract | Yes | No | ~390 pp | Theory, research |
| Mathematics for ML (Part I) | ML-focused | Light | No | 3 chapters | Fast ML prep |
Probability: which free book?
| Book | Level | Strength | Weakness |
|---|---|---|---|
| Stat 110 book | Beginner to intermediate | Intuition, story proofs, great problems | Online only, not downloadable |
| Grinstead and Snell | Beginner | Free PDF, simulations | Older style |
| Pishro-Nik | Beginner to intermediate | Random processes, solved problems | Less narrative |
| Chan | Intermediate | Written for data science, Python | Long |
| Durrett | Advanced | Rigor, measure theory | Hard first book |
Statistics: which free book?
| Book | Approach | Language | Best for |
|---|---|---|---|
| OpenIntro Statistics | Classical | None required (R labs available) | First course |
| Introduction to Modern Statistics | Simulation-first | R | Modern intro |
| Think Stats 3e | Computational | Python | Programmers |
| ISL | Statistical learning | R or Python | Moving into ML |
Practice: Exercises and Projects
Reading without doing is the most common reason people “finish” a math book and remember nothing. Try these projects, each tied to a section above:
- Proof journal. Each week write up three proofs in LaTeX or Markdown. Use Book of Proof exercises.
- Big-O from scratch. Derive the running time of merge sort and binary search with recurrences (MCS Chapter on recurrences), then measure them in code and plot.
- Hash collision simulator. Compute the birthday-bound probability analytically, simulate it, and compare.
- Mini NumPy. Implement vector add, dot product, matrix multiply, transpose and Gaussian elimination in pure Python. Test against NumPy.
- Least squares house prices. Fit a linear model with normal equations and with QR, compare numerical stability (VMLS + Fundamentals of Numerical Computation).
- PCA on images. Compute an SVD of a small image dataset and reconstruct images with k components.
- Gradient checker. Derive gradients for logistic regression by hand, then verify with finite differences.
- Backprop by hand. Implement a two-layer neural network forward and backward pass using only NumPy and the matrix calculus guide.
- Distribution zoo. For each distribution in the Stat 110 book, sample 100,000 values and compare histograms with the PDF.
- A/B test analysis. Analyze a public A/B test dataset with both a frequentist test and a Bayesian model (OpenIntro + Bayes Rules!).
- Optimizer race. Implement gradient descent, momentum and Adam on the Rosenbrock function and plot the paths.
- Entropy coder. Implement Huffman coding and compare compressed size to the entropy bound (MacKay Chapter 5).
- Toy RSA. Implement modular exponentiation, extended Euclid and RSA with small primes (Shoup or Stein).
- Project Euler. Project Euler problems mix number theory, combinatorics and programming.
How to Study a Math Textbook
- Read with a pencil. Re-derive every step that is not obvious. If a line says “clearly”, check it.
- Do at least a third of the exercises. Choose a mix of easy and hard. Exercises are where learning happens.
- Explain it in code. For applied topics, implement the idea. If your code disagrees with the formula, one of them is wrong, and finding which one teaches you a lot.
- Use spaced repetition for definitions and key theorems (a small deck, not thousands of cards).
- Read two books on hard topics. A second explanation often fixes what the first one could not.
- Do not aim for 100% before moving on. Return to earlier chapters when a later topic needs them.
- Keep a “confusions” file. Write down what you did not understand and revisit it weekly.
FAQ
What math do I need for machine learning? Linear algebra (vectors, matrices, eigenvalues, SVD), multivariable calculus (gradients, the chain rule), probability (distributions, expectation, Bayes’ rule) and some statistics and optimization. Mathematics for Machine Learning covers this list in one free book.
What math do I need for software engineering? For most jobs, discrete math (logic, sets, counting, graphs), big-O analysis and basic probability are enough. Graphics, games and ML need linear algebra; cryptography needs number theory.
Are these textbooks really free and legal? Yes. Every link points to the author’s site, a university, arXiv, OpenStax or another open-textbook project. If a link ever points to an unofficial copy, please open an issue.
Where can I find a free PDF of Linear Algebra Done Right? On the official site. The 4th edition is open access.
Is there a free version of Introduction to Probability by Blitzstein and Hwang? Yes, the authors provide a free online version at probabilitybook.net. It is read-online only.
What is the best free calculus textbook? OpenStax Calculus (Volumes 1 to 3) for a standard course; Active Calculus if you prefer activities; Calculus Made Easy if you are anxious about the subject.
Should I learn linear algebra or calculus first for ML? Linear algebra first. Most of ML is matrix operations, and you need only basic derivatives at the start.
How long does it take to learn math for machine learning? With 6 to 8 hours a week and some high school algebra, roughly 6 to 9 months to be comfortable (Roadmap B). You can start practical ML courses in parallel after the linear algebra stage.
Do I need proofs for ML engineering? Not to use libraries. You do need them to read theory papers, invent new methods, or work in research.
I’m bad at math. Can I still do this? Yes. Start with Stage 0, use Khan Academy for instant feedback, and choose the friendliest books (OpenStax, Interactive Linear Algebra, Think Stats). Progress comes from consistent practice, not talent.
Is Khan Academy enough? For refreshers and high school to early college level, it is excellent. For linear algebra, probability and beyond, pair it with a book from this list.
What is the difference between ISL and ESL? ISL is the applied introduction with labs; ESL is the denser, more mathematical graduate version from overlapping authors. Start with ISL.
Where to Go Next
- Apply the math: free ML books in machine-learning-books.
- See which textbook fits each CS course in computer-science-textbooks.
- Pick the classics every developer should read in best-programming-books.
- Do problems: Project Euler, CryptoHack, and the exercise sets in every book above.
Contributing
Suggestions are welcome. To add a book, open an issue or pull request with:
- The official link (author, university, publisher or open-textbook site only; no unofficial PDF mirrors).
- Level, format, and one honest sentence on who it is best for.
- Confirmation that it is free to read from that link today.
Please also report broken links and books that stopped being free.
License
This list is released under CC BY 4.0. The books belong to their authors and publishers and keep their own licenses.
If this helped you, a star helps others find it.
More free resources
Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.