Quant Memo
Foundational

Positive Semidefinite Matrices

The matrices that make quadratic forms non-negative, equivalent tests via eigenvalues, pivots and principal minors, the Cholesky factorization that generates correlated risk, and why every valid covariance matrix must be PSD.

Prerequisites: Linear Algebra for Quants, Eigenvalues & Eigenvectors

Positive semidefinite matrices are the ones for which the quadratic form xAxx^\top A x is never negative, and that innocuous property is the linchpin of quantitative finance. It is exactly the condition a covariance matrix must satisfy (no portfolio can have negative variance), the condition that makes an optimization problem Convex Optimization and hence solvable, and the condition that lets you factor a matrix to simulate correlated returns. When a risk system throws "matrix not positive definite", it is this property that broke, and knowing the equivalent characterizations is what lets you diagnose and fix it.

Definition and the hierarchy

A symmetric matrix A=ARn×nA = A^\top \in \mathbb{R}^{n\times n} is:

  • Positive semidefinite (PSD), written A0A \succeq 0, if xAx0x^\top A x \ge 0 for all xRnx \in \mathbb{R}^n;
  • Positive definite (PD), A0A \succ 0, if xAx>0x^\top A x > 0 for all x0x \ne 0 (strict).

The distinction is exactly invertibility: PD matrices have all-positive eigenvalues and are invertible; PSD matrices allow zero eigenvalues, hence can be singular. Symmetry is part of the definition here (the quadratic form only sees the symmetric part 12(A+A)\tfrac12(A + A^\top) anyway). The quadratic form xAxx^\top A x is the object being constrained, and it is the same quadratic form that appears as portfolio variance wΣww^\top\Sigma w in Linear Algebra for Quants, which is the whole reason this matters.

Equivalent tests

For a symmetric AA, the following are equivalent to A0A \succeq 0, and each is a practical test:

  1. Eigenvalue test. All eigenvalues λi0\lambda_i \ge 0 (strictly >0> 0 for PD). Via the spectral theorem A=QΛQA = Q\Lambda Q^\top, the form becomes xAx=iλi(qix)2x^\top A x = \sum_i \lambda_i (q_i^\top x)^2, a non-negative-weighted sum of squares iff all λi0\lambda_i \ge 0. This is the definitional test and connects directly to Eigenvalues & Eigenvectors.
  2. Gram / factorization test. A=BBA = B^\top B for some matrix BB. Then xAx=Bx20x^\top A x = \lVert Bx\rVert^2 \ge 0 automatically. Every PSD matrix is a Gram matrix of inner products, which is precisely why covariance matrices are PSD (below).
  3. Principal minors (Sylvester's criterion). A0A \succ 0 iff all leading principal minors are positive. For PSD, all principal minors (not just leading) must be 0\ge 0, a subtle but important difference; checking only leading minors misses PSD-but-not-PD cases.
  4. Pivots. In symmetric Gaussian elimination (LDL^\top), all pivots are 0\ge 0.

For a quick sanity check: a necessary condition is that all diagonal entries are non-negative (variances can't be negative) and the largest entry in absolute value sits on the diagonal. These catch obvious violations but are not sufficient.

Why covariance matrices are PSD

This is the result every quant must be able to prove on demand. Let rr be a random vector with covariance Σ=E[(rμ)(rμ)]\Sigma = \mathbb{E}[(r-\mu)(r-\mu)^\top]. For any weight vector ww, the portfolio wrw^\top r has variance Var(wr)=wΣw=E[(w(rμ))2]0,\operatorname{Var}(w^\top r) = w^\top \Sigma\, w = \mathbb{E}\big[(w^\top(r-\mu))^2\big] \ge 0, because it is the expectation of a square. Variance cannot be negative, so Σ0\Sigma \succeq 0 necessarily, it is not an assumption but a theorem. Equivalently, the sample covariance is Σ=1TXX\Sigma = \frac{1}{T}X^\top X (with XX the demeaned data matrix), manifestly of Gram form BBB^\top B. A zero eigenvalue means a portfolio ww with wΣw=0w^\top\Sigma w = 0: a riskless linear combination, i.e. a redundant asset or a perfect hedge, exactly what happens when you have more assets than observations (n>Tn > T), making the sample covariance singular and un-invertible. This is the concrete reason large-universe mean–variance optimisation fails and needs Shrinkage.

Cholesky: the factorization that generates correlation

For a PD matrix there is a unique lower-triangular LL with positive diagonal such that Σ=LL,\Sigma = LL^\top, the Cholesky decomposition, a specialized, twice-as-fast, numerically stable BBB^\top B factorization. Its killer application is simulating correlated Gaussians: draw independent standard normals zN(0,I)z \sim \mathcal{N}(0, I) and set x=Lzx = Lz. Then Cov(x)=LCov(z)L=LIL=LL=Σ.\operatorname{Cov}(x) = L\,\operatorname{Cov}(z)\,L^\top = LIL^\top = LL^\top = \Sigma. One triangular multiply turns independent noise into a sample with your target covariance, the backbone of Monte Carlo risk and multi-asset pricing. Cholesky is also the standard way to solve Σw=b\Sigma w = b (two triangular solves, no explicit inverse) and, as a bonus, its very existence is a PSD test: the algorithm fails (tries to square-root a negative pivot) exactly when the matrix is not PSD. That failure is the "matrix not positive definite" error every risk quant has seen, usually caused by a covariance estimated from mismatched or insufficient data.

Worked example, repairing a broken correlation matrix

You are handed a correlation matrix stitched from three pairwise estimates: C=(10.90.90.910.90.90.91).C = \begin{pmatrix} 1 & 0.9 & -0.9 \\ 0.9 & 1 & -0.9 \\ -0.9 & -0.9 & 1 \end{pmatrix}. Each entry looks plausible, but the trio is inconsistent: A and B are highly positive, both are highly negative with C, yet A–C and B–C can't both be 0.9-0.9 while A–B is +0.9+0.9. Testing PSD-ness, the smallest eigenvalue is negative, so C⪰̸0C \not\succeq 0: there exists a portfolio with negative implied variance, a pure arbitrage artifact of inconsistent inputs. Cholesky would fail on it. The standard repair is eigenvalue clipping: compute C=QΛQC = Q\Lambda Q^\top, floor the negative eigenvalues at 00 (or a small ε\varepsilon), and reconstruct C~=QΛ~Q\tilde C = Q\tilde\Lambda Q^\top, then rescale the diagonal back to 1. This projects the invalid matrix onto the nearest PSD one, precisely the kind of fix production risk systems apply automatically, and a direct application of the eigenvalue characterization.

Failure modes and subtleties

  • PSD vs. PD is invertibility. A singular (PSD, not PD) covariance cannot be inverted, so Σ1μ\Sigma^{-1}\mu optimal weights and Mahalanobis distances blow up. The n>Tn > T regime guarantees this; shrinkage or factor models restore full rank.
  • Estimation destroys PSD-ness sneakily. Pairwise-estimated correlations, different sample windows per pair, or missing-data patchwork routinely produce non-PSD matrices even though the true matrix is PSD. The fix is projection to the nearest correlation matrix (Higham's algorithm), not ignoring it.
  • Near-PSD is nearly-singular. A matrix with tiny positive eigenvalues is technically PD but has a huge condition number, so its inverse is noise-amplifying, the same instability as Singular Value Decomposition with small singular values. Regularize (shrinkage, ridge) rather than trusting the raw inverse.
  • Sylvester's criterion pitfall. Positive leading minors test PD, not PSD; a matrix can have positive leading minors yet fail PSD if a non-leading minor is negative. For PSD you must check all principal minors (or just the eigenvalues).
  • Adding PSD matrices preserves PSD; general sums do not preserve PD invertibility gracefully. A,B0A+B0A, B \succeq 0 \Rightarrow A + B \succeq 0 (useful: shrinkage αΣ+(1α)I\alpha\Sigma + (1-\alpha)I stays PSD and becomes PD), but subtracting can break it.

In interviews

"Prove that a covariance matrix is positive semidefinite" is a rite-of-passage question, the one-line answer is wΣw=Var(wr)0w^\top\Sigma w = \operatorname{Var}(w^\top r) \ge 0. Expect the equivalence drill: list the tests (eigenvalues 0\ge 0, Gram form BBB^\top B, non-negative principal minors, successful Cholesky) and know the PD-vs-PSD strictness. Cholesky-for-correlated-simulation is a classic applied question ("how do you simulate two correlated normals?", x=Lzx = Lz). A strong follow-up: "your risk system says the covariance matrix isn't positive definite, what happened and what do you do?", inconsistent/insufficient estimation, and eigenvalue clipping or shrinkage to repair. PSD-ness is the hinge between linear algebra and optimisation, so it sets up why convex problems (Convex Optimization) with PSD Hessians are globally solvable.

Related concepts

Practice in interviews

Further reading

  • Horn & Johnson, Matrix Analysis
  • Boyd & Vandenberghe, Convex Optimization (Appendix A)
  • Golub & Van Loan, Matrix Computations
ShareTwitterLinkedIn