Module 02
Linear Algebra
How can we represent and transform high-dimensional information mathematically?
- lessons
- 25
- duration
- 39 h 15 min
- concepts
- 126
- available in English
- 25 / 25
- completed by you
0 of 25
Where it fits
Prerequisites
Overview
A complete journey through linear algebra, from the geometry of Ax to research frontiers: subspaces, orthogonality, spectral theory, the SVD, norms and conditioning, matrix calculus for backpropagation, tensors, and einsum. Each idea begins with geometric intuition and interactive figures, is then proved, and finally implemented from scratch in NumPy before using NumPy, SciPy, or PyTorch. The first six lessons are intensive reviews. The core and advanced lessons build the foundation needed to read research papers in deep learning, quantitative finance, and numerical methods.
Why it matters
At the computational level, every modern model is a chain of matrix products and tensor contractions, whether it is a GPT, AlphaZero's policy and value network, or a robot policy. The SVD, eigenvalues, and conditioning help explain why training diverges, why LoRA works, or why an asset covariance matrix is unreliable. Matrix calculus lets you derive and debug a new layer by hand, giving you the tools to design architectures as well as use them.
Lessons 25
- 01Vectors, linear combinations and the four faces of matrix multiplicationAn intensive review of vectors and matrices focused on interpreting products. Read Ax as a combination of columns and as a collection of dot products, and AB in four equivalent ways, including a sum of outer products that anticipates the SVD. Finish with the cost of product chains, a foundational performance decision in any model.
- 02Vector spaces, linear independence, bases and dimensionA rigorous review of abstract structure: vector spaces beyond Rⁿ (polynomials, matrices and functions), subspaces, independence, bases and dimension. Prove the Steinitz exchange lemma, which makes dimension well defined, and discuss why numerical independence is a matter of degree rather than yes or no.
- 03Linear maps: the matrix as a functionA matrix becomes a function that deforms space. Establish the correspondence between linear maps and matrices, composition as multiplication, inverses, change of basis and affine maps in homogeneous coordinates. The central idea is that one map has many matrices, and choosing a good basis simplifies the problem.
- 04Linear systems, Gaussian elimination and LU factorizationReview solving Ax = b with computation in mind: elimination is a product of elementary matrices, recorded as an LU factorization, and pivoting is essential. Derive reduced row echelon form to describe the general solution and explain why an inverse is not calculated to solve a system.
- 05Rank and the four fundamental subspacesThe complete map of a matrix: what it reaches (column space), what it destroys (null space), and how the four subspaces pair up with their dimensions. Prove row rank equals column rank and the rank–nullity theorem, and introduce CR factorization as a sum of rank-one matrices, leading to SVD and rank bottlenecks in deep learning.
- 06Determinants: signed volumeInterpret the determinant as a signed volume scale, characterize it axiomatically, derive the product rule and compute it stably with LU and logarithms. Explain why determinant size does not measure proximity to singularity, and connect it to Gaussian densities, normalizing flows and log-determinant derivatives.
- 07Inner products, norms and high-dimensional geometryFormalize geometry through abstract inner products, norms and their unit balls, Cauchy–Schwarz, orthogonality, complements and orthonormal bases. Explore the counterintuitive geometry of high dimensions, where random vectors are nearly orthogonal and norms concentrate, explaining design choices in embeddings and attention.
- 08Projections and least squaresWhen Ax = b has no solution, find the closest Ax: the orthogonal projection of b onto the column space. Derive projection matrices and normal equations geometrically and by calculus, connect the data-space and column-space views, and understand the numerical danger of AᵀA that motivates QR and SVD.
- 09Orthogonal matrices, Gram-Schmidt and QR factorizationOrthonormal bases simplify difficult problems and orthogonal matrices preserve geometry. Construct QR using classical and modified Gram–Schmidt and Householder reflections, measure how well each preserves orthogonality, and solve least squares without squaring the condition number.
- 10Eigenvalues and eigenvectorsDirections that a transformation only stretches reveal its structure. Define eigenvalues, eigenvectors, characteristic polynomials, multiplicities and defective matrices; interpret complex eigenvalues geometrically as rotations; and explain why practical algorithms do not compute them as polynomial roots.
- 11Diagonalization, matrix functions and linear dynamicsDiagonalization chooses a basis where a matrix acts coordinate by coordinate, enabling powers, exponentials and other matrix functions. Study discrete and continuous linear systems, spectral-radius stability and its limits for nonnormal matrices, and Jordan form for defective matrices. This underlies state-space models.
- 12Symmetric matrices, the spectral theorem and quadratic formsReal symmetric matrices such as covariances, Hessians, Gram matrices and Laplacians have real eigenvalues and orthonormal eigenbases. Prove the spectral theorem, classify quadratic forms, characterize eigenvalues with Rayleigh and Courant–Fischer, and study how perturbations affect eigenvalues and eigenvectors.
- 13Positive definite matrices, Gram matrices and CholeskyPositive definite matrices appear in covariances, kernels, metrics and Hessians at minima. Prove five equivalent tests, connect them to Gram matrices, use Cholesky factorization for testing and solving, and distinguish the symmetric square root from the triangular factor. Apply the factorization to multivariate Gaussian sampling.
- 14Block matrices, Schur complements and low-rank updatesBlock algebra underpins Gaussian conditioning, online regression, Kalman filters and Gaussian processes. Study block elimination, Schur complements, the Woodbury identity and the matrix determinant lemma, including when these save computation and when numerical errors matter.
- 15The singular value decompositionAny matrix, of any shape, is a rotation, an axiswise scaling and another rotation. Construct the SVD from the spectral theorem, interpret it geometrically, obtain paired orthonormal bases for the four fundamental subspaces, and derive the polar decomposition used to align point clouds. This is the central lesson of the module.
- 16Matrix norms and the condition numberDefine operator, Frobenius and Schatten norms, express them through singular values and use the condition number to bound the sensitivity of Ax = b. Connect norms to Lipschitz constants in networks, leaving detailed numerical error analysis to Module 09.
- 17Low-rank approximation and the Eckart-Young theoremImages, ratings, network weights and asset returns often contain less information than their dimensions suggest. Prove that truncated SVD is the best rank-k approximation, choose a rank based on energy or noise, and apply effective-rank measures to compression, denoising, total least squares and real model weights.
- 18Pseudoinverse, minimum-norm solutions and spectral filteringUnderstand the Moore–Penrose pseudoinverse, minimum-norm least squares, spectral regularization and gradient descent’s implicit bias.
- 19Tensors, broadcasting and einsumIn deep learning everything is a tensor: image batches (B, C, H, W), sequences (B, T, D) and per-head scores (B, H, T, T); shape errors are a major source of bugs. Connect the mathematical view (tensor products and multilinear maps) with computation (axes, reshape, broadcasting and contractions), and master einsum for expressing and reasoning about linear tensor operations.
- 20Kronecker products and tensor decompositionsKronecker products encode structure repeated along two axes and underpin preconditioners such as K-FAC and Shampoo; the vec trick works with them without materialization. Then explore tensor rank and CP and Tucker decompositions, including a memorable example: the minimum multiplications needed for matrix multiplication is a tensor's rank, the problem AlphaTensor tackled with an AlphaZero-style agent.
- 21Matrix calculus I: differentials and gradients with respect to matricesTraining differentiates scalar loss with respect to weight matrices, and doing so entry by entry does not scale to ideas or code. Introduce derivatives as linear maps, gradients defined by the Frobenius inner product, differential rules and the trace trick, eliminating layout-convention ambiguity. Verify every result numerically.
- 22Matrix calculus II: the matrix chain rule and backpropagation by handUnderstand exactly what loss.backward() computes: the chain rule between matrix spaces, why full Jacobians are never formed, and how vector-Jacobian products yield gradients for linear layers, nonlinearities, softmax and arbitrary contractions. Derive a complete batch-vectorized MLP by hand and write a PyTorch layer with custom backward.
- 23Structured matrices: Toeplitz, circulant and the Fourier transformConvolutions, filters, rotary positional encoding and state-space models are structured matrices; exploiting structure turns O(n²) into O(n log n). Study complex spaces and unitary matrices, the DFT as a unitary basis change, Toeplitz and circulant matrices and convolution as diagonalization, then structured families used in modern efficient models.
- 24Random matrices: the spectrum of noise, data and neural networksUnderstand random-matrix spectra, the Wigner and Marchenko–Pastur laws, BBP transitions, covariance cleaning and neural-network applications.
- 25Low rank and orthogonalization in modern deep learningConnect randomized SVD, singular-mode learning, low-rank optimizers, spectral steepest descent and Newton–Schulz orthogonalization.
Module capstone
Capstone: linear algebra from scratch and three real applications
Build a small library of your own containing LU with pivoting, Householder QR, Cholesky, symmetric eigenvalues by Jacobi iteration, and the one-sided Jacobi SVD. Test it against NumPy and study error as a function of the condition number. Then use it for three applications: (1) image compression and denoising with truncated SVD and the Gavish-Donoho threshold, (2) alignment of 3D point clouds with Kabsch and least-squares fitting with QR, and (3) an MLP trained with backpropagation derived by hand, written using einsum, and validated with gradient checks. Deliver a notebook that uses plots to explain where and why each algorithm loses precision. Optional local extension: compress the layers of a small GPT-2 on a GPU using SVD and measure perplexity.
Check what you already know
- Compute AB by columns, by rows, and as a sum of outer products, then choose the least expensive order for a chain of products
- Decide whether a set of vectors forms a basis for a subspace and find its dimension
- Write the matrix of a linear map in another basis and recognize similar matrices
- Solve a system by elimination with pivoting, obtain PA = LU, and describe the general solution
- Compute the rank of a matrix and bases for its four fundamental subspaces
- Interpret the determinant as oriented volume and compute it stably using LU
- Prove Cauchy-Schwarz and reason about orthogonal complements
- Formulate a least-squares problem as a projection and solve the normal equations
- Obtain a QR factorization using Householder reflections and use it for least squares
- Compute eigenvalues and eigenvectors of 2×2 and 3×3 matrices, including complex ones
- Diagonalize a matrix and compute Aᵏ and e^{tA}, reasoning about stability
- Classify a quadratic form using the spectral theorem and apply the Rayleigh quotient
- Determine whether a matrix is positive definite and compute its Cholesky factorization
- Use Schur complements and the Woodbury identity to invert block matrices
- Compute the SVD of a 2×2 matrix by hand and interpret it geometrically
- Compute matrix norms and the condition number, and bound the error in Ax = b
- Apply the Eckart-Young theorem to choose and assess a rank-k approximation
- Compute the pseudoinverse and the minimum-norm solution of an underdetermined system
- Write contractions using einsum and predict the shapes resulting from broadcasting
- Derive the gradient of a scalar loss with respect to a matrix using differentials
- Derive the backward pass of a linear layer and of softmax with cross-entropy by hand
References
- Introduction to Linear Algebra (6.ª edición)
- Linear Algebra Done Right (4.ª edición)
- Numerical Linear Algebra
- Matrix Computations (4.ª edición)
- Matrix Analysis (2.ª edición)
- Linear Algebra and Learning from Data
- Mathematics for Machine Learning
- MIT 18.06 Linear Algebra (primavera de 2010)
- MIT 18.065 Matrix Methods in Data Analysis, Signal Processing, and Machine Learning
- Essence of Linear Algebra