skip to content

How do eigenvalues distinguish a positive-definite matrix from a merely PSD one?

level: seniorimportance: should knowfreq 46%

answer

  1. look at the sign of the whole spectrum
  2. strictly positive versus merely nonnegative
  3. the quadratic form stays strictly positive
  4. a zero eigenvalue kills invertibility
  5. PSD-singular means a flat direction exists

basics

~20 s

For a symmetric matrix, positive definite means every eigenvalue is strictly greater than zero; positive semidefinite means every eigenvalue is greater than or equal to zero. A zero eigenvalue is exactly what separates them, and it makes the matrix singular.

solid answer

~50 s

For a symmetric matrix `A`, positive definiteness is the quadratic-form statement `x^T A x > 0` for every nonzero `x`, and positive semidefiniteness relaxes it to `x^T A x >= 0`. Because a unit eigenvector gives `v^T A v = lambda`, these are equivalent to all eigenvalues being strictly positive, or all nonnegative. Compare `[[2,-1],[-1,2]]`, with eigenvalues `3` and `1`, so positive definite and invertible, against `[[1,1],[1,1]]`, with eigenvalues `2` and `0`. The second is only semidefinite: `x^T A x = (x1 + x2)^2`, which is zero along `(1,-1)`. That zero eigenvalue makes it singular, so it has no inverse and a Cholesky factorization fails. In practice a sample covariance matrix is always PSD, and it is positive definite only when no linear combination of the variables is exactly constant and there are enough observations.

go deeper

for a junior

Recall the eigenvalue rule: all strictly positive means positive definite, all nonnegative means positive semidefinite, and any negative eigenvalue means neither.

for a middle

Explain the equivalence with the quadratic form x^T A x by diagonalizing, and show why a zero eigenvalue makes the matrix singular via the determinant being the product of the eigenvalues.

for a senior

Diagnose it in production: a zero or tiny eigenvalue in a covariance matrix means collinear features or too few observations, breaks inversion and factorization, and demands a decision about which variable to drop.

for a principal

Own the policy on repairing near-singular matrices. Clipping eigenvalues or adding a ridge to the diagonal changes the estimate, so decide what the team does by default, what size of shift is defensible, and how it gets reported.

## Two equivalent definitions For a **symmetric** matrix `A` (definiteness is only defined for symmetric matrices in the usual convention), the quadratic form is the scalar `x^T A x`. Then: - `A` is **positive definite (PD)** if `x^T A x > 0` for all `x != 0`. - `A` is **positive semidefinite (PSD)** if `x^T A x >= 0` for all `x`. The eigenvalue characterisation is equivalent, and it is the one worth reaching for. Diagonalize `A = Q D Q^T` with `Q` orthogonal, and substitute `y = Q^T x`: ``` x^T A x = y^T D y = sum_i lambda_i * y_i^2 ``` A sum of eigenvalues weighted by squares is positive for every nonzero `y` exactly when every `lambda_i > 0`, and nonnegative exactly when every `lambda_i >= 0`. Taking `x` to be a unit eigenvector gives the one-line version: `v^T A v = lambda`, so a negative eigenvalue immediately exhibits a direction where the form goes negative. ## The two examples side by side `A = [[2,-1],[-1,2]]`. Trace 4, determinant `4 - 1 = 3`, so `lambda^2 - 4*lambda + 3 = 0` and the eigenvalues are `3` and `1`. Both strictly positive, so `A` is positive definite. Being PD it is invertible, its inverse is also PD, its determinant is positive, and its quadratic form carves out proper ellipses. `B = [[1,1],[1,1]]`. Trace 2, determinant `1 - 1 = 0`, so the eigenvalues are `2` and `0`. All nonnegative, so `B` is PSD, but not PD. The failure is explicit in the quadratic form: ``` x^T B x = x1^2 + 2*x1*x2 + x2^2 = (x1 + x2)^2 ``` This is never negative, but it vanishes on the whole line `x1 = -x2`, i.e. at `(1,-1)`, which is exactly the eigenvector for `lambda = 0`. So the boundary between PD and PSD is precisely whether some nonzero direction is annihilated. ## Why the zero eigenvalue is a practical event, not a technicality The determinant is the product of the eigenvalues, so a zero eigenvalue forces a zero determinant: the matrix is singular and has **no inverse**. Consequences that show up in real work: - Anything that requires inverting the matrix fails outright, and anything that inverts a *nearly* singular matrix returns huge, noise-dominated values. - A Cholesky factorization, which exists only for positive definite matrices, breaks down; it is in fact the standard cheap test for positive definiteness. - For a covariance matrix, `x^T C x` is the variance of the data projected onto `x`. A zero eigenvalue therefore says some linear combination of the variables has **zero variance** — an exact linear dependency among them. Perfectly redundant features, a set of proportions that sums to one, or a dummy-coded variable that kept every level all produce this. A sample covariance matrix is *always* PSD, because it is built as a sum of outer products and so `x^T C x` is an average of squares. It is positive definite only when no such exact dependency exists **and** there are enough observations: with `d` variables and `n` points, the rank cannot exceed `min(n - 1, d)`, so with fewer observations than variables the matrix is guaranteed singular no matter how clean the data is. ## Tests and traps Things that do **not** establish positive definiteness: - **Positive entries.** `[[1,2],[2,1]]` has all entries positive but eigenvalues `3` and `-1`, so it is indefinite. Conversely a PD matrix may have negative entries, as `[[2,-1],[-1,2]]` shows. - **Positive determinant alone.** `[[-1,0],[0,-1]]` has determinant `+1` yet both eigenvalues are `-1`: negative definite. In two dimensions you need positive determinant *and* a positive diagonal entry. - **Symmetry.** Symmetry is a prerequisite for the question to be well posed, not an answer to it. Things that do work: all eigenvalues positive; all **leading principal minors** positive (Sylvester's criterion); or a successful Cholesky factorization. Positive diagonal entries are *necessary* but not sufficient — necessary because `e_i^T A e_i = A[i][i]` must be positive for a PD matrix. ## Repairing a matrix that should have been PD If a matrix that ought to be PD comes back with a tiny negative eigenvalue from rounding, the common repairs are to clip the negative eigenvalues to zero and rebuild the matrix from its eigendecomposition, or to add a small multiple of the identity. The second works because the eigenvalues of `A + eps*I` are exactly `lambda_i + eps`, which shifts the whole spectrum upward while keeping every eigenvector unchanged. Both are deliberate modelling choices with consequences, not free fixes: they change the matrix, so the size of `eps` needs justifying rather than defaulting.

  • Is a symmetric matrix with all positive entries necessarily positive definite?
    No. `[[1,2],[2,1]]` has all entries positive but eigenvalues `3` and `-1`, so it is indefinite. The signs of the entries and the signs of the eigenvalues are different questions. In the other direction, `[[2,-1],[-1,2]]` has negative off-diagonal entries and is positive definite with eigenvalues `3` and `1`.
  • Why is a sample covariance matrix always at least positive semidefinite?
    Because `x^T C x` is the sample variance of the data projected onto `x`, and a variance is an average of squared deviations, which can never be negative. It fails to be positive definite exactly when some projection has zero variance: an exact linear dependency among the variables, or fewer observations than variables, since the rank cannot exceed min(n - 1, d).
  • What happens to the eigenvalues when you add a small multiple of the identity?
    Every eigenvalue shifts up by that constant and every eigenvector stays the same, since `(A + eps*I)v = (lambda + eps)v`. That turns a PSD matrix into a positive definite one and pulls a near-singular matrix away from the cliff. It is a deliberate change to the matrix, though, so the size of the shift has to be justified rather than chosen for convenience.

saying these in an interview costs you the question

  • Thinks PSD means all entries are nonnegative
  • Claims a positive determinant alone proves positive definiteness
  • Says positive diagonal entries are sufficient for definiteness
  • Treats positive definite and positive semidefinite as interchangeable
  • Forgets a zero eigenvalue makes the matrix non-invertible
  • Applies definiteness to a non-symmetric matrix without comment

context