Setup
Why linear algebra in quant finance?
Three operations dominate production quant code:
- Portfolio aggregation: multiply a weight vector by a covariance matrix to get portfolio variance .
- System solving: bootstrap a yield curve by solving a linear system where encodes instrument sensitivities to discount factors.
- Factor decomposition: decompose a risk matrix to identify which linear combinations of assets drive most of the variance.
All three reduce to linear algebra. This module builds the precise foundations: what a vector space is, what a matrix does geometrically, and what the rank-nullity theorem tells you about the structure of solutions to linear systems.
Why this matters on a derivatives desk. When bootstrapping a swap curve, the system has encoding instrument-to-discount-factor relationships and containing observed par swap rates. If two instruments are economically equivalent (redundant), is singular. The rank-nullity theorem tells you exactly by how many degrees the solution is underdetermined — and therefore how many regularisation constraints you need to add to recover uniqueness.
Conventions
- All vectors are column vectors in unless stated otherwise.
- denotes the set of real matrices.
- The standard inner product on is .
- Notation: (null space); (column space / image).
- Superscript denotes transpose: .
Theory
1. Vector Spaces
Definition 1.1 (Vector Space). A vector space over is a non-empty set equipped with two operations — addition and scalar multiplication — satisfying eight axioms:
- (Closure) and for all , .
- (Commutativity) .
- (Associativity) and .
- (Zero vector) There exists with for all .
- (Additive inverses) For each there exists with .
- (Unit scalar) .
- (Scalar distributivity) .
- (Vector distributivity) .
The canonical example is : column vectors with componentwise addition and scaling. Other examples relevant to quant finance:
- : the space of matrices, used as parameter spaces in calibration.
- : continuous functions on , the natural home for asset price paths.
- : square-integrable random variables; the space in which conditional expectations and martingales live (covered in the Probability Theory course).
Definition 1.2 (Subspace). A non-empty subset is a subspace if it is closed under addition and scalar multiplication — equivalently, if for all and .
The subspace test: is a subspace iff (i) and (ii) is closed under linear combinations.
Example 1.3 (Dollar-neutral portfolios). Let be the space of portfolio weight vectors. The set of dollar-neutral portfolios (zero net exposure) is a subspace of dimension . The sum of two dollar-neutral portfolios remains dollar-neutral; scaling preserves the constraint. This subspace arises in statistical arbitrage and market-neutral strategies.
2. Linear Spans and Bases
Definition 2.1 (Linear span). The span of vectors is This is the smallest subspace of containing all .
Definition 2.2 (Basis and dimension). A basis of is a set that is simultaneously:
- Linearly independent: implies for all .
- Spanning: .
The number of elements in any basis is the dimension — this is well-defined (any two bases of a finite-dimensional space have the same cardinality, proved via the Steinitz exchange lemma).
Coordinate representation. Once a basis is fixed, every has a unique representation . The coefficients are the coordinates of in that basis. A change of basis is itself a linear map (an invertible matrix).
3. Matrices as Linear Maps
A matrix defines a linear map by . Linearity is immediate:
Conversely, every linear map between finite-dimensional spaces has a unique matrix representation once bases are fixed — the -th column of is the image of the -th basis vector of the domain.
Definition 3.1 (Kernel and image). For :
- The null space (kernel): — a subspace of .
- The column space (image): — a subspace of .
Solvability: the system has a solution iff . It has a unique solution iff additionally .
Theorem 3.2 (Rank-Nullity). For any :
Proof sketch. Let . Choose a basis for , then extend to a basis of . For any , we have . It follows that spans and is linearly independent (if a combination were zero, it would imply a dependence contradicting the extended basis). So , giving .
Example 3.3 (Redundant swap instruments). Suppose five market instruments each price as a linear combination of six discount factors. The pricing equations are with . By rank-nullity, . Since has only 5 rows, , so : there is at least a one-dimensional family of solutions. The solution is not unique — additional constraints (e.g., smoothness of the forward curve) are required to select one.
4. The Four Fundamental Subspaces
For with , there are four canonical subspaces:
| Subspace | Lives in | Dimension |
|---|---|---|
| Column space | ||
| Left null space | ||
| Row space | ||
| Null space |
Theorem 4.1 (Orthogonality of fundamental subspaces). Furthermore, and (orthogonal direct sum decompositions).
Proof. Let and . Then . The direct sum decomposition follows from dimension counting and orthogonality.
Geometric picture. Think of as a map from to . The row space is the "effective" part of — the directions actually acts on. The null space is the "invisible" part — directions crushes to zero. In , the column space is the range and the left null space is the "unachievable" part.
5. Symmetric and Positive (Semi-)Definite Matrices
Definition 5.1. A matrix is:
- Symmetric if .
- Positive semi-definite (SPSD) if and for all .
- Positive definite (SPD) if and for all .
Notation: (SPSD), (SPD).
The quadratic form has a geometric interpretation: it measures how much stretches in the direction of itself. Positive definiteness says never "collapses" any direction to zero or below.
Proposition 5.2 (Covariance matrices are SPSD). Let be a returns matrix ( observations, assets) with mean-zero columns. The sample covariance matrix satisfies . It is positive definite iff has full column rank (no asset is a perfect linear combination of others).
Proof. (symmetric). For any : The form equals zero iff , i.e., . Full column rank of means , giving positive definiteness.
Near-singular covariance matrices. In practice, assets are highly correlated (e.g., equity index options at adjacent strikes), and estimated from finite data is frequently near-singular: it is theoretically SPD but has eigenvalues close to zero. Inverting directly (as required for minimum-variance weights ) amplifies these small eigenvalues and produces wildly unstable portfolio weights. The fix — regularisation via SVD or adding a diagonal ridge — is treated in Module 4.
Validation
The companion notebook verifies:
- Vector space axioms — checks all eight axioms for with explicit counterexamples showing what fails when each axiom is dropped.
- Subspace test — confirms the dollar-neutral subspace is closed under linear combinations.
- Rank-nullity — for a matrix, computes and via row reduction and verifies their sum equals 6.
- Orthogonality of fundamental subspaces — constructs a basis for each of the four subspaces and verifies the pairwise orthogonality via dot products.
- Covariance SPSD — builds a sample covariance from synthetic returns and confirms for 1000 random weight vectors.
By hand before opening the notebook. Let
- Are the rows of linearly independent? What is ?
- By the rank-nullity theorem, what is ?
- What is the dimension of (left null space)?
- Does the system have a solution? Does ?
(Answers: since row 3 = 2 × row 2 − row 1; nullity = 1; ; is column 1 of so yes; check whether is in the column space.)
Limitations
Numerical rank is not algebraic rank. The definitions above are exact, but in floating-point arithmetic, a matrix that is "theoretically" rank-2 may appear rank-3 due to rounding errors — or vice versa. Production code determines rank using singular values with a tolerance: count the number of singular values exceeding for a problem-specific threshold . This is treated rigorously in Module 4 (SVD and condition numbers).
Invertibility is not conditioning. A matrix can be theoretically invertible but numerically catastrophic if its columns are nearly linearly dependent. The condition number quantifies this. A yield curve system with means computed solutions are meaningless below 12 significant digits — which is the entire double-precision range on a bad day. Always check condition numbers before trusting a linear solve in calibration.
Scope limitations:
- This module assumes finite-dimensional spaces over . Infinite-dimensional Hilbert spaces (, Sobolev spaces) require additional structure (completeness, bounded operators) and arise in the functional analytic foundations of interest rate models.
- Results extend to complex vector spaces (replacing transpose with conjugate transpose ), which are needed for Fourier-transform pricing (Module in
fourier-fft-pricingcourse).
Interview Angle
L1 (Junior quant / developer).
-
"State the rank-nullity theorem and give an example with a matrix." — Expected answer: (number of columns). Example: rank-2 matrix has a 2-dimensional null space.
-
"When does the system have exactly one solution?" — Expected answer: when (solvability) and (uniqueness), i.e., is square and invertible.
-
"What does it mean for a covariance matrix to be positive definite, and why does it matter for portfolio optimisation?" — Expected answer: for all , so portfolio variance is always strictly positive (no costless zero-variance portfolio). Positive definiteness guarantees is invertible, which is needed to compute minimum-variance weights .
L2 (Senior quant).
-
"You bootstrap a 5-instrument swap curve and get infinitely many solutions. What does linear algebra tell you?" — Expected answer: the system matrix is rank-deficient. By rank-nullity, , so the solution set is an affine subspace of dimension . The instruments are redundant or the system is underdetermined — either remove a redundant instrument or add a regularisation constraint (smoothness prior on the forward curve).
-
"Explain the four fundamental subspaces and their orthogonality relations for an matrix of rank ." — Expected answer: column space and left null space are orthogonal complements in with dimensions and ; row space and null space are orthogonal complements in with dimensions and .
-
"When is a covariance matrix estimated from 50 days of returns on 100 assets positive definite?" — Expected answer: never — the data matrix has rank at most 50, so has rank at most 50 < 100. At least 50 eigenvalues are zero. The matrix is SPSD, not SPD.
L3 (Researcher).
-
"In a factor risk model, the factor covariance is full rank, but the full asset covariance (where with ) is used in a Markowitz optimisation. How does the structure of affect the optimisation?" — Expected answer: is rank (SPSD, not SPD). It lies in an -dimensional space but has a -dimensional null space. Portfolio optimisation using directly is impossible; one must use the full (where is a diagonal idiosyncratic matrix, making SPD), or use the Woodbury identity for efficient inversion.
-
"How does the null space of a linear operator relate to regularisation in calibration?" — Expected answer: if , the calibration objective has infinitely many minimisers differing by elements of . Tikhonov regularisation (penalising ) is equivalent to selecting the unique minimum-norm solution, which is the orthogonal projection of any solution onto the row space .