Semidefinite Programming
An optimization problem where the decision variable is an entire matrix, constrained to always be a valid covariance-like (positive semidefinite) matrix — the natural tool for repairing a broken correlation matrix or finding worst-case portfolio risk.
Prerequisites: Second-Order Cone Programming, The Spectral Theorem for Symmetric Matrices
A correlation matrix built by stitching together pairwise correlations estimated at different times, or from illiquid instruments with stale prices, can end up mathematically broken: it fails to be a valid correlation matrix at all, even though every individual entry looks like a normal correlation between −1 and 1. Specifically, it can have a negative eigenvalue, which would imply some portfolio has negative variance — nonsense. Fixing this isn't a matter of optimizing over a handful of numbers; it's an optimization problem where the variable itself is a whole matrix, constrained to always stay a legitimate covariance-like object. Semidefinite programming (SDP) is exactly the framework for optimizing over matrices under that constraint.
The analogy: sculpting clay that must always stand up
Ordinary optimization variables are just numbers or vectors, free to take any values respecting some constraints. In SDP, the variable is a matrix, and it must remain positive semidefinite at every step — informally, "physically sensible as a covariance matrix," meaning every possible portfolio built from it has non-negative variance. Think of sculpting a piece of clay that must, at every stage of the sculpting, still be able to stand upright under its own weight: you can reshape it freely, but certain shapes (the equivalent of a matrix with a negative eigenvalue) are simply off-limits, no matter how tempting they'd be to reach a better "objective."
The mechanics, one symbol at a time
A matrix is positive semidefinite (written ) if for every vector — equivalently, all its eigenvalues are non-negative. A semidefinite program is
where is a matrix inner product playing the role of a linear objective, and the constraints are linear equations on the entries of . In plain English: minimize a linear function of a matrix's entries, subject to some linear equations the matrix must satisfy, while never letting the matrix leave the set of matrices that are legitimately "covariance-shaped" (no negative eigenvalues) — the SDP analogue of the vector constraint in linear programming, but for the entire eigenvalue spectrum of a matrix at once.
Worked example 1: checking positive semidefiniteness by hand
Is (implied correlation 0.9) a valid correlation matrix? Its eigenvalues solve , giving , i.e. — both non-negative, so : valid. Now try (a correlation "of 1.2," an error a naive pairwise-fill could produce): eigenvalues solve , giving , i.e. — negative! is not positive semidefinite and cannot be a genuine correlation matrix, even though 1.2 might have slipped through as "just a large correlation" if no one checked the eigenvalues.
Worked example 2: the nearest valid correlation matrix
Given the broken above, the nearest-correlation-matrix problem finds the closest (in matrix distance) positive semidefinite matrix with 1's on the diagonal. A quick approximate fix: clip the negative eigenvalue to zero, reconstruct, then rescale the diagonal back to 1. Using and keeping with its eigenvector , the reconstructed (rank-1) matrix is ; rescaling the diagonal to 1 gives off-diagonal — so this crude version repairs the matrix to a correlation of exactly 1 here (an extreme case reflecting only one surviving eigenvalue); a full SDP solver does this more carefully, finding the true nearest valid correlation matrix (typically a correlation somewhat below the broken 1.2, not exactly 1) while respecting every constraint simultaneously rather than a rough clip-and-rescale.
Try entries like (1, 1.2, 1.2, 1) to see a transformation with a negative-eigenvalue direction — the unit circle maps to a shape that inverts along one axis, the geometric signature of a matrix that has left the positive-semidefinite set entirely.
What this means in practice
SDP is the standard tool for repairing correlation and covariance matrices assembled from asynchronous or noisy data (the nearest-correlation-matrix problem), for robust portfolio optimization where worst-case risk over a set of plausible covariance matrices must be bounded, and for relaxations of otherwise hard combinatorial problems (like certain risk-budgeting or clustering formulations) into a tractable convex form. Any time "this matrix must remain a valid covariance/correlation matrix throughout an optimization" is a real requirement, SDP is the right framework rather than an ad hoc patch.
Semidefinite programming optimizes over matrices constrained to stay positive semidefinite (all eigenvalues non-negative) — the matrix generalization of linear programming's non-negativity constraint — and is the correct tool for problems like repairing a broken correlation matrix or bounding worst-case portfolio risk over a set of covariance matrices.
The classic mistake is "fixing" a broken correlation matrix by clipping individual entries (like capping any correlation above 1 or below −1) rather than working with the matrix's eigenvalues as a whole. Clipping entries one at a time does not guarantee the resulting matrix is positive semidefinite — it only fixes the symptom that's easy to see, not the underlying eigenvalue problem — and can leave a matrix that still implies a negative-variance portfolio somewhere, just not the one you happened to check.
Related concepts
Practice in interviews
Further reading
- Boyd & Vandenberghe, Convex Optimization, ch. 4.6
- Vandenberghe & Boyd, Semidefinite Programming, SIAM Review 1996