Choose a positive integer . Which primes
can be written as
with integers
? For
the answer is familiar: apart from
, the primes are exactly those leaving remainder
on division by
. For
, something slightly different happens. We have
, but
cannot be written as
. Yet both primes have a square root of
:
and
. The same simple test succeeds for both primes, while the original equation succeeds for only one. What has the test actually told us about
?
There is a good answer, and it is the main point of this discussion. When has a square root modulo a prime
, the prime can always be represented by a quadratic expression closely related to
. It may not be the expression we started with. For
there are only two possibilities; for
there are three, and for
there are four. We can find these other expressions by a short calculation. Once we see where the prime has gone, the different answers for
become much easier to understand. We will still be asking about
throughout; the other expressions enter only to explain why a prime that passes the first test may fail to have the representation we want.
Congruence test
Suppose , where
is an odd prime not dividing
. The number
cannot be divisible by
: otherwise the equation would force
to divide
as well, and the right side would be divisible by
. We can therefore divide by
modulo
. The original equation gives
, where
means the inverse of
modulo
. Thus the polynomial
must have a root modulo
. This is a necessary condition, and it is often easy to check even for a large prime.
For , this condition is also sufficient. A root of
modulo an odd prime exists exactly when
, and Fermat’s two-square theorem says that every such prime is
. For
the represented odd primes are exactly
. For
they are exactly
, together with the prime
. Some small examples are
,
, and
. In these three cases the first square-root test tells the whole story. The question is why it stops doing so as
changes.
The first test has three possible outcomes, which are useful to keep separate. For , the prime
fails immediately: the nonzero squares modulo
are
, and
is not among them. The prime
passes the test but is not
. The prime
passes and does have the desired representation. Thus failure of the modular equation rules out the integer equation, but success only begins the search. What makes the successful modular tests so useful is that we can always attach a concrete two-variable expression to them.
Representation by some form
Assume now that is odd, that
does not divide
, and that we have found an integer
with
. Because
divides
, the number
is an integer. Consider the following quadratic form in two new variables:
There are two immediate facts about this expression. First, , so it represents the prime we started with. Second, the number
is always
. For a general expression
, the number
is called its discriminant. Thus our new form and the original
have the same discriminant,
. The expression is also positive away from
, as we can see by completing the square:
So a root of modulo
really does produce a positive quadratic form of the correct discriminant that represents
. No theorem about number fields is needed for this construction. It is just the observation that a congruence makes one coefficient an integer. The only remaining question is whether this form can be changed into
by an invertible integer change of variables. If it can, then the prime has the representation we wanted. If it cannot, the new form tells us what kind of representation the prime has instead.
We need a way to compare such expressions without trying arbitrary substitutions. Write a form briefly as , meaning
. There are two simple moves. Replacing
by
changes its coefficients to
. Replacing
by
changes the coefficients to
. Both substitutions are reversible using integers, and neither changes the numbers represented by the form. We first choose
to make the middle coefficient satisfy
. If the last coefficient is then smaller than
, we exchange the first and last coefficients and repeat. Each such exchange makes the first coefficient smaller, so the process must stop.
A form satisfying these inequalities is called reduced. The second inequality shows that its first coefficient cannot exceed . For any fixed
, we therefore have only a short list to examine. For example, when
, the first coefficient is at most
. Substituting
and
into
gives exactly the two reduced forms
and
, with the standard choice of sign on the boundary. This is the first place where we see why a prime can pass the square-root test without being
: there is a second possible destination.
It is useful to check why this procedure really answers our original question. If , then
have no common factor, since the square of such a factor would divide the prime. We can find integers
such that
. Making the substitution
in
gives a form whose leading coefficient is
. Its discriminant is still
, so its middle coefficient is
for some root
. Conversely, every move in our reduction procedure can be reversed using integers. If the constructed form reduces to
, reversing the substitutions turns its value
into an actual representation
. This explains the difference between the first test and the full reduction: the first constructs a form, while the second decides whether it is the particular form we wanted.
There are usually two square roots, and
, modulo the odd prime
. They lead to forms with opposite middle coefficients, after an elementary change of variables. Such forms represent the same integers, because replacing
by
changes the sign of the middle term. So the answer to our original question does not depend on which root we chose. Later, when we list forms such as
and
, we will see both signs; for deciding whether a prime has a representation, they give the same set of prime values.
Let us follow the calculation for . We have
, so the construction gives
. Exchanging the two variables gives
. We then replace
by
, obtaining
. This is the form we wanted. Reading the substitutions backward gives the familiar equality
. Nothing mysterious happened: the modular root gave a quadratic form, and two elementary changes of variables revealed that it was the original form in different coordinates.
Now try . This time
, so we obtain
. Exchange the variables to get
, replace
by
to get
, and exchange once more. A final replacement
gives
. This is not the form
. But it does represent
, and we can see the representation explicitly:
The difference between and
is now concrete. Both primes satisfy the congruence
, but one reduces to
and the other to
. Notice also that an odd number of the form
is
, whereas an odd number of the form
is
. In the second case
must be odd, and
is even. Thus the two forms are separated by a simple remainder test. In fact, for primes other than
, the first form represents precisely the primes
, and the second represents precisely the primes
. Together, the two forms account for every prime for which
has a square root.
For , the reduced list is again short:
and
. We have
, so
belongs to the first form. But
also passes the first test, because
. Its constructed form is
, which reduces by
. Indeed,
. Here again the square-root test gives two possibilities, and ordinary congruences separate them: for primes not dividing
, the form
represents exactly
, while
represents exactly
.
The two cases also show how to add a second polynomial test instead of carrying out a reduction for every new prime. For , a prime different from
is
precisely when both
and
have roots modulo
. The first test says that the prime is represented by one of the two forms; the second distinguishes the form
from
. For
, we have
and
. For
, the first congruence has a root but the second does not, because
. Likewise, for
, the two useful tests are
and
. The prime
passes both, since
and
, whereas
passes the first but not the second. In these examples, a second square-root test gives exactly the information missing from the first.
It would be natural to guess that the problem gets harder simply because the number of forms increases. That guess is not quite right. Take . Its discriminant is
, and reduction gives four forms:
We can find a prime represented by each one. The prime belongs to the first form. The prime
belongs to the second, simply by taking
. The prime
belongs to the third, and
belongs to the fourth. All four primes satisfy the first modular condition: roots of
modulo
are respectively
. So the first test again sends us to one of several forms, and the reduction procedure tells us which one.
For instance, the roots just listed give the forms ,
,
, and
. Reducing them yields, in the same order,
,
,
, and
. There are four possible forms, but a theorem says that the primes represented by the first one are still described by remainders alone:
For example, ,
, and
give the three remainders
modulo
. Here the different forms can still be separated by their remainders, even though there are four of them. The number of forms by itself is therefore not what decides whether a simple congruence test will work. To see a real change, we need an example where two primes pass exactly the same remainder test but end up in different forms.
The list of four forms for can also be checked without assuming it in advance. The inequality
gives
. For each
, the equation
and the restriction
leave only a few values of
. The choices
give exactly the four forms above. The possibility
gives no primitive reduced form. This calculation is typical: we do not need to guess the other forms from a table. We can write them all down by solving a short list of elementary equations, and then ask which one a particular prime belongs to.
Consider . The reduced forms of discriminant
are
and
. The two forms with opposite middle coefficients represent the same integers, since replacing
by
changes one into the other. But they are not the same form under changes of variables of determinant one. For our question about the primes represented, it is enough to view them as the second possibility. We have
, whereas
is not
. Checking the latter directly is easy:
is at most
, and the possibilities for
are
, none of which is a square.
Even so, , and both primes satisfy
. For
we can choose
, obtaining
, which reduces to
. For
we can choose
; the construction gives
. Its reduction is worth following because it answers the question of where the prime went:
Thus is represented by the other form. Indeed,
The two primes have the same remainder modulo , and both pass the same first square-root test. Nevertheless, one reduces to the form
and the other to
. This is the point at which remainders modulo
stop giving enough information. A different, still quite concrete, test is possible. Consider the fixed cubic polynomial
. For every prime other than
, a theorem says that
exactly when
has three distinct roots modulo
. Modulo
, those roots are
. Modulo
, the cubic has no root. The factorization of a fixed polynomial has distinguished two primes that the first congruence test could not separate.
There are other small primes in the second family for . For example,
and
. In contrast,
and
belong to the original form. The cubic test is not tied to the particular pair
: it works for every prime away from the two exceptional primes, using the same polynomial each time. Our reduction calculation also gives an effective method for finding an actual representation once we know a root of
. The polynomial test is different in purpose. It lets us decide which type of form a prime belongs to, without searching through all possible integer pairs
.
The case shows the same phenomenon with four reduced forms of discriminant
:
The prime is represented by the first form. The prime
is not: the only possible values of
are
, and none is a square. But
, and
is a square modulo both primes. For
, take
. The resulting form reduces as follows:
Once again, the prime has not disappeared. It belongs to a different form, since . For
we can choose
, obtaining
. This reduces to
, as expected. Other primes can land in the remaining two forms:
and
. So among primes for which the first square-root test succeeds, we can meet the original form, the form
, or one of the two forms
. Their existence explains why the first modular test need not identify our chosen representation.
For a quartic polynomial supplies a more precise test. Set
. For primes other than
, a theorem says that
exactly when this quartic splits into four distinct linear factors modulo
. The difference between
and
can be checked directly. Modulo
, the four roots are
. Modulo
, the polynomial factors only as
and neither of these quadratic factors has a root. Modulo , the quartic remains irreducible. So the way this one polynomial breaks apart shows three possible behaviors of split primes: four linear factors when the prime is
, two irreducible quadratic factors in the example
, and an irreducible quartic in the example
. We began by asking whether the prime has an integer representation. We ended by looking at the number and sizes of factors of a polynomial modulo that prime. These are two ways of organizing the same arithmetic information.
It matters that the quartic split completely. Asking only for one root would give a weaker test, just as the first quadratic congruence gave a weaker test. For example, modulo , the quartic
has the roots
but not four roots. The prime
is not
. In fact,
has no root modulo
either. Thus a higher-degree polynomial can have a few roots without supplying the complete information we need. The exact theorem uses four distinct roots, not merely the existence of a root. This is why the way a polynomial factors, rather than just whether it has one solution, becomes the natural test in these examples.
The small cases now fit into a single picture. The test tells us whether a prime is represented by some positive quadratic form of discriminant
. The formula
constructs that form, and elementary changes of variables reduce it to one of finitely many possibilities. If there is only one possibility, as for
, the first test settles the question. If there are several forms, we must find which one represents the prime. Sometimes their remainders distinguish them completely, as for
. Sometimes primes with the same remainder fall into different forms, as for
. Then a fixed cubic or quartic polynomial can give information that the first congruence did not give.
There is a general theorem behind the last two examples. Starting from the integers of the form , one can construct a number field in which the way a prime splits records whether
. In the usual cases this is described by the Hilbert class field of the quadratic field
; when the integers
form a smaller ring than the full ring of integers, as for
, the appropriate object is called a ring class field. We do not need their construction to appreciate what they accomplish. They give a reason why one fixed polynomial, chosen once for
, can recognize the primes represented by
through its factorization modulo
. The calculation with
is the elementary beginning of this story. It shows exactly what the first square-root test knows, and why more information is sometimes needed to return from a solution modulo
to an equation in ordinary integers.