Linear Algebra for Quant Work
3 min read
Quant finance is applied linear algebra with money attached. A portfolio is a vector; a risk model is a matrix; "what are my biggest risks" is an eigenvalue question. This lesson rebuilds the essentials in those terms.
Vectors and dot products: portfolios and P&L
A portfolio is a weight vector ; asset returns over a day form another vector . The portfolio's return is the dot product:
Dot products measure alignment: . Two return streams with high positive dot product (after demeaning) are correlated strategies — geometrically, vectors pointing the same way. "Diversification" means choosing vectors that are close to orthogonal.
Matrices: the covariance matrix is the risk model
The object at the center of everything is the covariance matrix , with . Portfolio variance is the quadratic form
which is the two-asset formula () written once for any . Facts interviews expect:
- is symmetric and positive semi-definite (PSD): always — variance can't be negative. If your estimated isn't PSD, it implies a portfolio with negative variance: a data or estimation bug, and a classic "spot the problem" interview prompt.
- Correlations near ±1 make nearly singular — some portfolio has almost zero risk, which optimizers will lever into absurd positions. Near-singularity is why raw sample covariance matrices are never used untreated.
Eigenvalues: what the market's principal risks are
Since is symmetric, it diagonalizes: with orthonormal eigenvectors and eigenvalues . Interpretation:
- Each eigenvector is a portfolio (a linear combination of assets); its eigenvalue is that portfolio's variance.
- The top eigenvector of an equity covariance matrix is, empirically, "everything moves together" — the market factor. The next few look like industries or styles. This is PCA, and it's the mathematical skeleton of factor models: a handful of large eigenvalues carry most of the variance, and the rest is diversifiable noise.
- The trace ( = total variance) and the share ("how much of the market is one big trade?") are quoted on real desks — that share spikes in crises, when correlations converge and diversification dies.
Solving systems: regression in matrix form
OLS with design matrix and target solves the normal equations:
Two practical readings. First, is (up to scaling) the covariance matrix of the predictors — if predictors are collinear it's near-singular, explodes, and you've rediscovered why multicollinearity destabilizes regressions. Second, nobody inverts matrices in practice; libraries solve the system via decompositions (QR, Cholesky) for speed and numerical stability — a fact worth mentioning in any "how would you implement this" follow-up.
The interview versions
- "Why must a covariance matrix be PSD? What would a negative eigenvalue mean?" — A portfolio with negative variance; impossible, so the estimate is broken (usually asynchronous data or more assets than observations).
- "You run PCA on 500 stocks. What does the first component look like, and what fraction of variance might it explain?" — Roughly equal positive weights (the market), often 30–50% in stressed periods.
- " is nearly singular — what happens to your regression, and what do you do?" — Coefficients become huge and unstable with opposite signs; fix with regularization (ridge adds , making the matrix invertible — a one-line answer that bridges directly into the machine-learning course).