PAITS Cheat Sheet Mathematics & ML Advanced Updated 2026-10-23

Linear Algebra for Machine Learning: SVD, Eigenvalues & Matrix Calculus

Spectral Theorem, Singular Value Decomposition (SVD), PCA, LoRA low-rank adaptation, and Jacobian/Hessian identities.

Executive Summary: Essential mathematical reference connecting matrix factorizations (Eigen-decomposition, SVD, Cholesky) to Principal Component Analysis (PCA), Low-Rank Adaptation (LoRA), and gradient backpropagation.

Key Equations & Invariants

Singular Value Decomposition (SVD)
A = U \Sigma V^\top = \sum_{i=1}^{r} \sigma_i u_i v_i^\top

Every m x n matrix A decomposes into orthogonal U (m x m), diagonal singular values Sigma >= 0, and orthogonal V (n x n).

Eckart-Young-Mirsky Best Rank-k Approximation
A_k = \arg\min_{\text{rank}(B)=k} \|A - B\|_F = \sum_{i=1}^{k} \sigma_i u_i v_i^\top

Truncating SVD to top-k singular values minimizes Frobenius and spectral reconstruction error.

LoRA (Low-Rank Adaptation) Weight Update
W = W_0 + \Delta W = W_0 + \frac{\alpha}{r} B A, \quad B \in \mathbb{R}^{d \times r},\; A \in \mathbb{R}^{r \times k},\; r \ll \min(d, k)

Freezes pretrained W_0 and trains rank-r matrices A and B, cutting trainable parameters by >99%.

1. Matrix Decompositions & ML Applications

For centered data matrix $X \in \mathbb{R}^{n \times d}$, the sample covariance matrix is $C = \frac{1}{n-1}X^\top X$. Computing PCA via the thin SVD $X = U \Sigma V^\top$ avoids forming $X^\top X$ explicitly, squaring the condition number $\kappa(X^\top X) = \kappa(X)^2$.

DecompositionFormulaMatrix RequirementPrimary ML Use Case
Spectral (Eigen)A = Q Lambda Q^TReal symmetric (A = A^T)Covariance matrices, Graph Laplacians
SVDA = U Sigma V^TAny m x n rectangular matrixPCA, Moore-Penrose Pseudoinverse, Recommender Systems
CholeskyA = L L^TSymmetric Positive Definite (SPD)Gaussian Processes, Multivariate Normal sampling
QR FactorizationA = Q RFull column rank m >= nNumerically stable Ordinary Least Squares (OLS)

Common Production & Interview Pitfalls

Frequently Asked Questions

Q: How are singular values of X related to the eigenvalues of X^T X?

The non-zero singular values sigma_i of X are the exact square roots of the non-zero eigenvalues lambda_i of X^T X (sigma_i = sqrt(lambda_i)), and the right singular vectors V are the eigenvectors of X^T X.