Algebra

The signs no completion can change

A quadratic in several variables can be completed square by square in many orders, and each order hands back different coefficients. What no order changes is how many come out positive and how many negative — and that count, read off a completion of A − tI, says how many eigenvalues lie below t without finding a single one.

Worth reading first: Completing the square, by completing a square · One number under every bell.

Completing the square in one variable has exactly one way to go. The quadratic ax2+bx+cax^2 + bx + c has one square term, the missing corner is forced, and the answer a(x+b/2a)2+(c−b2/4a)a(x + b/2a)^2 + (c - b^2/4a) is the only one there is. Nothing about the method invites a choice.

In two variables the choice appears at the first step. The quadratic 2x2+6xy+3y22x^2 + 6xy + 3y^2 has two square terms and a cross term, and the cross term can be swallowed by either of them. Gather everything containing xx into a square and the leftover is a multiple of y2y^2:

2x2+6xy+3y2=2(x+32y)2−32y2.2x^2 + 6xy + 3y^2 = 2\left(x + \tfrac32 y\right)^2 - \tfrac32 y^2.

Gather everything containing yy instead and the leftover is a multiple of x2x^2:

2x2+6xy+3y2=3(y+x)2−x2.2x^2 + 6xy + 3y^2 = 3(y + x)^2 - x^2.

Both are correct, both are completions in exactly the sense the one-variable method taught, and they disagree about the coefficients: 22 and −32-\tfrac32 against 33 and −1-1. Neither is the “real” answer, because there is no real answer — a quadratic in two variables can be written as a sum of two squares in infinitely many ways, and each pair of new variables is as good as any other.

And yet something is shared. Each completion has one positive coefficient and one negative one. That is not a coincidence of this example, and the theorem that says so — Sylvester’s law of inertia, published by James Joseph Sylvester in 1852 — is the subject of this essay. It says that however a quadratic in any number of variables is completed into a sum of squares, the number of positive squares, the number of negative squares and the number of missing ones never change. The coefficients are opinions. Their signs are facts.

One form completed three ways, and the same straddle each time. The plane coloured by the sign of 2x² + 6xy + 3y². Three pairs of lines, one for completing with x first, one for y first and one along the eigenvectors; their coefficients are 2 and −3/2; 3 and −1; 5.541 and −0.541, and every pair has one line in a positive wedge and one in a negative wedge.
Fig. 1 The plane coloured by the sign of 2x2+6xy+3y22x^2 + 6xy + 3y^2, with the two lines on which it vanishes dashed. Each way of completing the square names two directions — the line along which one new variable changes while the other stays at nought — and three completions name three different pairs. Every pair puts exactly one direction where the quadratic is positive and one where it is negative.

What a completion actually names

The two completions above are not merely two rearrangements of symbols. Each one is a change of coordinates, and each change of coordinates is a statement about directions in the plane.

Take the first, 2u2−32v22u^2 - \tfrac32 v^2 with u=x+32yu = x + \tfrac32 y and v=yv = y. Setting v=0v = 0 means walking along the xx-axis, where only uu changes; there the quadratic is 2u22u^2, positive. Setting u=0u = 0 means walking along the line x=−32yx = -\tfrac32 y, where only vv changes; there it is −32v2-\tfrac32 v^2, negative. So the completion names one positive direction and one negative direction, and its two coefficients measure how steeply the quadratic grows along each.

The second completion, 3w2−z23w^2 - z^2 with w=y+xw = y + x and z=xz = x, names two other directions: the yy-axis, positive, and the line y=−xy = -x, negative. A third natural completion is the one along the eigenvectors of the symmetric matrix (2333)\begin{pmatrix} 2 & 3 \\ 3 & 3\end{pmatrix}, whose coefficients are the eigenvalues 5±372\tfrac{5 \pm \sqrt{37}}{2}, about 5.5415.541 and −0.541-0.541; its two directions are at right angles, which is the only thing that makes it special.

The hero figure draws all three pairs on the sign pattern of the quadratic, and the pattern is the point. The quadratic is zero on two lines through the origin — the dashed ones — and they cut the plane into four wedges, positive and negative alternately. Every completion puts exactly one of its directions in a positive wedge and one in a negative wedge. No completion can put both in the positive wedges, because then the quadratic would be positive on a whole plane’s worth of directions, and the negative wedges are not empty.

That is the whole proof in two dimensions, and it is a proof about the wedges rather than about any formula. The coefficients came from arithmetic that could have gone a hundred ways. The wedges came from the quadratic itself, before any coordinates were chosen, and they decide the signs.

One more thing the coefficients agree on

The three completions disagree about the size of their coefficients and agree about something besides the signs. Multiply the two coefficients of each completion together:

2×(−32)=−3,3×(−1)=−3,5.541×(−0.541)=−3.2 \times \left(-\tfrac32\right) = -3, \qquad 3 \times (-1) = -3, \qquad 5.541 \times (-0.541) = -3.

Each product is the determinant of the matrix, 2⋅3−3⋅3=−32 \cdot 3 - 3 \cdot 3 = -3. That is not a second law, and it is worth seeing why it is weaker than the first. Completing the square one variable at a time is a substitution like u=x+32yu = x + \tfrac32 y, v=yv = y — a shear, which preserves area and so leaves the determinant alone. The eigenvector completion is a rotation, which preserves it too. But a general change of variables stretches as well, and stretching uu by a factor of kk divides its coefficient by k2k^2. The product of the coefficients changes by a square, and the only thing a square cannot change is a sign.

So the determinant’s sign is invariant under every change of variables and its size is invariant only under the area-preserving ones. Inertia generalises the first statement and not the second. In two variables the sign of the determinant already decides the signs of both coefficients when one of them is known — a negative product means one of each — which is why the two-variable case looks almost too easy. The content of the law appears with a third variable.

Six orders, six answers, one count

With three variables there are six orders in which to complete, one for each ordering of the three letters. The figure below does all six for one form, with every coefficient computed exactly as a fraction.

Six orders of completing, six sets of coefficients, one count of signs. The form −2x² + 2xy + 2xz + y² − 2yz + 2z² completed in all six orders of its variables, each giving different exact coefficients, and its eigenvalues; every row has 2 positive and 1 negative. In a census of 36844 completions of random four-variable forms, 0 disagree with the eigenvalues' signs.
Fig. 2 The form −2x2+2xy+2xz+y2−2yz+2z2-2x^2 + 2xy + 2xz + y^2 - 2yz + 2z^2 completed one variable at a time in each of the six orders: six different sets of exact coefficients, with the negative one in first, second or third place depending on the order, and two positive and one negative in every row. The eigenvalues, a seventh completion, are 7\sqrt7, 11 and −7-\sqrt7. Below, a census of random forms in four variables, every possible order of completion tried.

The procedure in each row is the one the single-variable method would recognise. Take the first variable in the order; collect every term containing it into a square, which uses up its coefficient as the first pivot; what is left is a quadratic in the remaining variables with no trace of the first. Repeat. The coefficient set {−2,32,73}\{-2, \tfrac32, \tfrac73\} is what the order x,y,zx, y, z produces, and {1,1,−7}\{1, 1, -7\} is what y,z,xy, z, x produces. Not only the values differ but where the negative one falls: first, second or third, according to which variable was completed when.

The rows have two things in common. Each has two positive coefficients and one negative one. And the three coefficients in each row multiply to −7-7, the determinant, for the reason given above — every step is a shear. The eigenvalues, 7\sqrt 7, 11 and −7-\sqrt7, multiply to −7-7 as well and carry the same signs.

The census under the table is the reason to believe this is a theorem and not a pattern in one example. Two thousand symmetric matrices of size four were drawn with whole entries from −3-3 to 33; thirty-six of them had a zero eigenvalue and were set aside, leaving 1,964. Each of those was completed in every one of its 24 orders that did not run into a zero pivot — an order that meets a zero pivot needs a substitution before it can go on, and is simply skipped. That is 36,844 completions, and not one of them has a count of signs that differs from the eigenvalues’. Ten thousand orders were blocked by a zero, which is worth saying because it is the one place the plain procedure fails. A form like xyxy has no square term to start from at all, and must first be rewritten with x=u+vx = u + v, y=u−vy = u - v into u2−v2u^2 - v^2; the law of inertia covers that route as well, since it is a statement about every change of variables, not about the one-at-a-time procedure.

Why no order can disagree

Sylvester’s proof replaces the coefficients with something that has no coordinates in it.

Call a positive subspace of a quadratic form any collection of directions — a line, a plane, a three-dimensional slice — on which the form is positive at every point except the origin. In the two-variable hero figure the positive subspaces are the lines inside the positive wedges; there is no positive plane, because the whole plane includes negative directions.

Now suppose a completion has pp positive squares. Hold the other new variables at nought and let the pp positive ones vary freely: that is a pp-dimensional slice of space on which the form is a sum of pp positive squares, positive everywhere but the origin. So every completion exhibits a positive subspace of dimension pp. In the same way, holding the positive variables at nought exhibits a subspace of dimension n−pn - p on which the form is never positive.

Two completions disagreeing would mean one has pp positive squares and the other p′<pp' < p. The first supplies a positive subspace of dimension pp; the second supplies a never-positive subspace of dimension n−p′n - p'. Their dimensions add to p+n−p′p + n - p', which is more than nn, and two subspaces of nn-dimensional space whose dimensions add to more than nn must share a nonzero direction. Along that direction the form would be positive by the first and not positive by the second, which is impossible.

So the number of positive squares in any completion is the largest dimension of a positive subspace — a number defined without completing anything. The same argument with the signs reversed does the negative squares, and what is left over, the zero coefficients, is the dimension of the directions the form ignores altogether. The triple (positive, negative, zero) is called the form’s signature, and Sylvester’s name for its constancy, inertia, was borrowed from mechanics on the grounds that it is what stays put however the form is pushed.

That proof is short enough to fit on a card, and it explains the census completely. What it does not do is say how to find the signature without completing, and the answer to that turns out to be the most useful thing about the theorem.

Counting eigenvalues without finding them

The eigenvalues of a symmetric matrix are a completion of its quadratic form — the one along perpendicular directions — so their signs are the form’s signature. That much is a corollary. The corollary run backwards is a method.

Take a symmetric matrix AA and a number tt, and look at the matrix A−tIA - tI. Its eigenvalues are those of AA, each lowered by tt, so the number of negative eigenvalues of A−tIA - tI is exactly the number of eigenvalues of AA that lie below tt. By the law of inertia, that is also the number of negative coefficients in any completion of A−tIA - tI’s form — including the plain one-variable-at-a-time completion, which takes a few dozen arithmetic operations for a small matrix and never mentions an eigenvalue.

Counting eigenvalues by completing squares. A staircase rising from 0 to 6: for each t, the number of negative coefficients when A − tI is completed. Its 6 steps stand exactly on the eigenvalues −5.89, −2.77, −0.46, 1.13, 5.23, 8.76, marked on the axis.
Fig. 3 A symmetric matrix of size six with whole entries; for each of 901 values of tt the form of A−tIA - tI is completed in the natural order and its negative coefficients counted. The staircase is drawn from those counts alone. The dots are the eigenvalues, computed separately by rotations, and every step of the staircase stands on one.

The staircase is a picture of a function that knows where the eigenvalues are without anyone having computed them. Below the smallest eigenvalue, about −5.894-5.894, every completion of A−tIA - tI is entirely positive; above the largest, about 8.7618.761, entirely negative; in between, the count climbs by one each time tt crosses an eigenvalue. It is the same staircase that counting the eigenvalues directly would draw, and the figure checks that at every one of its 901 samples.

A count of eigenvalues below a number is enough to find them, by halving. Pick an interval known to contain the third smallest, say. Complete at its midpoint; if at least three coefficients come out negative, the third eigenvalue is to the left, and otherwise to the right. Keep the half it is in and repeat.

Halving towards one eigenvalue, one completion at a time. 14 nested intervals, each half the one above, closing on the eigenvalue −0.4573; the midpoint of each is tested by completing A − tI and counting negative coefficients.
Fig. 4 The third smallest eigenvalue of the same matrix, hunted by halving. The starting interval is read off the rows of the matrix alone — each diagonal entry give or take the sum of the rest of its row — and each row below it costs one completion at its midpoint. After fourteen completions the interval is 0.0014 wide and contains −0.457296-0.457296.

The first interval needs no computation of any eigenvalue either. Every eigenvalue lies within the sum of the off-diagonal entries’ sizes of some diagonal entry — the discs that fence in the eigenvalues — so for this matrix the whole spectrum is inside the interval from −11-11 to 1212, read off by adding up rows. From there, each completion halves the uncertainty, and fourteen of them pin the eigenvalue to three decimal places. Every step is guaranteed: the interval contains the eigenvalue at every stage, because the count at the midpoint is exact whatever rounding went into the coefficients’ sizes, as long as their signs are right.

This is not a classroom curiosity. It is how the eigenvalues of large symmetric tridiagonal matrices are computed to this day — the bisection method in numerical linear algebra libraries — and it has a property the faster methods lack: it can find the hundredth eigenvalue of a matrix with a million of them without touching the other 999,999. A method that only counts can be pointed at any part of the spectrum.

The surprising place the count turns up: a doughnut

The law of inertia also classifies a kind of point every smooth landscape has, and when the landscape lives on a closed surface the classification produces a number that belongs to the surface and not to the landscape.

Near a point where a smooth function of two variables has zero slope, the function looks like its value plus a quadratic — the Taylor approximation stops at the second-order terms, whose coefficients form the Hessian matrix. Completing that quadratic’s square tells what kind of point it is. Two positive squares: the function rises in every direction, a pit. Two negative: it falls in every direction, a peak. One of each: it rises along one line and falls along another, a pass, or saddle. By inertia the classification does not depend on which completion is used, or on the coordinates the landscape was drawn in. The number of negative squares — 0, 1 or 2 — is called the point’s index.

Pits, passes and peaks on a doughnut. Contour lines of a function on a torus drawn as a square with glued edges, with its 8 critical points: 2 pits, 4 passes and 2 peaks, classified by completing the square of the Hessian; pits minus passes plus peaks is 0.
Fig. 5 A function drawn on a square whose top edge is glued to its bottom and left edge to its right, which makes it a function on a doughnut. Its eight critical points, found by Newton’s method from 576 starting guesses, each classified by completing the square of its Hessian: two pits, four passes, two peaks. Pits minus passes plus peaks is nought.

The function in the figure was chosen to have no particular symmetry: cos⁡x+0.7cos⁡y+0.5sin⁡(x+y)+0.6cos⁡(2x−y)\cos x + 0.7\cos y + 0.5\sin(x + y) + 0.6\cos(2x - y), which repeats when xx or yy increases by 2π2\pi and so lives naturally on a square with opposite edges glued — a torus. Its critical points were found by searching, not by solving — Newton’s method run from a grid of starting guesses — and the search found eight: two pits, four passes and two peaks.

Count them with alternating signs, pits minus passes plus peaks: 2−4+2=02 - 4 + 2 = 0. Change the function and the counts change — a different choice of coefficients can produce one pit, two passes and one peak, or three of each kind of extremum and six passes — but the alternating sum does not. It is always nought, and nought is the Euler characteristic of a torus. On a sphere the same sum is always 22; on the surface of a two-holed doughnut it is −2-2. This is Morse’s theorem, from the 1920s and 1930s, and its engine is the index, which is to say the count of negative squares in a completed Hessian.

The connection is surprising in a specific way. The Euler characteristic is usually computed by cutting a surface into faces and counting vertices minus edges plus faces. Morse’s version never cuts anything. It fills the surface with water at rising levels and notes the moments the shoreline changes shape — a new pond appears at a pit, two ponds merge or a pond wraps round the hole at a pass, the last dry hill drowns at a peak — and the alternating count of those events is the same number. The same flooding, done on a random surface rather than a chosen one, is how pieces minus holes gets its formula. The negative squares of a completed quadratic are what decides which kind of event happens at each moment.

Two variables drawn, any number argued

Every figure here draws a form in two variables or tabulates one in three. The proof of the law needs one fact about dimension — two subspaces whose dimensions add to more than nn meet — and in two dimensions that fact is the visible statement that a line cannot hide inside a wedge it is not in. In four or forty dimensions the same sentence is true and nothing can be drawn of it. The census is the stand-in: it shows that 36,844 completions of four-variable forms behave as the theorem says, which is evidence, and the dimension count is the proof.

The staircase’s samples avoid the eigenvalues themselves. Exactly at an eigenvalue, A−tIA - tI is singular, one completion coefficient is zero, and the count is ambiguous between two steps. The figure skips samples within a millionth of an eigenvalue, which a reader cannot see, and the bisection never lands on one exactly. A practical implementation must decide what to do with a zero pivot — perturb it, or count it on one side by convention — and that decision is invisible in a picture where it never occurs.

The doughnut figure finds eight critical points; it does not prove there are no others. The search started Newton’s method from 576 points spread over the square and kept every distinct point it converged to. A critical point with a tiny basin could escape such a search. That the alternating count came out to nought is evidence that nothing was missed, since a missed pass or pit would break it — but that is using the theorem to check the search, and the theorem itself is not proved by any figure on this page.

Signs in the physics of space and time

The law of inertia is the reason a well-known fact about space and time is a fact and not a choice of units. Distance in ordinary space is a quadratic form in three coordinates with three positive squares, x2+y2+z2x^2 + y^2 + z^2. The interval of special relativity is a form in four, c2t2−x2−y2−z2c^2t^2 - x^2 - y^2 - z^2, with one positive square and three negative ones. Any change of coordinates — a moving observer, a rotated frame, a stretched scale — rewrites the coefficients, and by Sylvester’s law none can turn one plus and three minuses into two of each. The signature of spacetime is an invariant in exactly the sense this essay has been drawing, and it is why time is one direction and not two.

The same count classifies conic sections — ellipse, hyperbola, parabola — and the quadric surfaces one dimension up: ellipsoid, hyperboloid of one sheet or of two. Each is a signature, and each family is closed under every change of coordinates because the signature is. The eigenvalue at the highest point on a sphere is another reading of the same structure: the largest eigenvalue is the largest value of the form on unit vectors, and the count of eigenvalues above a level is the largest dimension of a subspace on which the form beats that level, which is the minimax principle and is the dimension argument above with a number in place of nought.

Still open: how much the count costs

The signature is cheap to compute exactly for a matrix of whole numbers: complete in fractions, as the table did, and count signs. The fractions grow, but only polynomially, and the whole calculation is efficient. What is less settled is the cost of the bisection for a large dense matrix in floating point, where each completion is a full elimination and the method’s guarantee rests on a theorem about rounding: the signs computed in floating point are the exact signs of a slightly different matrix, and that matrix’s eigenvalues are close to the real ones. William Kahan proved that guarantee for tridiagonal matrices in 1966, and it is why the method is trusted there; for general matrices the guarantee is weaker, and the method is used only after reduction to tridiagonal form.

A sharper question lives in the doughnut figure. Morse’s alternating count says the numbers of pits, passes and peaks satisfy one equation; it does not say which triples occur, or how few critical points a function on a given surface can have. On a torus the answer is three if degenerate points are allowed and four if not — the Lusternik–Schnirelmann category against the Morse bound — and for surfaces and higher-dimensional spaces in general the gap between the two counts is a subject of its own, closely tied to the question of what a surface’s holes force. The law of inertia supplies the index at each point. How few points a shape can get away with is a question about the shape.

The next completion this subject owes is the one in the exponent of a bell in two variables, where completing in one variable and not the other is exactly the act of conditioning — and where the line the completion names turns out not to be the line anyone expects.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

BisectionCompleting the squareDeterminantEigenvalueEuler characteristicExact arithmeticExhaustive searchInvariantQuadratic formSignature