TICKETS 03 OF 3 RUNS LEFTACC --
OUTCRY

← Guide BookPlay it

Gradient Lab

PSD Classifier

Classify a symmetric 2x2 matrix as positive definite, positive semidefinite, indefinite, or negative definite using trace and determinant - the test that decides whether it could be a covariance matrix.

How it works

Each round shows a random symmetric 2x2 matrix [[a, b], [b, c]] with integer entries - a and c drawn from -4 to 4, b from -3 to 3. You pick one of four labels: Positive definite, Positive semidefinite, Indefinite, or Negative definite.

The truth is computed, not authored, from trace and determinant: det = ac - b² and trace = a + c. If det < 0 the matrix is indefinite. If det ≥ 0 with a > 0 and trace > 0, it is positive definite when det > 0 and positive semidefinite when det = 0. If a < 0 and trace < 0 it is negative definite. In the remaining boundary cases (a = 0 with det ≥ 0), it counts as positive semidefinite only when b = 0 and both a and c are nonnegative; otherwise indefinite.

After each pick the reveal shows trace and det with a one-line explanation of what they imply about the eigenvalue signs, then you move to the next matrix.

How scoring works

A correct label adds 1 to score and extends your streak; a wrong one resets the streak to 0. Rounds count every pick. Each pick is also recorded against the linear-algebra skill in your progress profile as correct or incorrect.

Definiteness is about the sign of a quadratic form

For a symmetric matrix Σ, the object being classified is the quadratic form xᵀΣx = ax₁² + 2bx₁x₂ + cx₂². Positive definite means the form is strictly positive for every nonzero x; positive semidefinite allows it to touch zero; indefinite means it takes both signs; negative definite means it is always strictly negative.

For a symmetric matrix these definitions translate exactly into eigenvalue signs: both positive (PD), both nonnegative with at least one zero (PSD boundary), opposite signs (indefinite), both negative (ND). You never need the eigenvalues themselves, because for a 2x2 their product is det and their sum is trace - the two numbers the game shows you afterward.

This is why the intro mentions covariance matrices: a covariance matrix is exactly a symmetric PSD matrix, since xᵀΣx is the variance of the portfolio with weights x, and a variance cannot be negative. A candidate covariance with det < 0 is claiming some portfolio has negative variance - impossible, and instantly spottable.

The det-first decision tree

Run one fixed order every round. First compute det = ac - b². If det < 0, stop: the eigenvalues have opposite signs (their product is negative), so the matrix is indefinite - no other check needed, and the diagonal signs are irrelevant. This single test resolves a large share of rounds, and b² grows fast, so any sizable off-diagonal against a modest diagonal product tends to force indefiniteness.

If det > 0, the eigenvalues share a sign, and the trace (their sum) tells you which: trace > 0 means positive definite, trace < 0 means negative definite. With det > 0 you cannot have a zero eigenvalue, so the semidefinite labels are off the table.

If det = 0, one eigenvalue is exactly zero and the boundary labels come alive: positive trace means PSD (the other eigenvalue is positive), negative trace means the game classifies it under negative definite per its trace/det rule, and the fully degenerate cases hinge on b - the code accepts PSD only when b = 0 with a and c nonnegative. In play: det = 0 with any positive diagonal presence and b consistent means think semidefinite, not definite.

Sanity anchors that catch errors instantly

Diagonal entries are quadratic-form values at the coordinate directions: a = e₁ᵀΣe₁ and c = e₂ᵀΣe₂. So a negative diagonal entry immediately rules out PD and PSD, and a positive one immediately rules out ND - before you compute anything. Mixed diagonal signs (a > 0, c < 0) force indefiniteness on the spot, which det confirms since ac - b² < 0.

Sylvester's criterion is the same test in another costume: PD iff the leading minors a and ac - b² are both positive. It generalizes to any dimension - check all leading principal minors - which is the version interviewers ask about for 3x3 and beyond.

Keep the classic trap matrix in mind: [[1, 2], [2, 1]] has a positive diagonal and positive trace but det = 1 - 4 = -3, so it is indefinite. Positive diagonal entries are necessary, never sufficient - the off-diagonal coupling can drag one eigenvalue negative, which is exactly what b² subtracting from ac encodes.

A worked example

Round: classify Σ = [[3, -2], [-2, 2]].

Step 1 - determinant. det = ac - b² = 3·2 - (-2)² = 6 - 4 = 2 > 0. The eigenvalues share a sign, so the answer is either positive definite or negative definite - the semidefinite and indefinite labels are eliminated.

Step 2 - trace. trace = 3 + 2 = 5 > 0. Both eigenvalues positive: Positive definite.

Step 3 - verify against the definition. The eigenvalues solve λ² - 5λ + 2 = 0, giving λ ≈ 4.56 and 0.44 - both positive, product 2 (the det), sum 5 (the trace). And a direct probe: at x = (1, 1), xᵀΣx = 3 - 2 - 2 + 2 = 1 > 0; even the coupling-heavy direction stays positive.

Contrast: change c to 1, so Σ = [[3, -2], [-2, 1]]. Now det = 3 - 4 = -1 < 0 - indefinite immediately, despite both diagonal entries being positive. The direction x = (1, 2) gives xᵀΣx = 3 - 8 + 4 = -1: an explicit negative-variance direction, which is why this cannot be a covariance matrix.

Common mistakes

Judging from the diagonal alone. Positive a and c do not make a matrix PSD - if b² > ac, the off-diagonal coupling makes it indefinite. Always compute det.

Checking trace before det. Trace only identifies the shared sign after det ≥ 0 has established that the signs agree; with det < 0 a positive trace still means indefinite.

Conflating positive definite with positive semidefinite. In this game det > 0 with positive trace is PD, and det = 0 exactly is the semidefinite boundary - answering PSD when det is strictly positive is graded wrong.

Forgetting the sign rule of the product: det < 0 means opposite-sign eigenvalues, always indefinite - there is no other option, whatever a, b, c look like individually.

Ignoring the b term in degenerate cases. With a = 0, the matrix is only PSD if b = 0 too (and c ≥ 0); a zero diagonal entry with nonzero coupling produces a direction where the form goes negative.

Why interviews test this

Definiteness checks appear across the quant interview stack: is this a valid covariance or correlation matrix, is this Hessian telling me the critical point is a min, a max, or a saddle, and is this optimization problem convex. The 2x2 trace/det shortcut is the expected fluency level, with Sylvester's leading-minors criterion as the stated generalization.

Common phrasings to be ready for: fix the entry range that keeps [[1, ρ], [ρ, 1]] PSD (answer: |ρ| ≤ 1, from det = 1 - ρ² ≥ 0), explain why sample covariance matrices are always PSD, and classify a critical point from its Hessian - the second-derivative test in multivariable calculus is precisely this game.

Play PSD Classifier · All game guides · The arcade