Linear Algebra
Reactivation sheet — results and the proofs whose tricks carry the subject. The organizing claim: every matrix is diagonal between the right pair of orthonormal bases (SVD). Everything before it is machinery needed to state and prove that; everything after is statistics cashing it in. The recurring workhorse is : it powers least squares, definiteness, and singular values.
1. Four ways to read , four subspaces
Four readings of matrix multiplication, each the right tool somewhere:
- Row picture: entry of is (row ) — the system is hyperplane constraints intersecting.
- Column picture: — a linear combination of columns with weights . This is the picture that generalizes: solvable ⟺ .
- Column-wise product: — apply to each column of .
- Outer-product sum: — a sum of rank-1 matrices. This view makes SVD’s natural before you ever see it.
Fundamental theorem. For with rank :
| Subspace | Lives in | Dim | Orthogonal complement of |
|---|---|---|---|
| Row space | |||
| Null space | |||
| Column space | |||
| Left null space |
Build it up:
- ⟺ ⟺ every row dots to zero against ⟺ row space. So — the orthogonality is nearly definitional.
- Apply the same statement to : .
- Row rank = column rank: one number sets all four dimensions. Rank–nullity is the bookkeeping: .
- Restricted to the row space, is a bijection onto the column space: injective because row space ∩ null space (they’re complements), surjective because dims match ( on both sides). The null space is what forgets; the left null space is what can’t reach.
- Elimination () computes as the pivot count and never changes — row operations are invertible, so solutions are preserved.
The picture to hold (and redraw cold): two panes. Left pane , split into row space (dim ) ⊥ null space (dim ); right pane , split into column space (dim ) ⊥ left null space (dim ). One arrow carries the row space bijectively onto the column space; a second arrow crushes the null space to .
Solvability regimes for :
| Rank | Shape of | # solutions | |
|---|---|---|---|
| (full col) | 0 or 1 | ||
| (full row) | dim | ∞ | |
| 1 (invertible) | |||
| dim | 0 or ∞ |
- Complete solution : one particular solution plus the whole null space — an affine subspace, a copy of shifted off the origin.
- Free variables: of them, one special solution each; the special solutions are a basis for .
Implications — what falls out of the four-subspace picture:
- Fredholm alternative: is solvable ⟺ . Either you can solve the system, or there exists a certificate with and — never both. (Just restating , but it converts “is it solvable?” into a checkable orthogonality condition.)
- Every splits uniquely as with the two parts orthogonal. acts only on ; this split is the engine behind the minimum-norm solution in §6.
- Rank-1 matrices are exactly outer products ; rank ⟺ a sum of outer products ⟺ factorization into — the seed of low-rank approximation.
Core competency set
- Draw the four-subspace picture with dimensions and orthogonality from a blank page.
- Read solution count straight off the rank regime.
- State the Fredholm alternative and the orthogonal split .
2. Projection and least squares
Build the projection from one dimension up:
- Project onto the line through . The projection lies on the line: for some scalar . The defining property is that the error is perpendicular: . Solve that one condition:
- Repackage to expose the matrix acting on :
— rank 1, built from an outer product.
- Project onto a subspace . Same logic, scalar → vector: , and the error must be perpendicular to every column at once, which is exactly one matrix statement:
- The normal equations are the orthogonality condition — there is nothing else in the derivation.
- is invertible ⟺ has independent columns. Why: they share a null space —
- So with independent columns:
Numbers: project onto : , so and ; check . The right triangle is the whole subject in one sketch — that triangle is also the picture to redraw cold.
Calculus arrives at the same place. Expand the loss, differentiate, set to zero:
Geometry and calculus give the same equations because “gradient zero” and “error ⊥ columns” are the same statement: the loss stops decreasing exactly when no direction in has any component of the error left to remove.
Reading :
- Projection matrices are exactly the symmetric idempotents: , (projecting twice changes nothing).
- ; ; in general splits into column-space part + left-null-space part. projects onto the complement.
- Least squares is this picture applied to an unsolvable system: , so solve the nearest solvable problem . The residual lives in .
Implications — what falls out of the projection picture:
- Pythagoras for regression. Since :
Total = explained + residual. Applied to centered data this is the decomposition: .
- In regression language: is the hat matrix, are fitted values, residuals are orthogonal to every regressor and to the fitted values — not an assumption, a theorem of the geometry.
- Adding a column to grows , so the residual norm can only shrink or stay — why never decreases when you add variables, and why that’s not evidence of a better model.
Orthogonal matrices. has orthonormal columns: if , else ; equivalently (square ⟹ ).
- They preserve lengths and inner products: — pure rotations/reflections.
- With orthonormal columns, projection collapses:
No inverse to compute — this is the reason to orthogonalize. Coefficients are just inner products: , each computed independently of the others.
Gram–Schmidt — the procedure that manufactures orthonormal bases. One move, repeated: subtract from each new vector its projections onto everything already built; what survives is the genuinely new direction.
- Input: independent . Output: orthogonal , then orthonormal .
- Step 1: . The first direction is kept as-is.
- Step 2: remove ‘s shadow on :
Verify the move worked:
- Step 3: remove shadows on both prior directions:
Subtracting projections onto orthogonal directions doesn’t interfere — removing the -shadow leaves the -orthogonality intact, which is why the procedure can work one direction at a time.
- Normalize last: , , .
- Spans are preserved at every step: .
- Bookkeeping form : since involves only (never later ones), the coefficient matrix is upper triangular with .
Implications — why QR earns its keep:
- Least squares via QR: substitute into the normal equations and watch them collapse:
One triangular solve. Better conditioned than forming , whose condition number is the square of ‘s.
- The same “project out what’s already explained” move is the engine elsewhere: a regression coefficient measures what a variable adds beyond the others (successive orthogonalization), orthogonal polynomials, Arnoldi/Lanczos iterations.
Core competency set
- Run the 1-D → subspace projection derivation; state that normal equations = orthogonality = gradient zero.
- Reproduce the calculus derivation of the normal equations from the expanded loss.
- Execute Gram–Schmidt on three vectors; explain why is triangular and how QR collapses the normal equations.
- Narrate the Pythagoras/ decomposition as projection geometry.
3. Determinants — the load-bearing facts
Three axioms (det ; sign flips per row swap; linear in each row separately) generate every property. Keep:
- = product of pivots (± for swaps) = product of eigenvalues = signed volume of the column parallelepiped.
- singular; ; ; .
- Elimination doesn’t change the determinant: subtracting a multiple of one row from another adds a multiple of a repeated-row determinant, which is 0 —
That’s why “product of pivots” works: eliminate (det unchanged), then a triangular determinant is the diagonal product.
- Similar matrices share determinant, trace, and eigenvalues — these are basis-free numbers attached to the underlying map.
- Cofactor expansion exists; in practice eliminate instead.
- = local volume scaling of a map — the bridge to change of variables in probability.
4. Eigenvalues and diagonalization
: directions the map only stretches; is the stretch factor (negative = flip).
The procedure:
- — we need singular.
- So set : the characteristic polynomial, degree , roots with multiplicity.
- For each root , the eigenvectors are — find by elimination. The whole null space is the eigenspace.
- Sanity-check instantly: , .
Numbers: — trace 4, det 3, so on sight. Eigenvectors and : orthogonal, because is symmetric (§5 coming). Powers grow like along .
Fast facts:
- Triangular ⟹ eigenvalues sit on the diagonal.
- Singular ⟺ is present.
- and share eigenvalues (same characteristic polynomial), not eigenvectors.
- Distinct eigenvalues ⟹ independent eigenvectors ⟹ diagonalizable. Repeated eigenvalues may starve you of eigenvectors (eigenspace dimension < multiplicity); Jordan form is the fallback, rarely needed.
Diagonalization. With independent eigenvectors as columns of , apply column by column:
Read it as a recipe: translates into eigen-coordinates, stretches each coordinate independently, translates back. In the right basis, the map has no cross-talk at all.
Implications — what falls out of knowing is diagonalizable:
- Powers cost one decomposition. The inner pairs cancel:
Only the eigenvalues get powered.
- Linear recurrences get closed forms. solves as : expand in eigenvectors, then
Each mode evolves independently. Fibonacci is the classic instance: , eigenvalues — golden-ratio growth is the dominant eigenvalue showing through.
- Stability is a one-number question. all ; long-run behavior is owned by . This single fact is LDS stability, Markov chain convergence, and power iteration (repeatedly applying amplifies the top eigenvector until it’s all that’s left).
- ODEs decouple. solves as — exponentials per mode; continuous-time stability ⟺ all .
- Functions of matrices become functions of scalars: for any polynomial/power series — matrix exponentials, square roots, inverses all ride the same identity.
- Convergence rates come from the spectral gap: a Markov chain approaches its steady state like — the second eigenvalue, not the first, sets the speed.
Markov matrices (entries ≥ 0, columns sum to 1):
- always: columns of sum to 0, so the rows are dependent, so is singular.
- All other ; the steady state is the eigenvector, reached because every other mode decays as .
Core competency set
- Run the eigen-procedure; sanity-check with trace/det reflexively.
- Derive from and narrate it as a change into eigen-coordinates.
- Produce the implications unprompted: powers, recurrences (Fibonacci), stability via , ODE decoupling, , spectral-gap rates.
5. Symmetric and positive definite matrices
Spectral theorem: ⟹ real eigenvalues and a full set of orthonormal eigenvectors:
- Reading: every symmetric matrix is a weighted sum of rank-1 orthogonal projections — acts by projecting onto each eigendirection and scaling by .
- Proof beat (orthogonality): symmetry lets hop across the inner product —
so forces .
- Proof beat (reality): compute two ways —
so : real.
- For symmetric matrices, # positive pivots = # positive eigenvalues — elimination and the spectrum agree on signs.
Implications — what falls out of the spectral theorem:
- Rayleigh quotient bounds. Expanding in the eigenbasis, , so
with equality at the eigenvectors. “Maximize variance” problems (PCA) are this: the top eigenvector is the argmax of the quadratic form on the sphere.
- Quadratic-form geometry: the level set (PD case) is an ellipsoid with axes along the and semi-lengths — eigen-decomposition literally draws the picture of the form.
- Whitening / matrix roots: exists for PSD ; transform data by to make its covariance the identity.
Positive definite — four equivalent tests, cycle freely:
- All eigenvalues .
- for all (the defining quadratic-form test).
- All pivots .
- All leading principal subdeterminants .
- The quadratic form is a bowl; PD means the bowl opens upward in every direction.
- Completing the square is elimination:
The outer coefficients (2, 2) are the pivots; the inside multiplier (3) is the elimination multiplier . PD ⟺ all completed squares have positive coefficients — that’s why test 3 works.
- PD matrices are exactly the valid covariance matrices and the valid inner products ().
- Semi-definite: — eigenvalues allowed to touch zero.
is always PSD:
with equality exactly on — so PD ⟺ full column rank. This single fact ties together least squares (§2), covariance matrices, and SVD (§6).
Cholesky: PD , lower triangular with positive diagonal, unique — a matrix square root recorded by elimination. How you sample correlated Gaussians ( for iid gives ) and the cheap way to solve PD systems. Also .
Core competency set
- Write the spectral theorem in both forms; reproduce both proof beats (hop, reality).
- Cycle between the four PD tests; narrate completing-the-square as elimination.
- Derive the Rayleigh bounds from the eigenbasis expansion; connect top-eigenvector to variance maximization.
- Explain in one line and when it upgrades to .
6. SVD — the capstone
Exists for every matrix — no squareness, no symmetry, no diagonalizability needed. Meaning: rotate (orthonormal basis in the domain), scale each axis by , rotate (orthonormal basis in the codomain). Eigendecomposition uses one basis and needs a lucky matrix; SVD buys universality by allowing two.
The picture: the unit circle, hit by (rotate), then (stretch into an ellipse with semi-axes along the coordinate axes), then (rotate the ellipse into place). Every matrix does exactly this to the unit sphere — the are the ellipse’s axis lengths.
Construction — also the existence proof, built entirely from §5:
- Form : symmetric PSD, the workhorse again.
- Spectral theorem gives orthonormal eigenvectors with eigenvalues . Define , sorted descending.
- For each , define — push the right basis through and renormalize.
- The come out orthonormal automatically — the one computation worth memorizing:
- Extend to an orthonormal basis of ; assemble , i.e. .
Numbers — run the construction on :
Note , not . The signs must come from — eigendecomposing separately and picking signs independently is the classic way to assemble an “SVD” that doesn’t multiply back to .
Consequences to keep paired with the construction:
- Right singular vectors = eigenvectors of ; left = eigenvectors of ; — both products share the same nonzero eigenvalues.
- SVD is the fundamental theorem made computational: span the row space, the null space, the column space, the left null space. Orthonormal bases for all four subspaces, with the row→column bijection scaled by the .
- — total “energy” lives in the singular values (orthogonal rotations don’t change Frobenius norm).
Eckart–Young / low-rank approximation. Truncate to the top rank-1 terms: .
- The error identity comes free, because multiplying by orthogonal matrices preserves Frobenius norm:
Truncation error = exactly the discarded energy.
- The theorem’s content is optimality: no rank- matrix of any kind beats (in Frobenius or operator norm). Intuition for why: any rank- has an -dimensional null space, which must intersect the -dimensional span of — on that intersection contributes nothing while still carries energy . You cannot avoid missing the top of what you cut.
- Reading: singular values rank the “concepts” in by signal strength — rows of are canonical row-types, columns of canonical column-types, each row/column of a mixture of them (the customers × movies story). PCA, compression, denoising, matrix completion all start here.
- Storage drops . Choose at the spectrum’s elbow, or to capture a target share of .
Pseudoinverse. , where inverts the nonzero ‘s and transposes the shape.
- Subspace-by-subspace: inverts the row↔column bijection () and kills .
- Claim: is the minimum-norm least-squares solution. Motivate it, both halves:
- Least squares half: the set of least-squares solutions is — all solutions of the normal equations differ by null-space vectors, since adding changes nothing about .
- Minimum-norm half: split any solution into orthogonal parts (§1). The fit only sees the row part (); the null part adds pure norm. By Pythagoras:
- So the minimizer is the unique solution with zero null-space component — a pure row-space vector. is built entirely from the spanning the row space: it is that solution.
- Full column rank ⟹ , the solution is unique anyway, and — recovering §2’s left inverse exactly.
Implications — what falls out of having an SVD:
- Operator norm and conditioning: (max stretch over the unit sphere); condition number measures how much relative error in can amplify in — the practical reason QR beats normal equations (forming squares ).
- Numerical rank: count singular values above a tolerance — far more robust than counting pivots, which rounding pollutes.
- PCA is SVD of the centered data matrix: principal directions = right singular vectors, component variances = ; “maximize variance” = Rayleigh quotient on the covariance (§5 implications, cashed in).
- Polar decomposition: = orthogonal × symmetric-PSD — every linear map is a rotation followed by a stretch.
Core competency set
- Construct the SVD from the spectral theorem on , including the orthonormality computation.
- Map singular vectors onto the four subspaces; state Eckart–Young with the discarded-energy identity and the null-space-intersection intuition for optimality.
- Prove the min-norm property of via the row/null split and Pythagoras.
- Connect , , PCA, and polar decomposition back to the SVD without prompting.
7. Matrix calculus — working table
Numerator layout (gradient of a scalar = row vector; Jacobian of is ). Chain rule = Jacobian product: — the shapes self-check.
| → if symmetric | |
| — zero ⟹ normal equations | |
| (Jacobian) |
Worked chain-rule template — the least-squares gradient, done the modular way (this is the pattern backprop generalizes):
- Element-wise operations ⟹ diagonal Jacobians; sums pull outside derivatives.
- = volume scaling (ties to §3 and the probability change-of-variables).
- Taylor: — Hessian PD at a critical point ⟹ local min (§5 cashing in).
8. Decompositions roundup
| Decomposition | Form | Requires | Use |
|---|---|---|---|
| LU | square, (P for swaps) | solving systems, det via pivots | |
| QR | independent columns | least squares, Gram–Schmidt record | |
| Cholesky | symmetric PD | sampling Gaussians, fast PD solves | |
| Eigen | indep. eigenvectors | powers, dynamics, stability | |
| Spectral | symmetric | quadratic forms, PSD theory | |
| SVD | nothing | everything else |
9. Memorize cold
The instant-recall layer — these should cost nothing to produce. Everything else in the guide is rederivable from them plus the named moves; the fluency flashcards drill exactly this list.
- Four subspaces: dims ; row ⊥ null, column ⊥ left-null; = bijection row space → column space.
- Normal equations ; ; ; orthonormal case .
- Projection test: symmetric + idempotent. Pythagoras .
- Eigen: ; , ; , ; stability ⟺ all .
- Spectral theorem: symmetric ⟹ , real , orthonormal .
- PD tests (all positive): eigenvalues / / pivots / leading minors. always; ⟺ full column rank.
- SVD: ; = eigvecs of , = eigvecs of , ; , .
- Pseudoinverse ; full column rank ⟹ ; = min-norm least squares.
- Gradient rows: ; ; .
- The decompositions table: form, requirement, use — all six rows.
- Named moves: error ⊥ subspace (normal equations); the inner-product hop (spectral orthogonality); project-out-what’s-built (Gram–Schmidt); row/null split + Pythagoras (min-norm); shared-null-space ( invertibility).