Skip to content
mlmentorship

Positive (semi-)definite matrices

Matrices that define inner products and proper covariances. The geometry of PSD: ellipsoids, not arbitrary shapes.

Published · 5 min read ·Core ·Foundation

Visual quick review

Visual first · depth when needed

Predict whether a quadratic sublevel set is bounded by checking whether every eigenvalue penalizes its eigenvector direction.

Preparing the visual…

Summary

A symmetric matrix is positive semi-definite (PSD) if for all , and positive definite (PD) if for all . Equivalently: all eigenvalues are non-negative (PSD) or strictly positive (PD).

PSD matrices are the matrices that can serve as covariance matrices, kernel matrices (Gram matrices), inner-product weight matrices, and Hessians at local minima. The PSD cone is the natural domain for many optimization problems (semidefinite programming, Gaussian processes, kernel methods).

Equivalent characterizations

For symmetric :

  • for all (definition).
  • All eigenvalues .
  • for some matrix (factorization, e.g., Cholesky with lower triangular).
  • is the covariance matrix of some random vector.
  • All principal minors are non-negative. For PD matrices, Sylvester’s criterion gives the simpler equivalent test that every leading (upper-left) principal minor is positive.

For PD: replace non-negative eigenvalues and quadratic forms with strictly positive ones, and require to be invertible in the factorization.

The Cholesky factorization

Every PD matrix has a unique decomposition with lower triangular and positive diagonal. This is the standard way to:

  • Solve when is PD ( instead of for general LU).
  • Sample from a Gaussian: if then .
  • Compute Gaussian log-likelihoods: .

PSD (not strictly PD) matrices admit Cholesky-like decompositions but with possible zero diagonal entries; use pivoted Cholesky or LDL.

The PSD cone

The set of PSD matrices forms a convex cone (closed under non-negative combinations). This is why semidefinite programming generalizes linear programming. It optimizes over a different cone.

Operations preserving PSD:

  • is PSD if are PSD.
  • is PSD for .
  • is PSD for any compatible .
  • Element-wise (Hadamard) product (Schur product theorem).

Operations not preserving PSD:

  • General matrix product (only if commute).
  • Inverse: PD matrices have PD inverses; PSD with zero eigenvalue is not invertible.

Geometric intuition

For PD, the set is a closed ellipsoid centered at the origin. Eigenvectors of give the axes; eigenvalues give . If is PSD but singular, a zero eigenvalue leaves its eigenvector direction unpenalized, so the same sublevel set is an unbounded cylinder (a strip in 2D), not a flat ellipsoid. A singular covariance distribution is instead supported on a lower-dimensional subspace; that is the setting in which its probability contours collapse.

Learning objective

Predict whether a quadratic sublevel set is bounded by checking whether every eigenvalue penalizes its eigenvector direction.

Positive definite ellipse compared with a singular positive semidefinite strip Two numbered coordinate plots use the same threshold x transpose A x less than or equal to one. In the first, A equals diagonal four comma one, so the quadratic form is four u squared plus v squared. Both eigenvalues are positive, and the feasible set is a bounded ellipse with u semiaxis one half and v semiaxis one. In the second, A equals diagonal four comma zero, so the form is four u squared. The v coordinate has zero cost, and the feasible set is the unbounded vertical strip from u equals negative one half to positive one half. Direct equations, boundary labels, solid axes, dashed strip edges, and continuation arrows communicate the distinction without color. 1 · PD: every direction has positive cost A = diag(4, 1) · xᵀAx = 4u² + v² ≤ 1 −½ ½ 1 u v λ = (4, 1) → bounded ellipse 2 · PSD, not PD: one direction has zero cost A = diag(4, 0) · xᵀAx = 4u² ≤ 1 u = −½ u = ½ u v λ = (4, 0) → v is free → unbounded strip
Read it this way: diagonalize first, then inspect one eigendirection at a time. In the top panel, moving along either axis increases the quadratic form, so the threshold closes into an ellipse. In the bottom panel, moving along v adds nothing because its eigenvalue is zero; only u is bounded, and the strip continues forever.

Original coordinate construction checked against MIT OpenCourseWare 18.06 and Boyd and Vandenberghe's Convex Optimization.

Common pitfalls

  • Calling a non-symmetric matrix PSD. PSD is defined for symmetric matrices. For asymmetric , the relevant object is .
  • Trusting numerical eigenvalues at machine precision. A theoretically PSD covariance computed from data can have tiny negative eigenvalues from rounding. Use jitter () before Cholesky.
  • Confusing PSD with diagonally dominant. Diagonally dominant with positive diagonal PSD, but the converse is false.
  • Inverting near-singular PSD matrices. Always check the smallest eigenvalue or condition number first; regularize if needed.