Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Linear algebra can be viewed as the study of linear spaces and linear mappings.[1] The most typical linear spaces are the finite-dimensional Euclidean spaces with Cartesian coordinates, where linear mappings can be understood through matrix multiplication and appear concretely as rotations, reflections, projections, scalings, shears, and their combinations. These transformations are everywhere in the physical world, computer graphics, statistics, and machine learning, and a first-year university linear algebra course usually starts from them.

For mathematicians, the value of linear algebra lies in this: once a problem can be formulated in the framework of linear algebra, it can often be solved completely. Many central topics fall within this framework, such as differentiation and integration on function spaces. Although infinite-dimensional spaces can only partly reuse the finite-dimensional theory, we still often approximate them by finite-dimensional spaces and obtain reliable approximate results. Nor does linear algebra deal only with linear problems: nonlinear topics such as the interactions between linear mappings and the properties of random matrices are also part of its subject matter, and our understanding of the field is still deepening.

What linear algebra abstracts is nothing more than two basic operations: the addition of vectors and the multiplication of vectors by scalars. Remarkably, on such a slender foundation one can raise grand structures in the Romanesque, Gothic, and Baroque styles; more striking still, it not only provides precise theorems for mathematics and its applications, but also supplies a fitting language in which to state these problems.

What This Book Aims to Do

Linear Algebra with Python tries to strike a balance among four aspects: geometric intuition, algebraic structure, computational methods, and real-world applications. We start from geometric pictures of linear mappings, use Python code as a tool for interactive exploration and verification, and then move step by step toward abstract definitions and proofs, in the hope that the body of knowledge readers build follows the natural order of understanding and can also be applied directly to solving problems.

To this end, the book makes several choices that differ from traditional textbooks: it uses code to support computation and provides interactive figures; it uses 0-based indexing throughout, as is common in computer science and physics, rather than the 1-based indexing customary in mathematics textbooks; it treats Gaussian elimination and the PLU decomposition from a single point of view when solving systems of linear equations; and in the chapters on eigenvalues, inner product spaces, and the singular value decomposition it brings in many examples from data science and quantum mechanics.

Intended Readers and Prerequisites

This book is suitable for undergraduates in mathematics, physics, computer science, engineering, and related fields; graduate students who need to strengthen their foundations in linear algebra; self-learners with some programming background who want to learn linear algebra systematically; and teachers looking for new ways to teach the subject.

Reading the book requires high-school mathematics (functions, coordinate systems, and basic reasoning) and introductory Python (variables, loops, functions). If your programming background is thin, there is no need to worry: the early chapters introduce the syntax and packages we use as they are needed.

Teaching Philosophy

Visualization first, abstraction gradually. People usually build intuition through visual and spatial perception before raising that intuition to abstract understanding. The book therefore begins with concrete transformations in two and three dimensions, accumulates geometric feeling through interactive figures, and only then introduces general vector spaces and abstract definitions.

Understanding driven by code. Code in this book is not an appendix but a tool for understanding concepts: readers can verify the conclusions of theorems with code, observe the effects of transformations through visual experiments, and test whether the theory holds on real data.

Theory guided by applications. Important concepts are introduced from concrete problems whenever possible, and theoretical derivations alternate with applied case studies, so that readers always know why a tool is needed.

Structure of the Book

The book has 11 chapters, with 13 interactive experiments placed after the relevant chapters. Most chapters come with a separate exercise page, where each exercise has an expandable solution and Python verification code.

ChapterTopicKey contentAccompanying experiments
1Sets and mappingsSet operations; injective, surjective, and bijective mappings—
2VectorsLinear operations, inner products and projections, cross products—
3Linear mappings and matricesMatrices motivated by rotations, typical 2D and 3D mappings, the geometric meaning of the determinantExperiment 1: 2D linear transformations; Experiment 2: 3D linear transformations
4Abstract linear spacesVector space axioms, linear independence and bases, kernel and image, the rank–nullity theoremExperiment 3: direct sums and tensor products
5Block matricesBlock multiplication, block inversesExperiment 4: four views of matrix multiplication; Experiment 5: covariance matrices
6Systems of linear equationsReduced row echelon form, the geometric structure of solutions, Gaussian eliminationExperiment 6: step-by-step elimination in the PLU decomposition
7DeterminantsDefinition and properties, computation, applications—
8The eigenvalue problemSimilarity and diagonalization, Jordan canonical form, numerical methodsExperiment 7: eigenvalue multiplicity and dynamical systems; Experiment 8: mixing times of Markov chains
9Inner product spaces and orthogonal structureOrthogonal and unitary matrices, Hermitian matrices, quadratic forms and the principal axis theoremExperiment 9: Gram–Schmidt orthogonalization
10Introduction to quantum mechanicsQuantum states, density matrices, quantum measurement, the uncertainty principleExperiment 10: the Bloch sphere and quantum gates
11The singular value decomposition and its applicationsProof of the SVD, matrix norms, PCA, the pseudoinverse, the Schmidt decompositionExperiment 11: latent semantic analysis; Experiment 12: eigenfaces; Experiment 13: PCA of the Iris dataset

The order of the chapters deliberately does not begin with systems of linear equations or determinants. Chapters 1–3 first build intuition for sets, vectors, and matrices as transformations; Chapter 4 makes the leap from the concrete to the abstract; Chapters 5–7 build on this foundation to treat block matrices, systems of equations, and determinants; and Chapters 8–11 go deeper into the internal structure of matrices and connect it to contemporary applications such as quantum mechanics and data science.

Some section titles carry a reading-priority mark: ◇ marks optional extensions, which can be skipped without affecting the main line; ◆ marks advanced material or proofs, where on a first reading you may grasp the conclusion and come back to the derivation later.

Comparison with Existing Textbooks

FeatureThis bookTraditional textbooks3Blue1BrownAxler, Linear Algebra Done Right
Starting pointLinear mappings and geometric intuitionSystems of linear equations / determinantsLinear mappings and geometric intuitionLinear mappings
ProgrammingDeeply integrated PythonLittle or noneUsed only for animationNone
3D geometryIntroduced earlyLater or not emphasizedLimitedLimited
ApplicationsThroughout the bookMostly supplementaryFewMainly theoretical
Abstract spacesFrom concrete to abstractMuch computation, little abstractionMainly concrete geometryAbstract and rigorous
InteractivityInteractive Jupyter environmentStaticAnimated videosStatic

Suggested Learning Paths

Classroom teaching. A standard one-semester course can cover Chapters 1–8 and selected parts of Chapters 9–11; a two-semester course can cover the whole book and add the experiments and projects.

Self-study. Readers who want to build a solid foundation should first read Chapters 1–5 in full and then choose later chapters according to their interests. Readers oriented toward applications can go directly to Chapters 8 and 11 after Chapters 1–3, together with the corresponding experiments. Readers oriented toward theory should read Chapters 1–9 in order before moving on to Chapters 10 and 11.

ChaptersEstimated study timeDifficultyRole
1–32–3 weeks★★☆☆☆Core
4–63–4 weeks★★★☆☆Core
7–83–4 weeks★★★★☆Core
92 weeks★★★★☆Core / extension
10–113–4 weeks★★★★★Applications

Notation and Conventions

The notation used in the book is collected in full in the Table of Common Notations. Before reading, please note the following points in particular:

Working Environment

The book is written as Jupyter notebooks (.ipynb), with the text in MyST Markdown, and is compiled into a website with Jupyter Book. We recommend the following ways to use it:

For the source files and environment setup, see the book’s GitHub repository.

After This Book

After reading this book, readers should understand the geometric meaning of the core concepts of linear algebra, be able to implement basic algorithms themselves and analyze their behavior, and be able to apply this framework to fields such as data science (PCA, SVD, least squares), machine learning (recommender systems, matrix factorization), computer graphics (rotations, projections, and other transformations), quantum computing (quantum states and measurement), dynamical systems (difference and differential equations), and network analysis (PageRank).

Contributing and Feedback

This book is still being revised. If you find errors, have suggestions for improvement, or would like to share applications or further exercises, you are welcome to contact us through the Issues of the GitHub repository.

We believe that combining geometric intuition, theoretical rigor, computational methods, and real-world applications can make linear algebra both easy to understand and genuinely useful. Whether you are a beginner or a practitioner who wants to reorganize your knowledge, we hope this book offers you a new learning experience. Now, let us begin the journey.

Footnotes
  1. Peter D. Lax, Linear Algebra and Its Applications, 2nd ed., Wiley, 2007.