Sylvester's Criterion Calculator
Introduction: Classifying symmetric matrices with Sylvester's criterion
This Sylvester's criterion calculator tests the definiteness of a real symmetric matrix using Sylvester's criterion. For a chosen size (2×2, 3×3, or 4×4), you enter the entries of a symmetric matrix. The tool computes leading principal minors (determinants of the top-left k×k blocks) for strict definiteness and all principal minors for semidefinite cases, then classifies the matrix as positive definite, negative definite, positive semidefinite, negative semidefinite, or indefinite, when possible.
How to use the Sylvester's criterion calculator for symmetric matrices
- Choose the matrix size. Select 2×2, 3×3, or 4×4 from the matrix size menu. This Sylvester's criterion calculator evaluates these matrix sizes and lists the necessary minors.
-
Enter a real symmetric matrix.
Fill in the matrix entries using real numbers (integers, decimals, or
fractions in decimal form). Sylvester's criterion is stated for
real symmetric matrices, so in theory you should have
aij = aji. If you enter a non-symmetric matrix, the calculator stops and asks you to correct the mirrored entries before it applies the definiteness tests. - Run the definiteness test. Click the button to evaluate the matrix. The script builds each leading principal submatrix, computes its determinant, and then analyzes the determinant signs.
- Read the matrix classification. The result identifies whether the symmetric matrix is positive definite, negative definite, semidefinite, or indefinite, and displays the determinant values used in that classification.
Sylvester's criterion is useful for checking Hessian matrices in optimization, assessing covariance-like matrices in statistics, or studying stability in differential equations without explicitly finding eigenvalues.
Key formulas: leading principal minors in Sylvester's criterion
For this Sylvester's criterion test, let A be an n×n real symmetric matrix. For each k = 1, 2, …, n, the k-th leading principal minor is the determinant of the top-left k×k block of A. Denote this determinant by Δk.
In compact form, if we write the k×k leading principal submatrix as Ak, then
Delta_k = det(A_k)
For the small symmetric matrices accepted here, the leading minors are explicit. For a 2×2 matrix
A = [ [a, b],
[b, c] ]
- Δ1 = a
- Δ2 = det(A) = ac − b2
For a 3×3 matrix
A = [ [a, d, e],
[d, b, f],
[e, f, c] ]
- Δ1 = a
- Δ2 = det of the top-left 2×2 block = ab − d2
- Δ3 = det(A), which can be expanded by standard determinant formulas.
Sylvester's criterion for a real symmetric matrix states:
- A is positive definite if and only if Δk > 0 for all k = 1, …, n.
- A is negative definite if and only if the signs of Δk alternate starting with negative: Δ1 < 0, Δ2 > 0, Δ3 < 0, …
When a symmetric matrix has zero minors, the strict Sylvester tests do not establish definiteness. The calculator then examines all principal minors for positive or negative semidefiniteness.
Interpreting Sylvester's criterion calculator results
The Sylvester's criterion result first uses leading principal-minor signs for strict definiteness, then uses every principal minor for semidefinite cases, assigning one of the following labels:
- Positive definite – all leading principal minors are strictly positive.
- Negative definite – the signs alternate starting with negative: Δ1 < 0, Δ2 > 0, Δ3 < 0, and so on.
- Indefinite – the principal-minor checks rule out both positive and negative semidefiniteness, so the associated quadratic form takes both signs.
- Positive semidefinite – all principal minors are nonnegative, with at least one zero or near-zero value. The calculator checks every principal minor for the selected 2×2, 3×3, or 4×4 size before using this label.
- Negative semidefinite – the principal minors match the sign pattern for -A: odd-order principal minors are nonpositive and even-order principal minors are nonnegative, again with at least one zero or near-zero value.
Because determinant signs can be affected by floating-point rounding, the script treats values extremely close to zero as zero within a small numerical tolerance. This prevents a tiny computational residue from changing a matrix classification.
Worked examples of Sylvester's criterion on symmetric matrices
Example 1: 2×2 positive definite matrix under Sylvester's criterion
Consider the symmetric 2×2 matrix
A = [ [2, 1],
[1, 2] ].
The leading principal minors are
- Δ1 = 2
- Δ2 = det(A) = 2·2 − 1·1 = 3
Both minors are positive, so Sylvester's criterion identifies the matrix as positive definite. The quadratic form xTAx is strictly positive for every nonzero vector x.
Example 2: 3×3 symmetric matrix with positive leading minors
Consider the symmetric 3×3 matrix
A = [ [4, 1, 2],
[1, 3, 0],
[2, 0, 5] ].
Its leading principal minors are
- Δ1 = 4
- Δ2 = det of the top-left 2×2 block = 4·3 − 1·1 = 11
- Δ3 = det(A) = 43.
Since all three leading minors are strictly positive, the calculator reports that A is positive definite.
If the 4 in the upper-left corner is replaced with −4, the new matrix has first and second leading minors −4 and −13. Those signs do not meet either strict Sylvester sign pattern, and the full principal-minor check classifies that matrix as indefinite.
Summary of Sylvester sign patterns and matrix classifications
This table summarizes how the Sylvester's criterion calculator reads leading principal minors for strict definiteness and all principal minors for semidefinite classifications.
| Condition checked | Typical classification | What it means for xTAx |
|---|---|---|
| Δk > 0 for all k = 1, …, n | Positive definite | Strictly positive for all nonzero x; unique minimum at the origin for the associated quadratic form. |
| Δ1 < 0, Δ2 > 0, Δ3 < 0, … (alternating signs) | Negative definite | Strictly negative for all nonzero x; unique maximum at the origin. |
| Principal minors rule out positive semidefiniteness and negative semidefiniteness | Indefinite | Takes both positive and negative values; typical of saddle points in optimization. |
| All principal minors are nonnegative, with at least one zero or near-zero value | Positive semidefinite | Never negative, but may be zero for some nonzero x. |
| Odd-order principal minors are nonpositive and even-order principal minors are nonnegative, with at least one zero or near-zero value | Negative semidefinite | Never positive, but may be zero for some nonzero x. |
| One or more Δk numerically very close to zero while others fit a definite pattern | Borderline / sensitive case | Classification may depend on numerical tolerance; consider rerunning with higher precision or symbolic methods. |
Limitations, assumptions, and special cases for Sylvester's criterion
- Real symmetric matrices only. Sylvester's criterion, and the classifications used by this calculator, are valid for real symmetric matrices. The script does not automatically symmetrize your input; it uses the exact numbers you type. If your matrix is not symmetric, it asks you to correct the mirrored entries before continuing.
- Zero determinants and semidefiniteness. When one or more leading principal minors are exactly zero, strict definiteness is ruled out. The calculator then checks all principal minors to classify positive semidefinite, negative semidefinite, or indefinite behavior.
- Numerical rounding. Determinants are computed using floating-point arithmetic. Very small nonzero determinants may appear as zero within machine precision. To reduce misclassification, the script uses a tolerance and treats |Δk| below that threshold as zero. For highly ill-conditioned matrices, consider using exact or high-precision linear algebra tools.
- No eigenvalues or optimization solutions. This calculator does not compute eigenvalues, eigenvectors, or solve optimization problems. It applies determinant-based criteria: leading principal minors for strict definiteness and all principal minors for semidefiniteness.
- Matrix size limited to 4×4. The Sylvester test interface supports 2×2, 3×3, and 4×4 matrices. Larger matrices follow the same theory but require more computation; a CAS or numerical linear algebra package may be more appropriate for them.
Related matrix definiteness calculators and further study
After classifying a symmetric matrix with Sylvester's criterion, these related matrix tools can help examine the same object from another angle:
- Matrix determinant calculator – to compute determinants directly.
- Eigenvalue and eigenvector calculator – to confirm definiteness by checking that all eigenvalues are positive or all are negative.
- Hessian definiteness checker – to diagnose whether a critical point in an optimization problem is a minimum, maximum, or saddle point.
Used together, determinant and eigenvalue methods give complementary ways to study the curvature and stability information carried by real symmetric matrices.
Arcade Mini-Game: Sylvester's Criterion Matrix Check
Use this quick arcade run to practice identifying a relevant matrix input while avoiding unreliable assumptions before checking definiteness.
Start the game, then use your pointer or arrow keys to catch useful inputs and avoid bad assumptions.
Status messages will appear here.
