Quick recap
The key takeaways of every lesson on one page. Read it in ten minutes to refresh the whole track; open a lesson when a point feels unclear.
00 Linear algebra in plain words
- A matrix moves space. Its column is , and .
- Span = everything reachable by combinations; basis = independent vectors that span; dimension = the size of a basis.
- Rank = the number of independent directions that survive; .
- : positive for acute angles, zero for perpendicular vectors, negative for obtuse angles.
- An eigenvector stays on its own line: . The eigenvalue can be negative, zero or complex.
- is the signed volume factor; means a direction is lost and cannot be undone.
- Every matrix has an SVD : rotate or reflect, stretch by the singular values, rotate or reflect. Singular values are not eigenvalues in general.
- PCA is the SVD of the centered data matrix; a symmetric matrix is positive definite when for all , that is, when all its eigenvalues are positive.
01 Matrices as maps, span and basis
- Column of is . The columns fix the whole linear map: .
- A matrix can stretch, rotate, shear, reflect or flatten the plane. Parallel columns flatten it.
- Span = all combinations. Independent = only the zero combination gives . Basis = independent and spanning. Dimension = size of any basis.
- Test independence with the null space: the columns of are independent exactly when forces .
- More than vectors in are always dependent; every basis of a subspace has the same size.
- Four views of : entries (dot products), columns (), rows (), and a sum of rank-1 outer products .
02 Rank and the four subspaces
- The rank of is : the number of independent columns, which equals the number of pivots after elimination.
- A basis of is the pivot columns of the original ; a basis of the row space is the nonzero rows of the echelon form.
- ( = pivot columns of , = nonzero rows of ), so row rank = column rank.
- Rank–nullity: for an matrix; the special solutions are a basis of .
- The four subspaces: (dim ) and (dim ) in ; (dim ) and (dim ) in .
- and are orthogonal complements in ; and are orthogonal complements in .
- is solvable exactly when for every in the left null space .
- , so .
03 Inverse, determinant and projection
- A square matrix is invertible exactly when it loses no direction: ⇔ ⇔ ⇔ 0 is not an eigenvalue.
- For square matrices one side is enough: implies . To solve , factor and solve; do not form .
- is the signed volume factor of the map; elimination gives (product of the pivots).
- , and ; a tiny determinant alone does not mean "nearly singular".
- (length of times the signed shadow of ), and Cauchy–Schwarz says .
- The projection of onto the line through is ; the error is perpendicular to .
- The projection onto (independent columns) is with , so , and .
04 Orthogonal matrices and change of basis
- Put the basis vectors as the columns of . Then and : turns new coordinates into standard ones.
- In the basis given by the columns of , the map has the matrix . Read it from right to left: , then , then .
- Similar matrices share the characteristic polynomial, so the eigenvalues, trace and determinant; they also share the rank.
- Similarity does not keep eigenvectors ( becomes ), singular values or symmetry, and equal eigenvalues do not imply similarity (the shear and ).
- An orthogonal has , so ; it keeps dot products, lengths and angles. , and every eigenvalue has .
- Orthogonal does not mean rotation: means the map contains a reflection.
- A unitary has , with the conjugate transpose ; the normalized DFT matrix is unitary.
- Orthogonal factors keep singular values: and , which is why stable algorithms are built from orthogonal steps.
05 Eigenvalues and Jordan form
- is an eigenvalue of exactly when is singular, that is, ; the eigenvectors are the nonzero vectors of .
- For a matrix, . In every size, the eigenvalues add up to the trace and multiply to the determinant.
- A real matrix can have complex eigenvalues ; for a matrix this means a rotation by and a scaling by in a suitable real basis, so no real direction is kept.
- exactly when has independent eigenvectors; then . Distinct eigenvalues are enough for this.
- Power iteration converges to the dominant eigenvector line with error of order , using only products with .
- Geometric multiplicity is at most the algebraic multiplicity ; is defective when for some , like the shear.
- A Jordan block has one eigenvector line; its powers contain the growing term . The Jordan form jumps under tiny perturbations, so libraries use the Schur form.
06 Spectral theorem and Rayleigh quotient
- Spectral theorem: a real matrix is symmetric exactly when with orthogonal and real.
- A symmetric matrix has real eigenvalues; for the discriminant is . Eigenvectors of different eigenvalues are orthogonal.
- A symmetric matrix always has orthonormal eigenvectors: if , then maps into itself, and the argument repeats in one dimension less.
- The Rayleigh quotient is a weighted average of the eigenvalues, so , with the max and min at the extreme eigenvectors.
- The critical points of are exactly the eigenvectors; middle eigenvectors are saddle points.
- Courant–Fischer: , the best weakest value of over -dimensional subspaces.
- Weyl: for symmetric and , . Without symmetry, eigenvalues can move like .
07 Positive definite matrices and Cholesky
- A symmetric is positive definite when for every , that is, when all its eigenvalues are positive; PSD allows .
- Five equivalent PD tests: all eigenvalues ; energy ; with independent columns; all leading minors ; all pivots . The pivots are .
- Leading minors do not prove PSD; PSD needs all principal minors (counterexample ).
- Every covariance and every Gram matrix is PSD, because and .
- Cholesky ( lower triangular, positive diagonal) exists and is unique exactly when ; its radicands are the pivots, and it costs flops.
- If , then ; any with gives the same distribution.
- Schur test: and ; the Schur complement is the covariance of a Gaussian conditional.
- The Loewner order () is a partial order, not a total one: and are incomparable.
08 The SVD
- Every real matrix has an SVD : and orthogonal, diagonal with , and .
- The are the eigenvalues of ; the are its eigenvectors, and . The number of nonzero is the rank.
- The SVD gives orthonormal bases of all four subspaces, and .
- Eckart–Young–Mirsky: the truncated SVD is a best approximation of rank at most , with error in the spectral norm and in the Frobenius norm.
- Polar decomposition: with (the nearest orthogonal matrix) and .
- Pseudoinverse: , and is the least-squares solution with the smallest norm. In floating point, treat tiny as zero (
rcond). - Compute the SVD from itself, never from : forming squares the condition number.
09 PCA and randomized SVD
- PC1 is the unit vector that maximizes the variance of the projected, centered data. It is the top eigenvector of , and the maximum variance is .
- With samples as rows and : the principal directions are the columns of , the variances are , and the scores are .
- Maximum captured variance = minimum reconstruction error. The best -dimensional subspace is spanned by the top right singular vectors, with error .
- Always center: without centering, the top direction turns toward the mean. samples give at most components with nonzero variance.
- PCA is not scale invariant: standardize features that have different units.
- Use the SVD of rather than the covariance when accuracy matters or when : forming squares the condition number.
- Randomized SVD: with Gaussian columns, , , a small SVD of , then . It reads in passes.
- Oversampling (–) protects against unlucky random vectors; power iterations (–, with a QR after each product) help when the spectrum decays slowly.
10 Factorizations and LU
- A factorization writes as a product of triangular, orthogonal or diagonal matrices: factor once (about flops), then each use costs about .
- records Gaussian elimination: the row swaps, the upper-triangular result with the pivots on its diagonal, the multipliers in their positions.
- The multipliers go into unchanged because each pivot row is already final: row of = row of + (row of ).
- Partial pivoting picks the largest as pivot, so ; it makes LU work for every square matrix and keeps it accurate in practice.
- Never form to solve : LU costs once and per right-hand side, the inverse about and gives less accurate answers. Cholesky costs .
- Every matrix has an SVD; needs independent eigenvectors; needs symmetry; least squares uses QR.
- Woodbury: updates an inverse after a rank- change with a inverse; it turns ridge into an solve.
- Each general factorization of an matrix has free parameters, each symmetric one .
11 Norms of vectors and matrices
- A norm satisfies three rules: only for , , and the triangle inequality. is a norm for ; with and the count "" are not.
- For every vector, .
- gives exact zeros: the ball has corners on the axes, and soft-thresholding sets every to 0. Ridge only shrinks: .
- The spectral, Frobenius and nuclear norms are the , and norms of the singular values: , and (Schatten ).
- The induced norms and are the largest absolute column sum and the largest absolute row sum. Frobenius and nuclear norms are not induced, because .
- The Lipschitz constant of is . For a network with 1-Lipschitz activations, is an upper bound, often loose; spectral normalization divides each by an estimate of .
- The rank is not convex; the nuclear norm is its standard convex surrogate, and singular value soft-thresholding gives low rank.
12 QR and least squares
- Least squares is the orthogonal projection of onto : the residual satisfies (the normal equations).
- Every with independent columns has a unique with and upper triangular with positive diagonal. Gram–Schmidt builds it: , , , .
- With , least squares is one back substitution: .
- The normal equations square the condition number, , so their error is about ; Householder QR gives about .
- Loss of orthogonality : about for classical Gram–Schmidt, for modified Gram–Schmidt, for Householder. A small says nothing about it.
- A Householder reflection with maps to without cancellation; a Givens rotation zeros one chosen entry.
- For an underdetermined full-row-rank system, the minimum-norm solution is , the only solution in the row space. For rank-deficient , use the SVD or column-pivoted QR.
13 Floating point and conditioning
- A binary float is with significant bits. The gap between neighbours grows with , but rounding to nearest has relative error at most ( in double).
- Subtracting nearly equal rounded numbers amplifies their old errors by (catastrophic cancellation). The fix is a different formula: ,
log1p,expm1, Vieta's formula, Welford's variance. - A running sum stops growing once half the gap at exceeds the term: in fp16 , in bf16 . So 16-bit training accumulates in fp32 and keeps fp32 master weights.
- bf16 has the range of fp32 but only 8 significant bits; fp16 has 11 bits but overflows above 65504 and underflows below about , so only fp16 needs loss scaling.
- , and ; the bound is attained for along and along .
- : the normal equations lose twice as many digits as QR.
- The backward error of is the smallest relative data change that makes exact; for it is a relative residual. Forward error backward error, so a backward-stable solver loses about digits.
14 Eigenvalue algorithms and Krylov methods
- Inverse iteration with shift converges to the eigenvector whose eigenvalue is closest to , at the rate ; Rayleigh quotient iteration updates the shift every step and converges cubically for symmetric .
- The QR algorithm (, ) is simultaneous power iteration: and . Without shifts, entry decays like .
- Practical eigensolvers reduce once to Hessenberg (tridiagonal if symmetric) form, then use shifted QR steps (Wilkinson shift) with deflation; each step costs , or if tridiagonal.
- The SVD is computed from a bidiagonal form (Golub–Kahan), never from , which loses all singular values below about .
- Arnoldi builds an orthonormal basis of with ; for symmetric , is tridiagonal (Lanczos). Ritz values converge to the extreme eigenvalues first.
- CG minimizes over ; its error is with , so : iterations versus for steepest descent.
- With distinct eigenvalues CG is exact after at most steps; clustered eigenvalues and preconditioning make it fast. GMRES minimizes for any nonsingular but needs long recurrences.
15 Autodiff, LoRA, tensors, attention
- A JVP gives one column of the Jacobian and a VJP gives one row. The full Jacobian needs forward passes or reverse passes.
- Reverse mode multiplies the chain of Jacobians starting at the output. For a scalar loss every intermediate result is a row vector, so one backward pass gives the whole gradient at a few times the cost of the forward pass; the price is the memory for the stored activations.
- For a linear layer : and (rank 1); for a batch , . Every gradient has the shape of its variable.
- LoRA learns with trainable numbers; at the start, so training starts at and the update always has rank at most .
- GaLore trains all weights but keeps Adam's state in a rank- subspace of the gradient that is refreshed every few hundred steps, so its total update can have full rank.
- The mode- unfolding has the mode- fibers as columns; the multilinear rank is . A rank- CP model has parameters.
- The truncated HOSVD (top singular vectors of each unfolding) is within a factor of the best Tucker approximation; tensors have no Eckart–Young theorem.
- An attention head has logits and output , where and have rank at most ; the attention matrix itself is usually full rank.
16 Matrix calculus and matrix functions
- The differential is the part of that is linear in . If for every , then , a matrix with the shape of .
- The product rule keeps the order: . So , not .
- Three gradients to know: , and (from ).
- A correct derivative leaves an error in (slope 2 on a log–log plot); a wrong one leaves an error.
- The softmax Jacobian is : symmetric, PSD, rows summing to 0, rank . The cross-entropy gradient is , and the VJP costs .
- For a symmetric , : the function acts on the eigenvalues, not on the entries. holds when .
- has the unique solution ; it decays for every exactly when all .
- ; has the eigenvalues and the Kronecker sum has .
17 Perturbation theory
- Weyl: for symmetric and , for every . Symmetric eigenvalues have condition number 1.
- Weyl for singular values: for any matrices of the same shape; it follows from the symmetric embedding , whose eigenvalues are and zeros.
- Non-symmetric matrices have no such bound: Bauer–Fike allows , and a perturbed Jordan block moves its eigenvalues by .
- Principal angles between subspaces: , and . Two planes in always have .
- To first order, moves by and mixes in with weight : the condition number of an eigenvector is 1/gap.
- Davis–Kahan (Yu–Wang–Samworth form): , where is the gap of to its neighbours in .
- For a block of eigenvectors only the gap between the block and the rest matters, so a cluster of close eigenvalues has a stable subspace but unstable single eigenvectors.
18 Sketching, JL and random matrices
- A Gaussian map keeps one squared length with relative error about , whatever the original dimension is.
- Johnson–Lindenstrauss: Gaussian rows keep all squared pairwise distances of points within , with probability at least ; does not depend on .
- is an -subspace embedding for ( orthonormal) exactly when , that is, all singular values of lie in ; a -dimensional subspace needs about Gaussian rows.
- Sketch-and-solve least squares gives a residual within of the optimum, but can be far from when is ill-conditioned.
- Sketch-and-precondition uses to make ; LSQR then reaches full accuracy in a few dozen iterations, whatever is.
- For pure noise with variance and , the eigenvalues of fill the Marchenko–Pastur support , although every true eigenvalue is .
- A spike is visible to PCA only if (BBP transition); then the top eigenvalue tends to , which overestimates the true variance, and the eigenvector is tilted.
- In , random Gaussian vectors have norm and random directions are at up to about ; this allows many more almost-orthogonal directions than (superposition).
19 Structured matrices in ML
- A circulant is diagonalized by the DFT: with , so a circular convolution costs with the FFT.
- A linear map commutes with the cyclic shift exactly when it is a circulant: shift-equivariant linear layers are circular convolutions.
- An FNO Fourier layer is a learned circulant truncated to modes; its complex weights do not depend on the grid size , so it can run on any uniform grid that resolves the input.
- The graph Laplacian is PSD with ; the multiplicity of the eigenvalue 0 is the number of connected components, and the signs of the Fiedler vector split the graph.
- GCN: a first-order Chebyshev filter with , one parameter and the renormalization trick gives with , whose eigenvalues lie in ; many layers over-smooth.
- is equivariant when ; equivariant linear maps form a null space, for example for permutations of .
- has dimension ; a Riemannian gradient step projects the gradient onto the tangent space and then retracts (normalize for , QR or polar factor in general).
- is the set of -dimensional subspaces, of dimension ; PCA is an optimization problem on it.