Linear Algebra for Quants
The vector-space machinery that every quantitative model runs on, subspaces and rank, orthogonal projection as the geometry of regression, matrix and vector norms, and the quadratic forms that encode portfolio risk.
Linear algebra is the operating system of quantitative finance. A portfolio is a vector, a covariance is a matrix, a factor model is a low-rank approximation, a regression is a projection, and a risk number is a quadratic form. Fluency here is not optional literacy, it is what lets you see that seemingly different problems (hedging, PCA, least squares, optimisation) are the same geometric object viewed from different angles. This is the foundation the whole matrix track (Eigenvalues & Eigenvectors, Singular Value Decomposition, Positive Semidefinite Matrices) builds on.
Vector spaces, subspaces, span
A vector space over is a set closed under addition and scalar multiplication. In finance the ambient space is , assets, observations, factors. The key derived objects:
- Span: all linear combinations of a set of vectors, the subspace they reach. A portfolio's achievable payoffs are the span of its tradable assets.
- Linear independence: no vector is a combination of the others; equivalently forces all . Redundant (dependent) assets add no new spanning power.
- Basis and dimension: a maximal independent set; its size, the dimension, is the number of true degrees of freedom.
The four fundamental subspaces of a matrix organise everything: the column space (range, what can produce), the null space (solutions of , the redundancy), the row space, and the left null space. Their dimensions are locked together by rank.
Rank: the number that matters most
The rank of is the dimension of its column space, the number of linearly independent columns (equivalently rows; row rank = column rank always). The rank–nullity theorem ties the pieces together: Rank is the single most diagnostic quantity in applied linear algebra. Full rank means invertible/uniquely solvable; rank deficiency means redundancy and non-uniqueness. In Ordinary Least Squares (OLS), full column rank of the design matrix is exactly the "no perfect multicollinearity" assumption that makes invertible. In covariance estimation, a rank-deficient sample covariance (more assets than observations, ) is singular, so it cannot be inverted, the reason naive mean–variance optimisation breaks on large asset universes and needs shrinkage. Rank is where abstract algebra becomes a concrete failure mode.
Norms: measuring size
A norm assigns length, satisfying positivity, homogeneity (), and the triangle inequality. The ones that recur:
- (Euclidean): . Induces the inner product and hence angles and orthogonality; the geometry of least squares and volatility.
- : . Its "pointy" unit ball drives sparsity, the reason Lasso (-penalised regression) zeroes out coefficients.
- : , the worst case, used in robust/minimax bounds.
The inner product makes "correlation" geometric: standardised return vectors have inner product equal to their correlation, so uncorrelated is literally orthogonal. For matrices, the spectral norm (largest singular value) and Frobenius norm () measure operator size and are central to low-rank approximation.
Orthogonal projection: the geometry of everything
Projection is the most useful single idea in the quant's linear-algebra toolkit. Given a subspace (say the column space of ), the orthogonal projection of a vector onto is the closest point in to , and the residual is orthogonal to . For with full column rank, the projection matrix is is symmetric () and idempotent (), the algebraic fingerprint of a projection. This is Ordinary Least Squares (OLS): fitting is projecting onto the space spanned by the regressors, and the normal equations are just the orthogonality of the residual. The same construction is hedging (project the thing you hold onto the space of hedging instruments; the residual is unhedgeable basis risk) and Gram–Schmidt factor orthogonalisation. See projection once and you see it everywhere.
Quadratic forms: the language of risk
A quadratic form is with symmetric, a scalar built from a vector and a matrix. This is the shape of portfolio variance: with the weights and the covariance. Because variance is never negative for any weights, must satisfy for all , it is positive semidefinite Positive Semidefinite Matrices, the constraint that governs which matrices can even be covariances and why Cholesky and eigen-decompositions behave. The quadratic form also defines the objective in mean–variance optimisation and the exponent of the multivariate normal density. Its curvature, encoded in the eigenvalues of , tells you the directions of maximum and minimum risk, the bridge to Eigenvalues & Eigenvectors.
Worked example, projecting a return onto a factor
Suppose a stock's return vector over days, and you want its market beta by projecting onto the market return vector (a one-dimensional subspace). The projection formula collapses to a scalar: This is exactly the OLS slope once returns are demeaned, regression is projection, and beta is the length of 's shadow on per unit of . The residual is the idiosyncratic return, orthogonal to the market by construction. One formula, and you have decomposed systematic from specific risk.
Failure modes and subtleties
- Near-singularity is worse than singularity. A matrix that is almost rank-deficient (high condition number, the ratio of largest to smallest singular value) makes enormous and error-amplifying. Correlated factors give an ill-conditioned , so OLS coefficients become unstable and sign-flippy, Multicollinearity. Always check conditioning, not just invertibility.
- Never invert to solve. Computing by forming is numerically inferior to solving directly (LU/Cholesky/QR). Explicit inverses lose precision and are slower; production code factorises.
- Dimension mismatches hide bugs. covariance matrices are singular by construction; treating them as invertible silently produces garbage optimal portfolios.
- Orthogonality depends on the inner product. "Uncorrelated" is orthogonality under the covariance inner product, not the raw Euclidean one; conflating them misinterprets factor structure.
- Basis choice is not neutral numerically. The same subspace in a poorly-scaled basis (mixing units, e.g. rates in bps and equities in %) inflates the condition number; standardise before decomposing.
In interviews
Linear-algebra questions on quant desks are rarely rote computation; they test whether you see the geometry. Expect "what is the rank of this matrix and why does it matter for regression?" (invertibility of ). Expect projection: "derive the least-squares solution", set up the orthogonality of the residual. Know that a projection matrix is symmetric and idempotent, and be able to state portfolio variance as the quadratic form and explain why must be positive semidefinite. Condition number and multicollinearity are favourite follow-ups. The strongest signal is connecting these threads, regression, hedging, PCA, and optimisation are all projections and quadratic forms, which sets up Eigenvalues & Eigenvectors and Singular Value Decomposition as the tools that diagonalise them.
Related concepts
Practice in interviews
Further reading
- Strang, Introduction to Linear Algebra
- Trefethen & Bau, Numerical Linear Algebra
- Horn & Johnson, Matrix Analysis