14.4  Completing the Square

Every symmetric matrix over R can be diagonalized by an orthogonal matrix, which is Chapter 12’s spectral theorem. That theorem needs R, an inner product and the existence of eigenvalues. This section proves a weaker conclusion under far weaker hypotheses: over any field of characteristic ≠2, with no inner product, no order and no eigenvalues available, every symmetric form still becomes diagonal after a change of basis — provided we ask only for congruence, not for similarity. The proof is one algebraic manipulation, completing the square, run by induction; and the induction has a case that a careless proof loses.

Throughout, F is a field with charF≠2 (Definition 0.7.2), V is a finite-dimensional vector space over F, β is a symmetric bilinear form on V (Definition 14.3.1), and q(v)=β(v,v) is its quadratic form (Definition 14.3.2).

14.4.1. Orthogonality without an inner product

Chapter 11 called two vectors orthogonal when their inner product vanished. The word survives the loss of positivity unchanged, because only the vanishing was ever used.

Definition 14.4.1 (Orthogonal Basis for a Form)

Let β be a bilinear form on V. Vectors u,v∈V are orthogonal with respect to β if β(u,v)=0. An ordered basis B=(v1,…,vn) of V is an orthogonal basis for β if β(vi,vj)=0whenever i≠j.

The definition is engineered to say exactly one thing about matrices: by Definition 14.1.2, B is an orthogonal basis for β precisely when [β]BB is a diagonal matrix, with q(v1),…,q(vn) down the diagonal. Two warnings come free. The vectors of such a basis are not required to satisfy q(vi)=1, and over a general field they usually cannot be rescaled to. And a vector may be orthogonal to itself: q(vi)=0 is allowed, and for a degenerate form it is unavoidable.

What an orthogonal basis buys is that q becomes a sum of squares with no cross terms. If v=c1v1+⋯+cnvn and di=q(vi), then expanding by bilinearity and deleting the i≠j terms,

q(v)=∑i=1ndici2.
(14.4.1)

That is the “sum of squares” a reader has met when completing the square in two variables, and Eq. 14.4.1 is the reason the whole section is called what it is.

14.4.2. The theorem, and the case that breaks it

Here is the naive argument, and it is worth seeing it fail. To make q(v)=ax12+2bx1x2+cx22 into a sum of squares, write q=a(x1+bax2)2+(c−b2a)x22, which is exactly a change of variable. The step divides by a=q(e1). If a=0 there is nothing to complete, and one may hope to start with x2 instead — but q(x)=2x1x2 has q(e1)=q(e2)=0, and neither variable offers a foothold. The repair is to change the vector, not the variable: q(e1+e2)=2≠0. That repair is a lemma, and it is where charF≠2 is spent.

Lemma 14.4.1 (A Non-Zero Form Is Non-Zero Somewhere on the Diagonal)

Let charF≠2 and let β be a symmetric bilinear form on V with β≠0. Then there exists v∈V with q(v)≠0.

Proof. Since β≠0, there are u,w∈V with a=β(u,w)≠0. If q(u)≠0 or q(w)≠0 we are done. So suppose q(u)=q(w)=0. Expanding by bilinearity and using symmetry, q(u+w)=q(u)+2β(u,w)+q(w)=(1+1)a. Since charF≠2, the element 1+1 is non-zero, and a product of two non-zero elements of a field is non-zero, so q(u+w)≠0. This proves the lemma.

Contrapositively: if q vanishes identically then β=0. That is the case the induction must handle separately, and the lemma is what lets it be handled in one line.

Theorem 14.4.2 (Diagonalization of a Symmetric Form)

Let F be a field with charF≠2, let V be a finite-dimensional vector space over F, and let β be a symmetric bilinear form on V. Then V has an orthogonal basis for β.

Equivalently: every symmetric A∈Mn(F) is congruent to a diagonal matrix, that is, there is an invertible P∈Mn(F) with P⊤AP diagonal.

Idea. Induction on dim⁡V. The step wants to peel off one basis vector and recurse on a complement, exactly as “peel off an eigenvector” does in Chapter 9 — but the complement here is the set of vectors orthogonal to the chosen one, not an invariant subspace, and it is available only if the chosen v1 has q(v1)≠0. So the proof splits into two steps: ① if q vanishes everywhere, the form is zero and every basis is orthogonal; ② otherwise Lemma 14.4.1 supplies a v1 with q(v1)≠0, the linear functional w↦β(v1,w) is non-zero, its kernel W is a hyperplane meeting span(v1) trivially, and the induction hypothesis applies to β restricted to W. Step ① is not a formality: without it the argument has no base for the recursion when the form degenerates, and the word “equivalently” in the statement would be unearned.

Proof. We induct on n=dim⁡V. If n=0 the empty basis is orthogonal, vacuously; if n=1 any basis (v1) is orthogonal, since there is no pair i≠j. Let n≥2 and suppose the result holds for all spaces of dimension n−1 over F.

Step 1: the form vanishes on the diagonal. Suppose q(v)=0 for every v∈V. By Lemma 14.4.1, read contrapositively, β=0. Then β(vi,vj)=0 for every pair of vectors whatsoever, so any basis of V is an orthogonal basis for β, and its matrix is 0, which is diagonal.

Step 2: the form does not vanish on the diagonal. Otherwise there is v1∈V with c=q(v1)≠0; in particular v1≠0. Define φ:V→F,φ(w)=β(v1,w). Then φ is linear, because β is linear in its second argument, and φ(v1)=c≠0, so φ≠0. A non-zero functional is surjective onto F (Proposition 5.1.2), so rankφ=1 and, by the Rank–Nullity Theorem (Theorem 2.3.1), W=kerφ has dim⁡W=n−1.

Moreover span(v1)∩W={0}: if av1∈W then 0=φ(av1)=ac, and c≠0 forces a=0. So the sum span(v1)+W is direct, and dim⁡(span(v1)+W)=1+(n−1)=n, both by Theorem 1.7.4. A subspace of V of dimension dim⁡V is all of V (Theorem 1.6.8), so V=span(v1)⊕W.

The restriction of β to W×W is a bilinear form on W, and it is symmetric because β is. As dim⁡W=n−1, the induction hypothesis provides an orthogonal basis (v2,…,vn) of W for that restriction.

Concatenating bases of the summands of a direct sum gives a basis of it (Theorem 1.7.5, (a) ⇔ (d)), so B=(v1,v2,…,vn) is a basis of V. It is orthogonal for β: for j≥2 we have vj∈W=kerφ, so β(v1,vj)=φ(vj)=0, and β(vj,v1)=0 by symmetry; and for 2≤i≠j the value β(vi,vj) is 0 by the choice of the basis of W. This completes the induction.

For the matrix statement, let A∈Mn(F) be symmetric and let β(x,y)=x⊤Ay on V=Fn, which is symmetric by Proposition 14.3.1 and has [β]EE=A in the standard basis E. Take an orthogonal basis B as above and let P=[id]BE, the matrix whose columns are the vectors of B, which is invertible. By Theorem 14.2.1, [β]BB=P⊤AP, and this matrix is diagonal. This proves the theorem.

Two hypotheses did visible work. Symmetry was used twice: to make β(vj,v1) vanish along with β(v1,vj), and to keep the restriction to W symmetric so the induction could run. The characteristic hypothesis was used exactly once, inside Lemma 14.4.1 — and that single use is essential: Exercise C2 below exhibits a symmetric matrix over F2 that is congruent to no diagonal matrix at all.

Warning. Diagonal does not mean “the diagonal entries are eigenvalues”. The matrix P⊤AP of Theorem 14.4.2 is congruent to A, not similar to it, and its entries are the values q(vi) at whatever basis the algorithm happened to produce. Over R they can be scaled at will: replacing vi by tvi replaces di by t2di. There is no canonical list of numbers here. The next section finds what there is.

Quick check. In Theorem 14.4.2, how many of the diagonal entries di are zero?

Solution. Exactly n−rankA of them. A diagonal matrix has rank equal to its number of non-zero entries, and congruence preserves rank (Theorem 14.2.3), so the count is the same for every orthogonal basis even though the individual di are not. In the language of Section 1, those vi with di=0 span the radical rad(β) of Definition 14.1.3, since in an orthogonal basis such a vi pairs to zero with every basis vector; and β is non-degenerate (Definition 14.1.4) exactly when no di is zero.

14.4.3. The algorithm: symmetric row and column operations

The proof is constructive, but running it by hand means chasing kernels of functionals. There is a bookkeeping device that does the same work on the matrix directly, and it is the practical content of this section.

The key observation is that a congruence by an elementary matrix is a pair of operations. Let E be an elementary matrix (Definition 3.4.1). Right multiplication AE performs a column operation, and left multiplication E⊤A performs the corresponding row operation. So A↦E⊤AE performs both, and the result is congruent to A and again symmetric. Doing the operations in pairs is exactly what keeps the matrix symmetric, and that is the whole idea.

Algorithm. To diagonalize a symmetric A∈Mn(F) by congruence, write A and In side by side and repeat, for i=1,2,…,n in turn:

  • If aii=0 but some ajj≠0 with j>i, swap rows i,j and then columns i,j.
  • If aii=0 and every ajj=0 for j≥i, look for an entry aij≠0 with j>i. If there is none, then row i and column i are already zero in every position, so move on to i+1. If there is one, add row j to row i, then column j to column i; the new aii is 2aij≠0.
  • Now aii≠0. For each j>i with aij≠0, subtract (aij/aii) times row i from row j, then (aij/aii) times column i from column j.

Over a field where division is inconvenient — Q or Z-valued data by hand — the clearing step may instead be done as row j↦aiirow j−aijrow i, with the matching column operation. That is the same move composed with scaling row and column j by aii≠0, which is itself a congruence, so it is legitimate; it keeps the entries integral and changes the diagonal result only by square factors. The worked example below takes this route.

Perform only the column half of each operation on the matrix standing to the right. When A has become diagonal, that matrix is P, and P⊤AP is the diagonal result.

The second bullet is Lemma 14.4.1 made mechanical, and the factor 2=1+1 in it is where the algorithm would stop in characteristic 2. The right-hand matrix works because applying the column operations E1,E2,…,Ek in order turns I into E1E2⋯Ek, which is the product whose transpose and self sandwich A.

Example (Diagonalizing a symmetric matrix with zero diagonal)

Over Q, diagonalize A=(011101110) by congruence, producing an invertible P with P⊤AP diagonal.

Solution. The form is q(x)=2x1x2+2x1x3+2x2x3: every diagonal entry is 0, so there is no square to complete yet, and the second bullet applies.

Step 1 (create a pivot). Add row 2 to row 1, then column 2 to column 1. The matrix becomes (112101110) ⟶ (212101210), the left matrix after the row operation and the right one after the matching column operation. The new corner entry is q(e1+e2)=2.

Step 2 (clear the first row and column, in two paired moves). Rather than divide by 2, use the operation “row 2↦2⋅row 2−row 1”, which is a scaling followed by an addition, hence a congruence by a product of two elementary matrices, and legitimate because 2≠0 in Q. Apply it and its column partner. This keeps every entry an integer: (2120−10210) ⟶ (2020−20200). Then “row 3↦row 3−row 1” and its column partner: (2020−2000−2) ⟶ (2000−2000−2).

The transforming matrix. Applying the three column operations to I3 in the same order gives I3→(100110001)→(1−10110001)→(1−1−111−1001)=P. Here detP=2≠0, so P is invertible, and P⊤AP=diag(2,−2,−2). The check is one column at a time: with p1=(1,1,0), p2=(−1,1,0) and p3=(−1,−1,1), we get q(p1)=2, q(p2)=−2 and q(p3)=2−2−2=−2, while β(p1,p2)=p1⊤Ap2=(1,1,0)⋅(1,−1,0)=0 and similarly for the other two pairs.

Two observations about that example. The determinants are detA=2 and det(P⊤AP)=8, and they differ by (detP)2=4: a congruence multiplies the determinant by a square, which is the discriminant statement of Section 2. And the eigenvalues of A are 2,−1,−1, whose signs are +,−,− — the same pattern of signs as 2,−2,−2, with none of the same numbers. That coincidence is Section 5.

14.4.4. Over the complex numbers, and over a general field

The diagonal entries produced by the algorithm are not canonical, but there is a precise statement of how much freedom remains.

Proposition 14.4.3 (Diagonal Entries Are Defined Only up to Squares)

Let B=(v1,…,vn) be an orthogonal basis for β with di=q(vi), and let t1,…,tn∈F be non-zero. Then (t1v1,…,tnvn) is again an orthogonal basis for β, with diagonal entries ti2di.

Proof. Scaling basis vectors by non-zero scalars again gives a basis. For i≠j, bilinearity gives β(tivi,tjvj)=titjβ(vi,vj)=0, so the new basis is orthogonal; and q(tivi)=ti2q(vi)=ti2di.

So each non-zero di can be changed to any other element of its coset in the group F×/(F×)2 of square classes, and no further, by this move. How much that costs depends entirely on the arithmetic of F:

  • Over C, every element is a square, so there is exactly one non-zero square class and every non-zero di can be turned into 1.
  • Over R, the squares are the positive numbers, so there are two classes and every non-zero di can be turned into 1 or −1, according to its sign — the subject of the next section.
  • Over Q there are infinitely many classes (2,3,5,… are pairwise inequivalent), so the 1-dimensional forms q(x)=x2 and q(x)=2x2 are already non-congruent.
  • Over Fp with p odd there are exactly two classes, as for R, but “which class” is not a matter of sign.

The complex case collapses completely.

Corollary 14.4.4 (Classification of Complex Symmetric Matrices by Rank)

Let A∈Mn(C) be symmetric of rank r. Then A is congruent to Ir⊕0n−r=diag(1,…,1⏟r,0,…,0). Consequently two symmetric matrices in Mn(C) are congruent if and only if they have the same rank, and there are exactly n+1 congruence classes.

Proof. By Theorem 14.4.2 (with charC=0) there is an invertible P1 with P1⊤AP1=D=diag(d1,…,dn) diagonal. Congruence preserves rank (Theorem 14.2.3), and the rank of a diagonal matrix is its number of non-zero entries, so exactly r of the di are non-zero. Permuting the basis vectors is a congruence by a permutation matrix P2, so we may assume d1,…,dr≠0 and dr+1=⋯=dn=0.

Every non-zero complex number has a square root, so choose si∈C with si2=di for i≤r, and set ti=1/si for i≤r and ti=1 otherwise. By Proposition 14.4.3 the congruence by P3=diag(t1,…,tn) replaces di by ti2di, which is 1 for i≤r and 0 otherwise. So P⊤AP=Ir⊕0n−r with P=P1P2P3.

For the classification: congruent matrices have equal rank by Theorem 14.2.3, and matrices of equal rank are both congruent to the same normal form, hence to each other by Proposition 14.2.2. The possible ranks are 0,1,…,n, giving n+1 classes. This proves the corollary.

Contrast this with similarity, where complex symmetric matrices are not classified by anything so simple: the matrix (1ii−1) is symmetric, non-zero, and satisfies A2=0, so it is not even diagonalizable as an operator. Congruence is a coarser relation than similarity on symmetric matrices, and over C it is coarse enough to be finite.

14.4.5. Exercises

A. Check your understanding

Exercise (A1)
  • (a) Define what it means for an ordered basis to be an orthogonal basis for a bilinear form β, and say what that means about [β]BB.
  • (b) State Theorem 14.4.2 with all of its hypotheses.
  • (c) Which step of the proof uses charF≠2, and what exactly is divided by?
  • (d) Determine whether the following statement is correct, and justify your answer: if P⊤AP=diag(d1,…,dn), then the di are the eigenvalues of A.
  • (e) Describe the pair of operations that a congruence by an elementary matrix performs.

Solution.

  • (a) B=(v1,…,vn) is orthogonal for β if β(vi,vj)=0 whenever i≠j. Equivalently [β]BB is diagonal, with entries q(vi).

  • (b) If charF≠2, V is finite-dimensional over F and β is a symmetric bilinear form on V, then V has an orthogonal basis for β; equivalently every symmetric A∈Mn(F) is congruent to a diagonal matrix.

  • (c) Lemma 14.4.1, inside Step 2 of the proof. It produces q(u+w)=(1+1)β(u,w) and needs 1+1≠0 to conclude that this is non-zero. Equivalently, the algorithm’s repair move multiplies by 2, so it needs 2≠0.

  • (d) Incorrect. The relation is congruence, not similarity. In Example (Diagonalizing a symmetric matrix with zero diagonal) the diagonal entries are 2,−2,−2 while the eigenvalues are 2,−1,−1. Only the signs matched there, and Section 5 explains why.

  • (e) A column operation and the matching row operation: A↦E⊤AE. Performing both keeps the matrix symmetric and keeps it in the same congruence class.

B. Practice

Exercise (B1: Symmetric elimination)

Over Q, let A=(120213031). Diagonalize A by paired row and column operations, exhibiting P and P⊤AP.

Solution. Here a11=1≠0, so the pivot is already available.

Clear the first row and column. Subtract 2× row 1 from row 2, then 2× column 1 from column 2. The entry a13 is already 0, so nothing else is needed in this round: (1200−33031) ⟶ (1000−33031).

Clear the second row and column. The pivot is −3, and a23=3, so add row 2 to row 3 and then column 2 to column 3: (1000−33004) ⟶ (1000−30004).

The transforming matrix. Applying the two column operations to I3 gives P=(1−2−2011001),P⊤AP=diag(1,−3,4). As a check, detP=1 and detA=−12=detdiag(1,−3,4).

Exercise (B2: No pivot on the diagonal)

Over Q, let A=(0110) and q(x)=2x1x2.

  • (a) Find a vector v with q(v)≠0, as in Lemma 14.4.1.
  • (b) Diagonalize A by paired operations and exhibit P.
  • (c) Write q as a difference of two squares in the new coordinates.

Solution.

  • (a) Both e1 and e2 give q=0, so take v=e1+e2: q(v)=2≠0.

  • (b) Add row 2 to row 1, then column 2 to column 1, reaching (2110). Then apply “row 2↦2⋅row 2−row 1” and its column partner, reaching diag(2,−2). Applying the same two column operations to I2 gives P=(1−111),P⊤AP=diag(2,−2). Check directly: P⊤A=(111−1) and multiplying by P gives (200−2).

  • (c) With x=Py, that is x1=y1−y2 and x2=y1+y2, we get q=2(y1−y2)(y1+y2)=2y12−2y22. This is the familiar identity ab=(a+b2)2−(a−b2)2 read as a change of variable, and it needs 2 to be invertible.

Exercise (B3: Reading off the rank)

Let A∈M4(C) be symmetric with rankA=3. Write down the normal form of A under congruence, and say how many congruence classes of symmetric matrices there are in M4(C).

Solution. By Corollary 14.4.4, A is congruent to I3⊕01=diag(1,1,1,0). Since rank is a complete invariant there, the classes correspond to the possible ranks 0,1,2,3,4, so there are 5 of them.

C. Going deeper

Exercise (C1: Square classes over a finite field)

Work over F5, whose non-zero squares are 1 and 4.

  • (a) Prove that the 1×1 matrices (1) and (2) are not congruent over F5.
  • (b) Prove that I2 and 2I2 are congruent over F5, by exhibiting a P.
  • (c) Explain why (a) and (b) are consistent with Proposition 14.4.3.

Hint: for (b), look for two vectors p1,p2 with pi⋅pi=2 and p1⋅p2=0.

Solution.

  • (a) A congruence of 1×1 matrices is (a)↦(p2a) with p≠0. So (1) and (2) are congruent exactly when 2=p2 for some p∈F5×. The squares of 1,2,3,4 are 1,4,4,1, so 2 is not a square and the two are not congruent.

  • (b) Take p1=(1,1) and p2=(1,4). Then p1⋅p1=2, p2⋅p2=1+16=17=2 and p1⋅p2=1+4=5=0 in F5. With P=(1114),detP=4−1=3≠0, we get P⊤I2P=P⊤P=diag(2,2)=2I2.

  • (c) Proposition 14.4.3 only says what rescaling a single basis vector can do, and that move cannot change a square class. Part (b) does not contradict it, because the congruence there is not diagonal: it mixes the two coordinates, and both diagonal entries change square class at once. What is invariant is the class of their product, the determinant: detI2=1 and det(2I2)=4 differ by 4=22, a square.

Exercise (C2: Is this still true over F2?)

Let A=(0110) over F2, and let β(x,y)=x⊤Ay on F22.

  • (a) Prove that β is alternating.
  • (b) Prove that if P∈M2(F2) is invertible, then every diagonal entry of P⊤AP is 0.
  • (c) Deduce that A is congruent to no diagonal matrix except the zero matrix, and hence that Theorem 14.4.2 fails over F2.

Solution.

  • (a) By Proposition 14.3.2 (b): over F2 we have −A=A, so A⊤=A=−A, and the diagonal entries of A are 0. (Directly: β(x,x)=2x1x2=0.)

  • (b) The i-th diagonal entry of P⊤AP is pi⊤Api=q(pi), where pi is the i-th column of P. By (a), q vanishes identically, so every diagonal entry is 0.

  • (c) A diagonal matrix congruent to A has all diagonal entries 0 by (b), hence is the zero matrix. But congruence preserves rank (Theorem 14.2.3) and rankA=2≠0=rank0. So no diagonal matrix is congruent to A. Since A is symmetric over F2, the conclusion of Theorem 14.4.2 fails there, and the hypothesis charF≠2 cannot be dropped.

Exercise (C3: Diagonalizing the restriction)

Let charF≠2, let β be a symmetric bilinear form on V, and let U⊆V be a subspace.

  • (a) Prove that U has an orthogonal basis for the restriction of β to U.
  • (b) Give an example, with dim⁡V=2, in which β is non-degenerate but its restriction to some 1-dimensional U is the zero form.
  • (c) Deduce that an orthogonal basis of U cannot always be extended to an orthogonal basis of V by adding vectors of U alone, and say in one sentence what Theorem 14.4.2 does guarantee instead.

Solution.

  • (a) The restriction β|U×U is bilinear, since it is the same function on a smaller domain, and symmetric for the same reason. U is finite-dimensional, being a subspace of a finite-dimensional space (Theorem 1.6.7). So Theorem 14.4.2 applies to (U,β|U×U) directly.

  • (b) Over Q take β(x,y)=x1y2+x2y1 on Q2, with matrix (0110), which is invertible, so β is non-degenerate. Put U=span(e1). Then β(ae1,be1)=0 for all a,b, so the restriction is the zero form even though β is not.

  • (c) In (b) the single vector e1 is an orthogonal basis of U, but no vector of U can be added to it, and any orthogonal basis of V for this β must consist of vectors v with q(v)≠0 (its matrix is diagonal and invertible), so e1 belongs to none of them. What the theorem guarantees is only the existence of some orthogonal basis of V, built from scratch; it promises nothing about extending a given orthogonal list, and Section 8 is where a correct extension statement finally appears.

Found a typo or a mistake? Report it, or read this page’s source

The text of this book is licensed under CC BY-NC-SA 4.0.