Advanced maths

Quadratic form inertia calculator with congruence transformation

Find positive, negative and zero inertia of a rational symmetric quadratic form, with exact congruence diagonalization and an invertible coordinate map.

Your numbers

One rational row per line, comma-separated; at most 6 rows and columns.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

The inertia of a real symmetric quadratic form counts its positive, negative and zero directions. This calculator obtains those counts through exact rational congruence transformations rather than rounded eigenvalue signs. It returns an invertible S and diagonal D satisfying SᵀAS=D. Nonzero diagonal entries provide ordinary pivots; an off-diagonal two-coordinate pivot handles cases whose remaining diagonal entries are all zero. The diagonal coefficients describe a changed coordinate system and are not generally the eigenvalues of A.

THE FORMULAx=Sz gives xᵀAx=zᵀDz, with D=SᵀAS diagonal; inertia counts the positive, negative and zero diagonal entries.

A worked example

For A=((0,1),(1,0)), the quadratic form is 2x1x2. Every original diagonal entry is zero, but the form is not zero or semidefinite. Taking S=((1,1),(1,−1)) gives D=diag(2,−2), so x1=z1+z2 and x2=z1−z2 turn the form into 2z1²−2z2². Its inertia is one positive, one negative and zero null directions. This demonstrates why a procedure that stops after seeing zero diagonal entries would give the wrong classification.

Good to know

Exactly symmetric rational square matrices of order one through six. Decimal entries represent exact rationals; uncertain measurement thresholds are not inferred. Congruence uses rational diagonal pivots and invertible two-coordinate changes, with bounded fraction growth. D need not contain only −1,0,1 and need not list eigenvalues. The result classifies the entered form, not a general nonsymmetric matrix or stability of a noisy physical model.

Congruence preserves signs of directions rather than individual coefficients

An invertible coordinate transformation maps each nonzero direction bijectively to another direction. The largest dimensions of positive and negative subspaces therefore cannot change, which is the content of Sylvester’s inertia law. Scaling coordinates can change diagonal magnitudes while leaving their signs unchanged. This explains why two correct diagonalizations can show different coefficients yet agree on the three inertia counts.

Ordinary elimination with a nonzero diagonal pivot completes a square and removes its cross terms by a congruence shear. If every remaining diagonal is zero but an off-diagonal entry is nonzero, the associated two coordinates are mixed first to create positive and negative pivots. A completely zero remaining block contributes null directions. The solver retains every transformation so the final identity can be checked against the original matrix rather than trusting only the sign tally.

A form with zero diagonal can still have one positive and one negative direction2x1x2x1 = z1 + z2; x2 = z1 − z22(z1 + z2)(z1 − z2) = 2z1² − 2z2²Positive: 1; negative: 1; zero: 0
A=((0,1),(1,0)) gives 2x1x2. With x1=z1+z2 and x2=z1−z2, the form is 2z1²−2z2². The exact congruence diagonal is (2,−2), certifying inertia (1,1,0).

Read the quadratic form and its classification carefully

For a symmetric matrix, the off-diagonal entry a12 contributes 2a12x1x2 because both mirrored entries appear in xᵀAx. Entering the whole cross-term coefficient in each off-diagonal position doubles it again. The form 2x1x2 therefore uses ones off the diagonal, as in the worked example. A positive-definite result requires all directions positive; a positive-semidefinite result allows zero directions but no negative ones.

An indefinite form has at least one positive and one negative direction. A zero determinant alone cannot distinguish semidefinite from indefinite singular forms. The Symmetric matrix definiteness by leading minors calculator addresses a different criterion, whereas this page returns full inertia and a certificate even for zero or indefinite forms. Similarity uses S inverse A S and preserves eigenvalues; congruence uses SᵀAS and preserves inertia. Confusing these transformations would misinterpret the returned diagonal.

A few questions, answered

Are the diagonal entries of D the eigenvalues?

Generally no. D is obtained by congruence, not orthogonal similarity. Its signs give inertia, but its magnitudes depend on coordinate scaling.

Why is symmetry required?

The quadratic form depends on the symmetric part of a matrix. This page requires that part explicitly and does not silently discard an entered antisymmetric component.

Find your calculator

Start typing to explore the library.