An -dimensional quadratic form over a field is a polynomial in variables with coefficients in that is homogeneous of degree . More abstractly, a quadratic form on a vector space is a function that comes from a homogeneous degree- polynomial in the linear functions on .

I’ll start off with some comments on why quadratic forms are a natural type of object to want to classify. Then I’ll review well-known classifications of the quadratic forms over and . Then I’ll give the classification of quadratic forms over finite fields of odd characteristic. Then I’ll go over some counting problems related to quadratic forms over finite fields, which might get tedious. Finally, and perhaps most interestingly, I’ll tell you how and are secretly related to finite fields, and what this means for quadratic forms over each of them.

I’ll actually just focus on nondegenerate quadratic forms. A quadratic form is degenerate if there is a nonzero vector that is “-orthogonal” to every vector, meaning that for every vector . In this case, we can change coordinates so that is a standard basis vector, and in these coordinates, doesn’t use one of the variables, so the same polynomial gives us an -dimensional quadratic form. We can iterate this until we get a nondegenerate quadratic form, so -dimensional quadratic forms are in some sense equivalent to at-most--dimensional nondegenerate quadratic forms (in terms of abstract vector spaces, a quadratic form on a vector space is a nondegenerate quadratic form on some quotient of it). Because of this, the interesting parts of understanding quadratic forms is mostly just understanding the nondegenerate quadratic forms.

An important tool will be the fact that quadratic forms are essentially the same thing as symmetric bilinear forms. An -dimensional symmetric bilinear form over a field is a function that is symmetric (i.e. ), and linear in each component (i.e., for any , the function is linear). From any symmetric bilinear form , we can get a quadratic form by , and from any quadratic form , that symmetric bilinear form can be recovered by . This means that there’s a natural bijection between quadratic forms and symmetric bilinear forms, so I could have just as easily said this was a post about symmetric bilinear forms over finite fields (of characteristic other than ). Throughout this post, whenever denotes some quadratic form, I’ll use to denote the corresponding symmetric bilinear form. Of course, this bijection involves dividing by , so it does not work in characteristic , and this is related to why the situation is much more complicated over fields of characteristic .

In coordinates, quadratic forms and symmetric bilinear forms can both represented by symmetric matrices. A symmetric matrix represents the quadratic form , and the corresponding symmetric bilinear form . From the symmetric bilinear form, you can extract the matrix representing it: , where are the standard basis vectors.

Two quadratic forms are equivalent if you can turn one into the other with an invertible linear transformation. That is, and are equivalent if there’s an invertible linear transformation such that for every vector . In coordinates, quadratic forms represented by matrices and are equivalent if there’s an invertible matrix such that . When I said earlier that I would classify the quadratic forms over , , and finite fields of odd characteristic, what I meant is classify nondegenerate quadratic forms up to this notion of equivalence.

## Why quadratic forms?

Quadratic forms are a particularly natural type of object to try to classify. When I say “equivalence” of some sort of linear algebraic object defined on a vector space (over some field ), one way of describing what this means is that naturally acts on these objects, and two such objects are equivalent iff some change of basis brings one to the other. Equivalence classes of these objects are thus the orbits of the action of .

is -dimensional, so if we have some -dimensional space of linear algebraic objects defined over , then the space of equivalence classes of these objects is at least -dimensional. So, if , then there will be infinitely many equivalence classes if is infinite, and even if is finite, the number of equivalence classes will grow in proportion to some power of .

For example, for large , the space of cubic forms, or symmetric trilinear forms, on is approximately -dimensional, which is much greater than , so the space of equivalence classes of symmetric trilinear forms is also approximately -dimensional, and counting cubic forms up to equivalence rather than individually barely cuts down the number of them at all, leaving us with no hope of a reasonable classification. The same issue kills pretty much any attempt to classify any type of tensor of rank at least 3.

The space of (not necessarily symmetric) bilinear forms is -dimensional. But bilinear forms can be invariant under certain changes of coordinates, so the space of bilinear forms up to equivalence is still positive-dimensional. It isn’t enormously high-dimensional, like the space of cubic forms up to equivalence, so this doesn’t necessarily rule out any sort of reasonable classification (in fact, linear maps, which are also -dimensional, do have a reasonable classification. There’s the Jordan normal form for linear maps defined over algebraically closed fields, and the Frobenius normal form for arbitrary fields). But it does mean that any such classification isn’t going to be finitistic, like Sylvester’s law of inertia is.

Classifying objects is also not too interesting if there’s very few of them for very straightforward reasons, and this tends to happen if there’s far fewer than of them, so that it’s too easy to change one to another by change of coordinates. For instance, the space of vectors is -dimensional, and there’s only two vectors up to equivalence: the zero vector, and the nonzero vectors.

To get to the happy medium, where there’s a nontrivial zero-dimensional space of things up to equivalence, you want to start with some space of objects that’s just a bit less than -dimensional. Besides quadratic forms / symmetric bilinear forms, the only other obvious candidate is antisymmetric bilinear forms. But it turns out these are already fairly rigid. The argument about classifying symmetric bilinear forms reducing to classifying the nondegenerate ones applies to antisymmetric bilinear forms as well, and, up to equivalence, there’s not that many nondegenerate antisymmetric bilinear forms, also known as symplectic forms: Over any field, there’s only one of them in each even dimension, and none at all in odd dimensions.

## Classification of quadratic forms over certain infinite fields

Let’s start with (though the following theorem and proof work just as well for any ordered field containing the square root of every positive element). We’ll use this same proof technique for other fields later.

Theorem (Sylvester’s law of inertia): For an -dimensional nondegenerate real quadratic form , let denote the maximum dimension of a subspace on which takes only positive values, and let denote the maximum dimension of a subspace on which takes only negative values. Then , and is equivalent to the quadratic form represented by the diagonal matrix whose first diagonal entries are and whose last diagonal entries are . All pairs of nonnegative integers summing to are possible, and completely classifies nondegenerate real quadratic forms up to isomorphism. Thus, up to equivalence, there are exactly nondegenerate -dimensional real quadratic forms.

Proof: First we’ll show that every quadratic form can be diagonalized. We’ll use induction to build a basis in which a given quadratic form is diagonal. For the base case, it is trivially true that every -dimensional quadratic form can be diagonalized (and -dimensional quadratic forms are just as straightforwardly diagonalizable, if you prefer that as the base case). Now suppose every -dimensional quadratic form is diagonalizable, and let be an -dimensional quadratic form. Let be any vector with (if this is not possible, then , and is represented by the zero matrix, which is diagonal). Then is an -dimensional subspace disjoint from . Using the induction hypothesis, let be a basis for in which is diagonal. Then is a basis in which is diagonal (its matrix has in the upper left entry, the diagonal matrix representing in the basis in the submatrix that excludes the first row and column, and the fact that for means that the rest of the first row and column are zero).

Now that we’ve diagonalized , we can easily make those diagonal entries be , assuming is nondegenerate (otherwise, some of them will be ). If , then . If , then . Either way, we can replace with some scalar multiple of it such that .

The ordering of the diagonal entries doesn’t matter because we can permute the basis vectors so that all the ‘s come before all the ‘s. So all that remains to show is that any two quadratic forms whose diagonal matrices have different numbers of ‘s are not equivalent. Let be the number of ‘s and let be the number of ‘s, so that our diagonalized quadratic form can be written as . There is an -dimensional subspace on which it only takes positive values (the subspace defined by ), and an -dimensional subspace on which it only takes negative values (the subspace defined by ). It can’t have an -dimensional subspace on which it takes only positive values, because such a subspace would have to intersect , and similarly, it can’t have an -dimensional subspace on which it takes only negative values, because such a subspace would have to intersect . Thus the number of ‘s and ‘s are the maximum dimensions of subspaces on which the quadratic form takes only positive values and only negative values, respectively, and hence quadratic forms with different numbers of ‘s are not equivalent.

Over , things are simpler.

Theorem: All -dimensional nondegenerate complex quadratic forms are equivalent to each other.

Proof: As in the real case, we can diagonalize any quadratic form; the proof of this did not depend on the field. But in , every number has a square root, so each basis vector can be scaled by , to get a vector that sends to (of course, has two square roots, but you can just pick one of them arbitrarily). Thus every nondegenerate complex quadratic form is equivalent to the quadratic form defined by the identity matrix.

Note that this proof works just as well over any quadratically closed field not of characteristic 2.

Over other fields, things get a bit complicated. One class of fields you might want to consider is the p-adic numbers, and there is a known classification (called the Hasse invariant) of quadratic forms over (and its finite extensions), but it involves Brauer groups, for some reason.

Over the rationals, things are even worse. The best result about classifying rational quadratic forms we have is the Hasse-Minkowski theorem: Over any finite extension of , two quadratic forms are equivalent iff they are equivalent over every non-discrete completion of the field (so, they are equivalent over itself iff they are equivalent over and over for every prime ). An interesting result, but not one that lets you easily list out equivalence classes of rational quadratic forms.

But over finite fields, things go back to being relatively straightforward.

## Classification of nondegenerate quadratic forms over finite fields of odd characteristic

Let be a power of an odd prime, and let denote the field with elements.

has a certain feature in common with : exactly half of its nonzero elements are squares. For , you can show this with a counting argument: every nonzero square is the square of exactly two nonzero elements, and there are finitely many nonzero elements. For , it might not be obvious how to formally make sense of the claim that exactly half of nonzero reals are squares (i.e. positive). One way is to notice that the positive reals and negative reals are isomorphic as topological spaces. But what matters in this context is that the quotient group has order , just like (here means the group of units of a field ). Now let’s see how this relates to quadratic forms.

The part of the proof of Sylvester’s law of inertia that shows that every nondegenerate real symmetric form can be diagonalized with diagonal elements can be generalized to an arbitrary field:

Lemma 1: Let be a field, and let be a set of elements of consisting of one element from each coset of . Then every nondegenerate quadratic form over is equivalent to one represented by a diagonal matrix with elements of on the diagonal.

Proof: As in the proof of Sylvester’s law of inertia, with replaced with the set .

Since has exactly 2 cosets in , this means there is a set of size (if , then is nonsquare, and you could use again) such that every -dimensional nondegenerate quadratic form over is equivalent to one represented by a diagonal matrix with elements of on the diagonal, and thus there are at most of them up to equivalence. However, we have not shown that these quadratic forms are inequivalent to each other (that part of the proof of Sylvester’s law of inertia used the fact that is ordered), and in fact, this is not the case. Instead, the following lower bound ends up being tight over finite fields of odd characteristic:

Lemma 2: Let be a field. Any two invertible symmetric matrices whose determinants are in different cosets of represent inequivalent quadratic forms (that is, if their determinants are and , and is nonsquare, then the matrices do not represent equivalent quadratic forms). Thus, for , there are at least nondegenerate -dimensional quadratic forms over up to equivalence.

Proof: If invertible symmetric matrices and represent equivalent quadratic forms, then there is some change of basis matrix such that . . If , then for every element of , there is a symmetric matrix that has that determinant, so the fact that symmetric matrices whose determinants are in different cosets of represent inequivalent quadratic forms implies that there are inequivalent nondegenerate quadratic forms for each coset.

What’s going on here is that there’s a notion of the determinant of a bilinear form that doesn’t depend on a matrix representing it in some basis. For every -dimensional vector space , there’s an associated -dimensional vector space , called the space of volume forms on . Elements of are called volume forms because, over , they represent amounts of volume (with orientation) of regions in the vector space. This is not exactly a scalar, but rather an element of a different -dimensional vector space, because, in a pure vector space (without any additional structure like an inner product), there’s no way to say how much volume is . I won’t give the definition here, but anyway, a bilinear form on a vector space induces a bilinear form on . A basis for induces a basis for , in which is represented by a matrix (i.e. scalar) that is the determinant of the matrix representing . An automorphism of induces an automorphism of , which is multiplication by , and thus induces an automorphism of the space of bilinear forms on given by division by . Thus if the ratio of the determinants of two nondegenerate bilinear forms is not a square, then the bilinear forms cannot be equivalent. This also applies to quadratic forms, using their correspondence to symmetric bilinear forms.

Theorem: Up to equivalence, there are exactly two -dimensional nondegenerate quadratic forms over (for ).

Proof: Lemma 2 implies that invertible symmetric matrices of square determinant and invertible symmetric matices of nonsquare determinant represent inequivalent quadratic forms. It remains to show that any two invertible symmetric matrices with either both square determinant or both nonsquare determinant represent equivalent quadratic forms.

Let be square, and nonsquare, respectively. By lemma 1, every nondegenerate quadratic form over can be represented with a diagonal matrix whose diagonal entries are all or . The determinant is square iff an even number of diagonal entries are . It suffices to show that changing two ‘s into ‘s or vice-versa doesn’t change the equivalence class of the quadratic form being represented. Thus this reduces the problem to show that the -dimensional quadratic forms represented by and are equivalent. If we can find such that , then the change of basis matrix will do, because . This reduces the problem to showing that there are such .

The squares in cannot be an additive subgroup of , because there are of them, which does not divide . Thus there are such that is nonsquare. Since has order , and is also nonsquare, it follows that is a square. Let , and let and . Then , as desired.

Note, as a consequence, if we count the degenerate quadratic forms as well, there are -dimensional quadratic forms over up to equivalence: for every positive dimension that’s at most , and more for dimension (this is the zero quadratic form; there are no zero-dimensional quadratic forms of nonsquare determinant).

## Counting

Given an -dimensional quadratic form over , and some scalar , how many vectors are there such that ? There are vectors , and possible values of , so, on average, there will be vectors with any given value for the quadratic form, but let’s look more precisely.

First, note that we don’t have to check every quadratic form individually, because if two quadratic forms are equivalent, then for any given scalar , each form will assign value to the same number of vectors. And it’s enough to check nondegenerate forms, because every quadratic form on a vector space corresponds to a nondegenerate quadratic form on some quotient , and the number of vectors it assigns a given value is just times the number of vectors the corresponding nondegenerate quadratic form assigns the same value. So we just have to check 2 quadratic forms of each dimension.

And we don’t have to check all scalars individually because, if is a square, then multiplication by its square root is a bijection between and . So there’s only cases to check: , is a nonzero square, or is nonsquare. If the dimension is even, there’s even fewer cases, because a quadratic form is equivalent to any nonzero scalar multiple of it, so each nonzero scalar has the same number of vectors that sends to . Thus, for any -dimensional quadratic form , there will be some number such that, for each , , and .

And it turns out that in odd dimensions, for any nonzero quadratic form , the probability that for a randomly selected vector is exactly . To see this, we can reduce to the -dimensional case (which is clear because there’s vectors and only gets sent to by ): Given a -dimensional quadratic form , let be a -dimensional subspace on which is nonzero, and let . Then every vector is uniquely a sum for some and , and . Since is a quadratic form on the -dimensional space , there’s some number such that for each , , and . For and , iff ( ways for this to happen) or ( ways for this to happen), for a total of vectors such that . Since there’s the same number of nonzero squares as nonsquares, it follows that there is some number such that for each , if is square, and if is nonsquare.

We can compute these offsets and recursively. We can represent quadratic forms of square determinant with the identity matrix (i.e. ). The number of vectors such that is . (Why do I suggest decrementing by at a time? You could also try decrementing by each step, but I think is easier because of the significance of the parity of the dimension). We can represent quadratic forms of nonsquare determinant with a matrix that is the identity except for the last diagonal entry being replaced with a nonsquare, and then compute how many vectors it assigns each scalar in terms of the square-determinant quadratic forms of one lower dimension.

It turns out that it matters whether is a square in . To see this, consider the case of a -dimensional quadratic form of square determinant: , and let’s see how many solutions there are to . Assuming is nonzero, iff . If is not a square, then this is not possible, so is the only solution. But if is a square, then it has two square roots that could be, and choices of overall scale, so there’s nonzero solutions, and thus total solutions. is a square iff , so we can phrase this as that it matters whether is or .

If you state and solve the recurrence, you should find that:

Where is defined as follows:

If , then if has square determinant, and if has nonsquare determinant.

If , then is defined as in the previous case if is even, but is reversed if is odd. Remember that the dimensions above were and , so, by , I mean half the dimension (rounded down).

It turns out that counting how many vectors a quadratic form assigns each value is useful for another counting problem: Now we can determine the order of the automorphism group of a quadratic form.

If is an -dimensional quadratic form of square determinant, it can be represented by the identity matrix. A matrix with columns is an automorphism of iff and for . Once have been chosen, the space that’s -orthogonal to all of them is -dimensional, and restricts to a quadratic form on it of square determinant, so the number of options for is the number of vectors that an -dimensional quadratic form of square determinant assigns value (which is square). Thus the order of the automorphism group of is the product of these over all .

If is an -dimensional quadratic form of nonsquare determinant, we can do a similar thing, representing with a matrix like the identity, but with the first diagonal entry replaced with a nonsquare. Then the number of options for is the number of vectors that a quadratic form of nonsquare determinant assigns some particular nonsquare value, and the rest of the product is unchanged.

If you evaluate these products, you should get:

:

:

You may notice that, in odd dimensions, the size of the automorphism group of a quadratic form does not depend on its determinant. In fact, the groups are the same. This is because multiplication by a nonsquare scalar sends a quadratic form of square determinant to a quadratic form of nonsquare determinant, and does not change its automorphism group.

As a sanity check, is a subgroup of the general linear group, so its order should divide the order of the general linear group. (which can be shown with a similar recursive computation). And indeed:

:

:

By the orbit-stabilizer theorem, these count the number of quadratic forms of each equivalence class.

The sum of the sizes of the two equivalence classes is the total number of (individual, not up to equivalence) nondegenerate quadratic forms on a vector space, or equivalently, the number of invertible symmetric matrices. This sum is

:

:

The leading terms of these are and , respectively, which are the numbers of symmetric and matrices, respectively. And the second terms of each are negative, which makes sense because we’re excluding singular matrices. You could compute the sizes of all equivalence classes of quadratic forms on an -dimensional vector space, not just the nondegenerate ones, and add them up, and you should get exactly .

## Fields of well-defined Euler characteristic

is, of course, infinite, but if you had to pick a finite number that acts most like the size of , it turns out that is a decent answer in some ways. After all, and each are homeomorphic to , so they should probably all have the same size, and ; has size , and size should probably be additive, which would imply that, if we’re denoting the “size” of by , , which implies . Then, of course, should have “size” .

This might seem silly, but it’s deeper than it sounds. This notion of “size” is called Euler characteristic (this is actually different from what algebraic topologists call Euler characteristic, though it’s the same for compact manifolds). A topological space has an Euler characteristic, denoted , if it can be partitioned into finitely many cells, each of which is homeomorphic to for some . If can be partitioned into cells , and is homeomorphic to , then and . This is well-defined, in the sense that multiple different ways of partitioning a space into cells that are homeomorphic to will give you the same Euler characteristic. Roughly speaking, this is because partitions of a space can be refined by splitting an -dimensional cell into two -dimensional cells and the -dimensional boundary between them, this does not change the Euler characteristic, and any two partitions into cells have a common refinement.

Euler characteristic has a lot in common with sizes of finite sets, and is, in some ways, a natural generalization of it. For starters, the Euler characteristic of any finite set is its size. Some familiar properties of sizes of sets generalize to Euler characteristics, such as , and .

In fact, all of the counting problems we just did over finite fields of odd size applies just as well to fields of well-defined odd Euler characteristic. There are only two infinite fields that have an Euler characteristic: , with , and , with .

Recall that in the counting problems in the previous section, we needed to know whether or not contains a square root of , and that it does iff . This extends to fields with Euler characteristic just fine, since and contains a square root of , and and does not contain a square root of . In fact, this generalizes a bit. contains the primitive th roots of unity iff . for every , and contains all roots of unity. only for and , and the only roots of unity in are itself and its primitive square root .

Anyway, let’s start with positive-definite real quadratic forms (i.e. those only taking positive values). If is an -dimensional positive-definite real quadratic form, then

For negative-definite quadratic forms, of course, the positive and negative cases switch.

Now let’s try the indefinite quadratic forms. Recall that for every nondegenerate quadratic form on a real vector space , there are -orthogonal subspaces such that is positive-definite, is negative-definite, and . Let and . For , in order for to satisfy , can be anything, and then must lie on the -dimensional sphere . If , then and switch roles. In order for to satisfy , either , or there’s some such that lies on the -dimensional sphere and lies on the -dimensional sphere . Thus

With , this also works for definite quadratic forms.

If you remove one point from , you get , so ; that is, if is even, and if is odd. Thus the Euler characteristics of the above level sets of depend only on the parities of and . The parity of is equivalent to the sign of , and is the dimension. So the Euler characteristics of the level sets of depend only on the parity of its dimension and the sign of its determinant, and

:

:

:

:

In comparison, if you take our earlier formula for the sizes of these level sets over and plug in , you get

is the sign of the determinant, so these two calculations agree.

Now let’s look at complex quadratic forms. Since every complex number is square and , for every nondegenerate complex quadratic form . Thus our formulas for sizes of level sets of quadratic forms over finite fields predicts

In the odd-dimensional case, I’ve left out the nonsquare case, and relabeled the case where is a nonzero square as , because all complex numbers are squares.

It’s easy to verify that the zero-sets of complex quadratic forms have Euler characteristic . This is because, besides the origin, all of the other solutions to can be arbitrarily rescaled to get more solutions, and . That is, let be the space of -dimensional subspaces on which is zero. Then , so .

The Euler characteristics of the other level sets of complex quadratic forms can be checked by induction. A -dimensional quadratic form takes no nonzero values, so . An -dimensional quadratic form can be diagonalized as . For , the solutions to can be partitioned into three pieces:

1. . This has Euler characteristic .

2. . This has Euler characteristic .

3. For some , . This has Euler characteristic

(I’ve replaced and with where they appear, since both are nonzero, and all the nonzero level sets are homeomorphic).

Thus, summing these up, we get , explaining the alternation between and .

There are some apparent disanalogies between finite fields and infinite fields with Euler characteristics. For instance, it is not true that exactly half of nonzero complex numbers are squares, at least in the sense that . However, it is still true (vacuously) that the ratio between any two nonsquare complex numbers is square. And the spaces of nonzero square and nonsquare complex numbers have the same Euler characteristic, since . This had to be the case, because sufficiently non-pathological bijections preserve Euler characteristic, so sufficiently non-pathological two-to-one maps cut Euler characteristic in half, since the domain can be partitioned into two pieces in non-pathological bijection with the range.

And, while finite fields of odd characteristic have two nondegenerate -dimensional quadratic forms up to equivalence, has just one, and has of them. ‘s missing second nondegenerate quadratic form of each dimension can be addressed similarly to its missing nonsquare elements. The number of nondegenerate -dimensional quadratic forms over in each equivalence class is a multiple of , so, with , this correctly predicts that the Euler characteristic of each equivalence class of -dimensional complex quadratic form is , and one of the equivalence classes being empty is consistent with that.

The oversupply of equivalence classes of real quadratic forms is a little subtler. Our analysis of nondegenerate quadratic forms over finite fields of odd characteristic predicts that any two nondegenerate real quadratic forms whose determinants have the same sign should be equivalent, and this is not the case. To address this, let’s look at the heap of isomorphisms between two nondegenerate quadratic forms whose determinants have the same sign. A heap is like a group that has forgotten its identity element. The heap of isomorphisms between two isomorphic objects is the underlying heap of the automorphism group of one of them. In particular, if the automorphism group of some object is a Lie group, then the heap of isomorphisms between it and another object it is isomorphic to is homeomorphic to the automorphism group, and thus they have the same Euler characteristic. In the finite case, this is just saying that the heap of isomorphisms between two isomorphic objects has the same size as the automorphism group of one of them. So when we computed the sizes of automorphism groups of nondegenerate quadratic forms over , we were also computing sizes of isomorphism heaps between isomorphic pairs of nondegenerate quadratic forms over . Plugging in , this should also tell us the Euler characteristic of the heap of isomorphisms between two real quadratic forms whose determinants have the same sign. Notice that (with the exception of the cases where and , or where ), the order of the automorphism group of a nondegenerate quadratic form over is a multiple of , so plugging in predicts that the automorphism group of a nondegenerate real quadratic form has Euler characteristic , and hence so does the heap of isomorphisms between two nondegenerate real quadratic forms of the same dimension whose determinants have the same sign. This is consistent with said heap of isomorphisms being empty! The exceptions, the quadratic forms whose automorphism groups do not have Euler characteristic , are when and , or when . These are exactly the cases when knowing the dimension of a nondegenerate real quadratic form and the sign of its determinant actually does tell you what the quadratic form is up to equivalence.