Type at least 2 letters. Enter opens the first result, Esc closes.

    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 jj is AejAe_j, and Ax=x1a1+⋯+xnanAx = x_1 a_1 + \dots + x_n a_n.
    • Span = everything reachable by combinations; basis = independent vectors that span; dimension = the size of a basis.
    • Rank = the number of independent directions that survive; rank⁡A+dim⁡N(A)=n\operatorname{rank} A + \dim N(A) = n.
    • u⊤v=∥u∥ ∥v∥cos⁡θu^\top v = \|u\|\,\|v\|\cos\theta: positive for acute angles, zero for perpendicular vectors, negative for obtuse angles.
    • An eigenvector stays on its own line: Av=λvAv = \lambda v. The eigenvalue λ\lambda can be negative, zero or complex.
    • det⁡A\det A is the signed volume factor; det⁡A=0\det A = 0 means a direction is lost and AA cannot be undone.
    • Every matrix has an SVD A=UΣV⊤A = U\Sigma V^\top: 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 x⊤Sx>0x^\top S x > 0 for all x≠0x \ne 0, that is, when all its eigenvalues are positive.

    01 Matrices as maps, span and basis

    • Column jj of AA is AejAe_j. The columns fix the whole linear map: Ax=x1a1+⋯+xnanAx = x_1 a_1 + \dots + x_n a_n.
    • A 2×22 \times 2 matrix can stretch, rotate, shear, reflect or flatten the plane. Parallel columns flatten it.
    • Span = all combinations. Independent = only the zero combination gives 00. Basis = independent and spanning. Dimension = size of any basis.
    • Test independence with the null space: the columns of VV are independent exactly when Vc=0Vc = 0 forces c=0c = 0.
    • More than mm vectors in Rm\mathbb{R}^m are always dependent; every basis of a subspace has the same size.
    • Four views of ABAB: entries (dot products), columns (AbjAb_j), rows (αi⊤B\alpha_i^\top B), and a sum of rank-1 outer products ∑kakβk⊤\sum_k a_k \beta_k^\top.

    02 Rank and the four subspaces

    • The rank of AA is dim⁡C(A)\dim C(A): the number of independent columns, which equals the number of pivots after elimination.
    • A basis of C(A)C(A) is the pivot columns of the original AA; a basis of the row space is the nonzero rows of the echelon form.
    • A=CRA = CR (CC = pivot columns of AA, RR = nonzero rows of rref⁡(A)\operatorname{rref}(A)), so row rank = column rank.
    • Rank–nullity: rank⁡(A)+dim⁡N(A)=n\operatorname{rank}(A) + \dim N(A) = n for an m×nm \times n matrix; the special solutions are a basis of N(A)N(A).
    • The four subspaces: C(A)C(A) (dim rr) and N(A⊤)N(A^\top) (dim m−rm - r) in Rm\mathbb{R}^m; C(A⊤)C(A^\top) (dim rr) and N(A)N(A) (dim n−rn - r) in Rn\mathbb{R}^n.
    • N(A)N(A) and C(A⊤)C(A^\top) are orthogonal complements in Rn\mathbb{R}^n; C(A)C(A) and N(A⊤)N(A^\top) are orthogonal complements in Rm\mathbb{R}^m.
    • Ax=bAx = b is solvable exactly when y⊤b=0y^\top b = 0 for every yy in the left null space N(A⊤)N(A^\top).
    • N(A⊤A)=N(A)N(A^\top A) = N(A), so rank⁡(A⊤A)=rank⁡(A)\operatorname{rank}(A^\top A) = \operatorname{rank}(A).

    03 Inverse, determinant and projection

    • A square matrix is invertible exactly when it loses no direction: N(A)={0}N(A) = \{0\} ⇔ rank⁡A=n\operatorname{rank} A = n ⇔ det⁡A≠0\det A \ne 0 ⇔ 0 is not an eigenvalue.
    • For square matrices one side is enough: BA=IBA = I implies AB=IAB = I. To solve Ax=bAx = b, factor and solve; do not form A−1A^{-1}.
    • det⁡A\det A is the signed volume factor of the map; elimination gives det⁡A=(−1)#exchanges×\det A = (-1)^{\#\text{exchanges}} \times (product of the pivots).
    • det⁡(AB)=det⁡Adet⁡B\det(AB) = \det A \det B, det⁡A=λ1⋯λn\det A = \lambda_1 \cdots \lambda_n and tr⁡A=λ1+⋯+λn\operatorname{tr} A = \lambda_1 + \dots + \lambda_n; a tiny determinant alone does not mean "nearly singular".
    • u⊤v=∥u∥∥v∥cos⁡θu^\top v = \|u\|\|v\|\cos\theta (length of uu times the signed shadow of vv), and Cauchy–Schwarz says ∣u⊤v∣≤∥u∥∥v∥|u^\top v| \le \|u\|\|v\|.
    • The projection of bb onto the line through aa is p=a⊤ba⊤a ap = \dfrac{a^\top b}{a^\top a}\,a; the error b−pb - p is perpendicular to aa.
    • The projection onto C(A)C(A) (independent columns) is p=Ax^p = A\hat x with A⊤Ax^=A⊤bA^\top A\hat x = A^\top b, so P=A(A⊤A)−1A⊤P = A(A^\top A)^{-1}A^\top, and P2=P=P⊤P^2 = P = P^\top.

    04 Orthogonal matrices and change of basis

    • Put the basis vectors as the columns of MM. Then x=Mcx = Mc and c=M−1xc = M^{-1}x: MM turns new coordinates into standard ones.
    • In the basis given by the columns of MM, the map AA has the matrix B=M−1AMB = M^{-1}AM. Read it from right to left: MM, then AA, then M−1M^{-1}.
    • Similar matrices share the characteristic polynomial, so the eigenvalues, trace and determinant; they also share the rank.
    • Similarity does not keep eigenvectors (vv becomes M−1vM^{-1}v), singular values or symmetry, and equal eigenvalues do not imply similarity (the shear and II).
    • An orthogonal QQ has Q⊤Q=IQ^\top Q = I, so Q−1=Q⊤Q^{-1} = Q^\top; it keeps dot products, lengths and angles. det⁡Q=±1\det Q = \pm 1, and every eigenvalue has ∣λ∣=1|\lambda| = 1.
    • Orthogonal does not mean rotation: det⁡Q=−1\det Q = -1 means the map contains a reflection.
    • A unitary UU has U∗U=IU^*U = I, with the conjugate transpose U∗U^*; the normalized DFT matrix is unitary.
    • Orthogonal factors keep singular values: σ(Q1AQ2)=σ(A)\sigma(Q_1AQ_2) = \sigma(A) and κ2(Q)=1\kappa_2(Q) = 1, which is why stable algorithms are built from orthogonal steps.

    05 Eigenvalues and Jordan form

    • λ\lambda is an eigenvalue of AA exactly when A−λIA - \lambda I is singular, that is, det⁡(A−λI)=0\det(A - \lambda I) = 0; the eigenvectors are the nonzero vectors of N(A−λI)N(A - \lambda I).
    • For a 2×22 \times 2 matrix, p(λ)=λ2−(tr⁡A)λ+det⁡Ap(\lambda) = \lambda^2 - (\operatorname{tr}A)\lambda + \det A. In every size, the eigenvalues add up to the trace and multiply to the determinant.
    • A real matrix can have complex eigenvalues a±bia \pm bi; for a 2×22 \times 2 matrix this means a rotation by θ\theta and a scaling by ∣λ∣=det⁡A|\lambda| = \sqrt{\det A} in a suitable real basis, so no real direction is kept.
    • A=XΛX−1A = X\Lambda X^{-1} exactly when AA has nn independent eigenvectors; then Ak=XΛkX−1A^k = X\Lambda^kX^{-1}. Distinct eigenvalues are enough for this.
    • Power iteration converges to the dominant eigenvector line with error of order ∣λ2/λ1∣k|\lambda_2/\lambda_1|^k, using only products with AA.
    • Geometric multiplicity g(λ)=n−rank⁡(A−λI)g(\lambda) = n - \operatorname{rank}(A - \lambda I) is at most the algebraic multiplicity a(λ)a(\lambda); AA is defective when g<ag < a for some λ\lambda, like the shear.
    • A Jordan block λI+N\lambda I + N has one eigenvector line; its powers contain the growing term kλk−1k\lambda^{k-1}. 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 S=QΛQ⊤=∑iλiqiqi⊤S = Q\Lambda Q^\top = \sum_i \lambda_i q_iq_i^\top with QQ orthogonal and Λ\Lambda real.
    • A symmetric matrix has real eigenvalues; for 2×22\times2 the discriminant is (a−c)2+4b2≥0(a - c)^2 + 4b^2 \ge 0. Eigenvectors of different eigenvalues are orthogonal.
    • A symmetric matrix always has nn orthonormal eigenvectors: if Sq1=λ1q1Sq_1 = \lambda_1 q_1, then SS maps q1⊥q_1^\perp into itself, and the argument repeats in one dimension less.
    • The Rayleigh quotient R(x)=x⊤Sx/x⊤xR(x) = x^\top Sx / x^\top x is a weighted average of the eigenvalues, so λmin⁡≤R(x)≤λmax⁡\lambda_{\min} \le R(x) \le \lambda_{\max}, with the max and min at the extreme eigenvectors.
    • The critical points of RR are exactly the eigenvectors; middle eigenvectors are saddle points.
    • Courant–Fischer: λk=max⁡dim⁡U=kmin⁡x∈UR(x)\lambda_k = \max_{\dim U = k} \min_{x \in U} R(x), the best weakest value of RR over kk-dimensional subspaces.
    • Weyl: for symmetric AA and EE, ∣λk(A+E)−λk(A)∣≤∥E∥2|\lambda_k(A + E) - \lambda_k(A)| \le \|E\|_2. Without symmetry, eigenvalues can move like ∥E∥2\sqrt{\|E\|_2}.

    07 Positive definite matrices and Cholesky

    • A symmetric SS is positive definite when x⊤Sx>0x^\top S x > 0 for every x≠0x \ne 0, that is, when all its eigenvalues are positive; PSD allows ≥0\ge 0.
    • Five equivalent PD tests: all eigenvalues >0> 0; energy >0> 0; S=A⊤AS = A^\top A with independent columns; all leading minors >0> 0; all pivots >0> 0. The pivots are dk=Dk/Dk−1d_k = D_k / D_{k-1}.
    • Leading minors ≥0\ge 0 do not prove PSD; PSD needs all principal minors ≥0\ge 0 (counterexample diag⁡(0,−1)\operatorname{diag}(0, -1)).
    • Every covariance and every Gram matrix ΦΦ⊤\Phi\Phi^\top is PSD, because w⊤Σw=Var⁡(w⊤x)≥0w^\top \Sigma w = \operatorname{Var}(w^\top x) \ge 0 and c⊤ΦΦ⊤c=∥Φ⊤c∥2≥0c^\top \Phi\Phi^\top c = \|\Phi^\top c\|^2 \ge 0.
    • Cholesky S=LL⊤S = LL^\top (LL lower triangular, positive diagonal) exists and is unique exactly when S≻0S \succ 0; its radicands are the pivots, and it costs n3/3n^3/3 flops.
    • If z∼N(0,I)z \sim \mathcal N(0, I), then μ+Lz∼N(μ,LL⊤)\mu + Lz \sim \mathcal N(\mu, LL^\top); any MM with MM⊤=SMM^\top = S gives the same distribution.
    • Schur test: (ABB⊤C)≻0  ⟺  A≻0\begin{pmatrix} A & B \\ B^\top & C \end{pmatrix} \succ 0 \iff A \succ 0 and C−B⊤A−1B≻0C - B^\top A^{-1}B \succ 0; the Schur complement is the covariance of a Gaussian conditional.
    • The Loewner order A⪯BA \preceq B (B−A⪰0B - A \succeq 0) is a partial order, not a total one: diag⁡(2,1)\operatorname{diag}(2,1) and diag⁡(1,2)\operatorname{diag}(1,2) are incomparable.

    08 The SVD

    • Every real m×nm \times n matrix has an SVD A=UΣV⊤A = U\Sigma V^\top: UU and VV orthogonal, Σ\Sigma diagonal with σ1≥σ2≥⋯≥0\sigma_1 \ge \sigma_2 \ge \dots \ge 0, and Avi=σiuiAv_i = \sigma_i u_i.
    • The σi2\sigma_i^2 are the eigenvalues of A⊤AA^\top A; the viv_i are its eigenvectors, and ui=Avi/σiu_i = Av_i/\sigma_i. The number of nonzero σi\sigma_i is the rank.
    • The SVD gives orthonormal bases of all four subspaces, ∥A∥2=σ1\|A\|_2 = \sigma_1 and ∥A∥F=∑iσi2\|A\|_F = \sqrt{\sum_i \sigma_i^2}.
    • Eckart–Young–Mirsky: the truncated SVD Ak=∑i≤kσiuivi⊤A_k = \sum_{i \le k}\sigma_i u_i v_i^\top is a best approximation of rank at most kk, with error σk+1\sigma_{k+1} in the spectral norm and ∑i>kσi2\sqrt{\sum_{i>k}\sigma_i^2} in the Frobenius norm.
    • Polar decomposition: A=QPA = QP with Q=UV⊤Q = UV^\top (the nearest orthogonal matrix) and P=VΣV⊤=(A⊤A)1/2P = V\Sigma V^\top = (A^\top A)^{1/2}.
    • Pseudoinverse: A+=VΣ+U⊤A^+ = V\Sigma^+U^\top, and A+bA^+b is the least-squares solution with the smallest norm. In floating point, treat tiny σi\sigma_i as zero (rcond).
    • Compute the SVD from AA itself, never from A⊤AA^\top A: forming A⊤AA^\top A squares the condition number.

    09 PCA and randomized SVD

    • PC1 is the unit vector ww that maximizes the variance w⊤Sww^\top S w of the projected, centered data. It is the top eigenvector of S=Xc⊤Xc/(N−1)S = X_c^\top X_c/(N-1), and the maximum variance is λ1\lambda_1.
    • With samples as rows and Xc=UΣV⊤X_c = U\Sigma V^\top: the principal directions are the columns of VV, the variances are λi=σi2/(N−1)\lambda_i = \sigma_i^2/(N-1), and the scores are XcV=UΣX_cV = U\Sigma.
    • Maximum captured variance = minimum reconstruction error. The best kk-dimensional subspace is spanned by the top kk right singular vectors, with error ∑j>kσj2\sum_{j>k}\sigma_j^2.
    • Always center: without centering, the top direction turns toward the mean. NN samples give at most N−1N - 1 components with nonzero variance.
    • PCA is not scale invariant: standardize features that have different units.
    • Use the SVD of XcX_c rather than the covariance when accuracy matters or when d≫Nd \gg N: forming Xc⊤XcX_c^\top X_c squares the condition number.
    • Randomized SVD: Y=AΩY = A\Omega with ℓ=k+p\ell = k + p Gaussian columns, Q=orth⁡(Y)Q = \operatorname{orth}(Y), B=Q⊤AB = Q^\top A, a small SVD of BB, then U=QU~U = Q\tilde U. It reads AA in 2q+22q + 2 passes.
    • Oversampling (p≈5p \approx 5–1010) protects against unlucky random vectors; power iterations (q=1q = 1–22, with a QR after each product) help when the spectrum decays slowly.

    10 Factorizations and LU

    • A factorization writes AA as a product of triangular, orthogonal or diagonal matrices: factor once (about n3n^3 flops), then each use costs about n2n^2.
    • PA=LUPA = LU records Gaussian elimination: PP the row swaps, UU the upper-triangular result with the pivots on its diagonal, LL the multipliers ℓij\ell_{ij} in their positions.
    • The multipliers go into LL unchanged because each pivot row is already final: row ii of AA = row ii of UU + ∑j<iℓij\sum_{j<i} \ell_{ij} (row jj of UU).
    • Partial pivoting picks the largest ∣aik∣|a_{ik}| as pivot, so ∣ℓij∣≤1|\ell_{ij}| \le 1; it makes LU work for every square matrix and keeps it accurate in practice.
    • Never form A−1A^{-1} to solve Ax=bAx = b: LU costs 23n3\tfrac23 n^3 once and 2n22n^2 per right-hand side, the inverse about 2n32n^3 and gives less accurate answers. Cholesky costs 13n3\tfrac13 n^3.
    • Every matrix has an SVD; A=XΛX−1A = X\Lambda X^{-1} needs nn independent eigenvectors; QΛQ⊤Q\Lambda Q^\top needs symmetry; least squares uses QR.
    • Woodbury: (A+UCV)−1=A−1−A−1U(C−1+VA−1U)−1VA−1(A + UCV)^{-1} = A^{-1} - A^{-1}U(C^{-1} + VA^{-1}U)^{-1}VA^{-1} updates an inverse after a rank-kk change with a k×kk\times k inverse; it turns d×dd\times d ridge into an n×nn\times n solve.
    • Each general factorization of an n×nn\times n matrix has n2n^2 free parameters, each symmetric one n(n+1)/2n(n+1)/2.

    11 Norms of vectors and matrices

    • A norm satisfies three rules: ∥x∥=0\|x\| = 0 only for x=0x = 0, ∥cx∥=∣c∣ ∥x∥\|cx\| = |c|\,\|x\|, and the triangle inequality. ℓp\ell_p is a norm for p≥1p \ge 1; ℓp\ell_p with p<1p < 1 and the count "ℓ0\ell_0" are not.
    • For every vector, ∥x∥∞≤∥x∥2≤∥x∥1≤n ∥x∥2\|x\|_\infty \le \|x\|_2 \le \|x\|_1 \le \sqrt n\,\|x\|_2.
    • ℓ1\ell_1 gives exact zeros: the ℓ1\ell_1 ball has corners on the axes, and soft-thresholding Sλ(z)=sign⁡(z)max⁡(∣z∣−λ,0)S_\lambda(z) = \operatorname{sign}(z)\max(|z| - \lambda, 0) sets every ∣z∣≤λ|z| \le \lambda to 0. Ridge only shrinks: z/(1+λ)z/(1 + \lambda).
    • The spectral, Frobenius and nuclear norms are the ℓ∞\ell_\infty, ℓ2\ell_2 and ℓ1\ell_1 norms of the singular values: σ1\sigma_1, ∑iσi2\sqrt{\sum_i\sigma_i^2} and ∑iσi\sum_i\sigma_i (Schatten p=∞,2,1p = \infty, 2, 1).
    • The induced norms ∥A∥1\|A\|_1 and ∥A∥∞\|A\|_\infty are the largest absolute column sum and the largest absolute row sum. Frobenius and nuclear norms are not induced, because ∥In∥F=n≠1\|I_n\|_F = \sqrt n \ne 1.
    • The Lipschitz constant of x↦Wxx \mapsto Wx is σ1(W)\sigma_1(W). For a network with 1-Lipschitz activations, ∏l∥Wl∥2\prod_l\|W_l\|_2 is an upper bound, often loose; spectral normalization divides each WlW_l by an estimate of σ1\sigma_1.
    • 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 min⁡x∥Ax−b∥2\min_x\|Ax - b\|_2 is the orthogonal projection of bb onto C(A)C(A): the residual satisfies A⊤(b−Ax^)=0A^\top(b - A\hat x) = 0 (the normal equations).
    • Every AA with independent columns has a unique A=QRA = QR with Q⊤Q=IQ^\top Q = I and RR upper triangular with positive diagonal. Gram–Schmidt builds it: rjk=qj⊤akr_{jk} = q_j^\top a_k, vk=ak−∑j<krjkqjv_k = a_k - \sum_{j<k} r_{jk}q_j, rkk=∥vk∥r_{kk} = \|v_k\|, qk=vk/rkkq_k = v_k/r_{kk}.
    • With A=QRA = QR, least squares is one back substitution: Rx^=Q⊤bR\hat x = Q^\top b.
    • The normal equations square the condition number, κ(A⊤A)=κ(A)2\kappa(A^\top A) = \kappa(A)^2, so their error is about εκ2\varepsilon\kappa^2; Householder QR gives about εκ\varepsilon\kappa.
    • Loss of orthogonality ∥Q⊤Q−I∥\|Q^\top Q - I\|: about εκ2\varepsilon\kappa^2 for classical Gram–Schmidt, εκ\varepsilon\kappa for modified Gram–Schmidt, ε\varepsilon for Householder. A small ∥A−QR∥\|A - QR\| says nothing about it.
    • A Householder reflection H=I−2vv⊤/(v⊤v)H = I - 2vv^\top/(v^\top v) with v=x+sign⁡(x1)∥x∥e1v = x + \operatorname{sign}(x_1)\|x\|e_1 maps xx to −sign⁡(x1)∥x∥e1-\operatorname{sign}(x_1)\|x\|e_1 without cancellation; a Givens rotation zeros one chosen entry.
    • For an underdetermined full-row-rank system, the minimum-norm solution is x+=A⊤(AA⊤)−1b=A+bx^+ = A^\top(AA^\top)^{-1}b = A^+b, the only solution in the row space. For rank-deficient AA, use the SVD or column-pivoted QR.

    13 Floating point and conditioning

    • A binary float is ±(1.f)2×2e\pm(1.f)_2 \times 2^e with pp significant bits. The gap between neighbours grows with ∣x∣|x|, but rounding to nearest has relative error at most u=2−pu = 2^{-p} (2−53≈1.1×10−162^{-53} \approx 1.1\times10^{-16} in double).
    • Subtracting nearly equal rounded numbers amplifies their old errors by (∣x∣+∣y∣)/∣x−y∣(|x| + |y|)/|x - y| (catastrophic cancellation). The fix is a different formula: 2sin⁡2(x/2)2\sin^2(x/2), log1p, expm1, Vieta's formula, Welford's variance.
    • A running sum stops growing once half the gap at ss exceeds the term: in fp16 2048+1=20482048 + 1 = 2048, in bf16 256+1=256256 + 1 = 256. 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 6×10−86\times10^{-8}, so only fp16 needs loss scaling.
    • κ2(A)=σmax⁡/σmin⁡\kappa_2(A) = \sigma_{\max}/\sigma_{\min}, and ∥δx∥/∥x∥≤κ(A) ∥δb∥/∥b∥\|\delta x\|/\|x\| \le \kappa(A)\,\|\delta b\|/\|b\|; the bound is attained for bb along u1u_1 and δb\delta b along unu_n.
    • κ2(A⊤A)=κ2(A)2\kappa_2(A^\top A) = \kappa_2(A)^2: the normal equations lose twice as many digits as QR.
    • The backward error of x^\hat x is the smallest relative data change that makes x^\hat x exact; for Ax=bAx = b it is a relative residual. Forward error ≲κ×\lesssim \kappa \times backward error, so a backward-stable solver loses about log⁡10κ\log_{10}\kappa digits.

    14 Eigenvalue algorithms and Krylov methods

    • Inverse iteration with shift σ\sigma converges to the eigenvector whose eigenvalue is closest to σ\sigma, at the rate ∣λJ−σ∣/∣λK−σ∣|\lambda_J - \sigma|/|\lambda_K - \sigma|; Rayleigh quotient iteration updates the shift every step and converges cubically for symmetric AA.
    • The QR algorithm (Ak=QkRkA_k = Q_kR_k, Ak+1=RkQkA_{k+1} = R_kQ_k) is simultaneous power iteration: Ak=Q‾k⊤AQ‾kA_k = \underline Q_k^\top A\underline Q_k and Ak=Q‾kR‾kA^k = \underline Q_k\underline R_k. Without shifts, entry (j+1,j)(j+1, j) decays like ∣λj+1/λj∣k|\lambda_{j+1}/\lambda_j|^k.
    • Practical eigensolvers reduce once to Hessenberg (tridiagonal if symmetric) form, then use shifted QR steps (Wilkinson shift) with deflation; each step costs O(n2)O(n^2), or O(n)O(n) if tridiagonal.
    • The SVD is computed from a bidiagonal form (Golub–Kahan), never from eig⁡(A⊤A)\operatorname{eig}(A^\top A), which loses all singular values below about ε σ1\sqrt\varepsilon\,\sigma_1.
    • Arnoldi builds an orthonormal basis QkQ_k of Kk(A,b)=span⁡{b,Ab,…,Ak−1b}\mathcal K_k(A, b) = \operatorname{span}\{b, Ab, \dots, A^{k-1}b\} with AQk=Qk+1H~kAQ_k = Q_{k+1}\tilde H_k; for symmetric AA, HkH_k is tridiagonal (Lanczos). Ritz values converge to the extreme eigenvalues first.
    • CG minimizes ∥x−x∗∥A\|x - x^*\|_A over x0+Kkx_0 + \mathcal K_k; its error is pk(A)e0p_k(A)e_0 with pk(0)=1p_k(0) = 1, so ∥ek∥A/∥e0∥A≤2(κ−1κ+1)k\|e_k\|_A/\|e_0\|_A \le 2\big(\tfrac{\sqrt\kappa - 1}{\sqrt\kappa + 1}\big)^k: O(κ)O(\sqrt\kappa) iterations versus O(κ)O(\kappa) for steepest descent.
    • With dd distinct eigenvalues CG is exact after at most dd steps; clustered eigenvalues and preconditioning make it fast. GMRES minimizes ∥b−Ax∥2\|b - Ax\|_2 for any nonsingular AA but needs long recurrences.

    15 Autodiff, LoRA, tensors, attention

    • A JVP JvJv gives one column of the Jacobian and a VJP u⊤Ju^\top J gives one row. The full m×nm\times n Jacobian needs nn forward passes or mm 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 y=Wxy = Wx: xˉ=W⊤yˉ\bar x = W^\top\bar y and Wˉ=yˉx⊤\bar W = \bar yx^\top (rank 1); for a batch Y=WXY = WX, Wˉ=YˉX⊤\bar W = \bar YX^\top. Every gradient has the shape of its variable.
    • LoRA learns W0+αrBAW_0 + \tfrac{\alpha}{r}BA with r(d+k)r(d + k) trainable numbers; B=0B = 0 at the start, so training starts at W0W_0 and the update always has rank at most rr.
    • GaLore trains all weights but keeps Adam's state in a rank-rr subspace of the gradient that is refreshed every few hundred steps, so its total update can have full rank.
    • The mode-nn unfolding X(n)X_{(n)} has the mode-nn fibers as columns; the multilinear rank is (rank⁡X(1),rank⁡X(2),rank⁡X(3))(\operatorname{rank}X_{(1)}, \operatorname{rank}X_{(2)}, \operatorname{rank}X_{(3)}). A rank-RR CP model has R(I+J+K)R(I + J + K) parameters.
    • The truncated HOSVD (top singular vectors of each unfolding) is within a factor N\sqrt N of the best Tucker approximation; tensors have no Eckart–Young theorem.
    • An attention head has logits xi⊤WQKxj/dhx_i^\top W_{QK}x_j/\sqrt{d_h} and output WOVXA⊤W_{OV}XA^\top, where WQK=WQ⊤WKW_{QK} = W_Q^\top W_K and WOV=WOWVW_{OV} = W_OW_V have rank at most dhd_h; the attention matrix AA itself is usually full rank.

    16 Matrix calculus and matrix functions

    • The differential dfdf is the part of f(X+dX)−f(X)f(X + dX) - f(X) that is linear in dXdX. If df=tr⁡(G⊤dX)df = \operatorname{tr}(G^\top dX) for every dXdX, then ∇Xf=G\nabla_X f = G, a matrix with the shape of XX.
    • The product rule keeps the order: d(FG)=dF G+F dGd(FG) = dF\,G + F\,dG. So d(X−1)=−X−1 dX X−1d(X^{-1}) = -X^{-1}\,dX\,X^{-1}, not −X−2dX-X^{-2}dX.
    • Three gradients to know: ∇tr⁡(AX)=A⊤\nabla\operatorname{tr}(AX) = A^\top, ∇x⊤Ax=(A+A⊤)x\nabla x^\top Ax = (A + A^\top)x and ∇log⁡det⁡X=X−⊤\nabla\log\det X = X^{-\top} (from dlog⁡det⁡X=tr⁡(X−1dX)d\log\det X = \operatorname{tr}(X^{-1}dX)).
    • A correct derivative leaves an O(t2)O(t^2) error in f(X+t dX)≈f(X)+t dff(X + t\,dX) \approx f(X) + t\,df (slope 2 on a log–log plot); a wrong one leaves an O(t)O(t) error.
    • The softmax Jacobian is J=diag⁡(s)−ss⊤J = \operatorname{diag}(s) - ss^\top: symmetric, PSD, rows summing to 0, rank n−1n - 1. The cross-entropy gradient is s−eys - e_y, and the VJP costs O(n)O(n).
    • For a symmetric S=QΛQ⊤S = Q\Lambda Q^\top, f(S)=Qf(Λ)Q⊤f(S) = Qf(\Lambda)Q^\top: the function acts on the eigenvalues, not on the entries. eA+B=eAeBe^{A+B} = e^Ae^B holds when AB=BAAB = BA.
    • x′=Axx' = Ax has the unique solution x(t)=eAtx0x(t) = e^{At}x_0; it decays for every x0x_0 exactly when all Re⁡λi(A)<0\operatorname{Re}\lambda_i(A) < 0.
    • vec⁡(AXB)=(B⊤⊗A)vec⁡X\operatorname{vec}(AXB) = (B^\top\otimes A)\operatorname{vec}X; A⊗BA\otimes B has the eigenvalues λiμj\lambda_i\mu_j and the Kronecker sum A⊗I+I⊗BA\otimes I + I\otimes B has λi+μj\lambda_i + \mu_j.

    17 Perturbation theory

    • Weyl: for symmetric AA and EE, ∣λk(A+E)−λk(A)∣≤∥E∥2|\lambda_k(A + E) - \lambda_k(A)| \le \|E\|_2 for every kk. Symmetric eigenvalues have condition number 1.
    • Weyl for singular values: ∣σk(A+E)−σk(A)∣≤∥E∥2|\sigma_k(A + E) - \sigma_k(A)| \le \|E\|_2 for any matrices of the same shape; it follows from the symmetric embedding (0AA⊤0)\begin{pmatrix} 0 & A \\ A^\top & 0 \end{pmatrix}, whose eigenvalues are ±σi(A)\pm\sigma_i(A) and zeros.
    • Non-symmetric matrices have no such bound: Bauer–Fike allows κ(X)∥E∥2\kappa(X)\|E\|_2, and a perturbed n×nn\times n Jordan block moves its eigenvalues by ∥E∥21/n\|E\|_2^{1/n}.
    • Principal angles between subspaces: cos⁡θi=σi(V^⊤V)\cos\theta_i = \sigma_i(\hat V^\top V), and ∥sin⁡Θ∥2=∥VV⊤−V^V^⊤∥2\|\sin\Theta\|_2 = \|VV^\top - \hat V\hat V^\top\|_2. Two planes in R3\mathbb{R}^3 always have θ1=0\theta_1 = 0.
    • To first order, λk\lambda_k moves by qk⊤Eqkq_k^\top Eq_k and qkq_k mixes in qjq_j with weight qj⊤Eqk/(λk−λj)q_j^\top Eq_k/(\lambda_k - \lambda_j): the condition number of an eigenvector is 1/gap.
    • Davis–Kahan (Yu–Wang–Samworth form): sin⁡θ(q^k,qk)≤2∥E∥2/δk\sin\theta(\hat q_k, q_k) \le 2\|E\|_2/\delta_k, where δk\delta_k is the gap of λk\lambda_k to its neighbours in AA.
    • 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 x↦Gx/kx \mapsto Gx/\sqrt k keeps one squared length with relative error about 2/k\sqrt{2/k}, whatever the original dimension DD is.
    • Johnson–Lindenstrauss: k≥(4ln⁡n+2ln⁡(1/δ))/(ε2/2−ε3/3)k \ge (4\ln n + 2\ln(1/\delta))/(\varepsilon^2/2 - \varepsilon^3/3) Gaussian rows keep all squared pairwise distances of nn points within 1±ε1 \pm \varepsilon, with probability at least 1−δ1-\delta; kk does not depend on DD.
    • SS is an ε\varepsilon-subspace embedding for range⁡(U)\operatorname{range}(U) (UU orthonormal) exactly when ∥I−U⊤S⊤SU∥2≤ε\|I - U^\top S^\top SU\|_2 \le \varepsilon, that is, all singular values of SUSU lie in [1−ε,1+ε][\sqrt{1-\varepsilon}, \sqrt{1+\varepsilon}]; a dd-dimensional subspace needs about d/ε2d/\varepsilon^2 Gaussian rows.
    • Sketch-and-solve least squares gives a residual within (1+ε)/(1−ε)\sqrt{(1+\varepsilon)/(1-\varepsilon)} of the optimum, but x~\tilde x can be far from x∗x^* when AA is ill-conditioned.
    • Sketch-and-precondition uses SA=QRSA = QR to make κ(AR−1)≤(1+ε)/(1−ε)\kappa(AR^{-1}) \le \sqrt{(1+\varepsilon)/(1-\varepsilon)}; LSQR then reaches full accuracy in a few dozen iterations, whatever κ(A)\kappa(A) is.
    • For pure noise with variance σ2\sigma^2 and γ=p/n≤1\gamma = p/n \le 1, the eigenvalues of X⊤X/nX^\top X/n fill the Marchenko–Pastur support [σ2(1−γ)2,σ2(1+γ)2][\sigma^2(1-\sqrt\gamma)^2, \sigma^2(1+\sqrt\gamma)^2], although every true eigenvalue is σ2\sigma^2.
    • A spike θ\theta is visible to PCA only if θ>γ\theta > \sqrt\gamma (BBP transition); then the top eigenvalue tends to σ2(1+θ)(1+γ/θ)\sigma^2(1+\theta)(1+\gamma/\theta), which overestimates the true variance, and the eigenvector is tilted.
    • In Rd\mathbb{R}^d, random Gaussian vectors have norm ≈d\approx \sqrt d and random directions are at 90°90° up to about 57.3°/d57.3°/\sqrt d; this allows many more almost-orthogonal directions than dd (superposition).

    19 Structured matrices in ML

    • A circulant C(c)C(c) is diagonalized by the DFT: Cfk=c^kfkCf_k = \hat c_k f_k with c^=fft(c)\hat c = \mathrm{fft}(c), so a circular convolution costs O(nlog⁡n)O(n\log n) 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 kmax⁡k_{\max} modes; its kmax⁡dv2k_{\max}d_v^2 complex weights do not depend on the grid size nn, so it can run on any uniform grid that resolves the input.
    • The graph Laplacian L=D−AL = D - A is PSD with x⊤Lx=∑edgesAij(xi−xj)2x^\top Lx = \sum_{\text{edges}} A_{ij}(x_i - x_j)^2; the multiplicity of the eigenvalue 0 is the number of connected components, and the signs of the Fiedler vector u2u_2 split the graph.
    • GCN: a first-order Chebyshev filter with λmax⁡≈2\lambda_{\max} \approx 2, one parameter and the renormalization trick gives H′=σ(A^HW)H' = \sigma(\hat AHW) with A^=D~−1/2(A+I)D~−1/2\hat A = \tilde D^{-1/2}(A+I)\tilde D^{-1/2}, whose eigenvalues lie in (−1,1](-1, 1]; many layers over-smooth.
    • ff is equivariant when f(ρ(g)x)=ρ′(g)f(x)f(\rho(g)x) = \rho'(g)f(x); equivariant linear maps form a null space, for example aI+b11⊤aI + b\mathbf 1\mathbf 1^\top for permutations of Rn\mathbb{R}^n.
    • St⁡(n,p)={X:X⊤X=Ip}\operatorname{St}(n, p) = \{X : X^\top X = I_p\} has dimension np−p(p+1)/2np - p(p+1)/2; a Riemannian gradient step projects the gradient onto the tangent space and then retracts (normalize for p=1p = 1, QR or polar factor in general).
    • Gr⁡(n,p)=St⁡(n,p)/O(p)\operatorname{Gr}(n, p) = \operatorname{St}(n, p)/O(p) is the set of pp-dimensional subspaces, of dimension p(n−p)p(n-p); PCA is an optimization problem on it.