JOVANA
Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Diagonalization, Rank, and Sylvester's Law

Every quadratic form diagonalizes by completing the square. The number of nonzero diagonal entries is the rank; over the reals the number of plus and minus signs is forced, and that rigidity is Sylvester's law of inertia — the signature is a genuine invariant.

Diagonalizing by completing the square

The first structural theorem: over any field of characteristic ≠ 2, every symmetric bilinear form admits an orthogonal basis — a basis in which the Gram matrix is diagonal. Equivalently every symmetric matrix is congruent to a diagonal one, and every quadratic form is equivalent to some ⟨d₁, …, dₙ⟩. The proof is just completing the square, done by an algorithm you already know from school but now run over a general field.

  1. If some diagonal entry q(eᵢ) = B(eᵢ, eᵢ) is nonzero, reorder so it is the first variable x₁; use it as a pivot.
  2. Gather every term containing x₁ and complete the square: a₁(x₁ + …)² where the “…” is a linear combination of x₂, …, xₙ. Substitute y₁ = x₁ + …, removing all cross terms with x₁.
  3. What remains is a quadratic form in x₂, …, xₙ alone; recurse on it.
  4. Edge case: if every diagonal entry is 0 but some B(eᵢ, eⱼ) ≠ 0, first substitute xᵢ ↦ xᵢ + xⱼ to create a nonzero square (this needs char ≠ 2), then proceed.
Diagonalize q(x1, x2, x3) = x1^2 + 2 x1 x2 + 2 x2 x3 over Q.

Pivot on x1:  x1^2 + 2 x1 x2 = (x1 + x2)^2 - x2^2.
  Set y1 = x1 + x2.   q = y1^2 - x2^2 + 2 x2 x3.

Now handle the rest:  -x2^2 + 2 x2 x3 = -(x2^2 - 2 x2 x3)
                    = -(x2 - x3)^2 + x3^2.
  Set y2 = x2 - x3,  y3 = x3.

  q = y1^2 - y2^2 + y3^2.        Diagonal form  <1, -1, 1>.

Rank = 3 (three nonzero entries), so q is nondegenerate.
Over R: one minus sign, two plus signs -> signature (2, 1), s = 2 - 1 = 1.
The change of variables is invertible, so this is a CONGRUENCE,
not an orthonormal (eigenvalue) diagonalization -- no square roots needed.
Completing the square one pivot at a time turns q into ⟨1, −1, 1⟩ using only rational operations — no eigenvalues.

Rank: the field-independent invariant

Once diagonalized as ⟨d₁, …, dₙ⟩, the number of nonzero dᵢ is the rank of the form — the rank of its Gram matrix, which congruence cannot change because P is invertible. The form is nondegenerate exactly when the rank equals dim V, i.e. all dᵢ ≠ 0. Rank is the *one* invariant that works over every field: over an algebraically closed field like ℂ it is the *only* invariant, since there every nonzero dᵢ becomes 1 after scaling by 1/(√dᵢ)² — so over ℂ a form is determined entirely by its rank, and ⟨d₁, …, dᵣ, 0, …⟩ ≅ ⟨1, …, 1, 0, …⟩.

Sylvester's law of inertia

Over ℝ we can scale each nonzero dᵢ to ±1 (divide by (√|dᵢ|)²), so every real form is congruent to ⟨1, …, 1, −1, …, −1, 0, …, 0⟩ with p ones, m minus-ones, and z zeros. The diagonalization is wildly non-unique, but [[sylvester-law-of-inertia|Sylvester's law of inertia]] says the triple (p, m, z) is not: any two diagonalizations of the same real form have the same number of positive, negative, and zero entries. The pair (p, m) is the [[signature-of-a-form|signature]]; often one reports the single number s = p − m.

The clean proof of uniqueness of p: it equals the maximal dimension of a subspace on which q is strictly positive. If U is a subspace where q > 0 (dimension p, the span of the “+” basis vectors) and W is where q ≤ 0 (dimension m + z, the rest), then U ∩ W = {0} because a vector in both has q both > 0 and ≤ 0. Hence dim U + dim W ≤ n, forcing p to be maximal and basis-independent. The same argument pins m. This dimension characterization is *intrinsic* — no basis mentioned — which is exactly why the count cannot depend on the chosen diagonalization.