Lecture 14
Many people, particularly those who like numerical calculations with integers (like computer programmers), use all this as an excuse to define a function, which in some languages is written “”, which gives the remainder upon division (so that is an integer between and ). So they say, for example, that , and .
This works fairly well for the computer programmers, but for us it’s a little unsatisfying. While it’s true that every number is congruent (modulo ) to a unique number from , there’s nothing much special about that set. It’s also true that every number is congruent (modulo ) to a unique number in the set . And it’s also true that every number is congruent (modulo ) to a unique number in the set . And, in fact, I can think of situations where all those facts are useful.
So it’s important we just think of the unique number in as just one out of many equally good ways of describing our number, up to congruence modulo .
Next semester, you’ll come to regard the integers, considered up to congruence modulo , as a system of numbers in its own right (and why not? We can add them and subtract them and multiply them, all considered only up to congruence modulo ). This system of numbers is commonly called (for reasons which will remain obscure at least for a year or two more).
So, for example, the system consists of two “numbers” which could be called “even” and “odd” (or 0 and 1; or 1 and 2), subject to the arithmetic laws you’d expect (like ).
This is novel in one important sense. In the past, every time we’ve introduced a new system of numbers, it’s contained the system we were thinking about before. We’ve built But doesn’t seem to work like this in this framework. It’s related to , but doesn’t really live inside it. Similarly, the set of “times of day” isn’t a subset of the set of times: for example, there’s no one special point of time in history called “2pm”, just many examples of 2pm on many different days (and the same goes for “days of the week”, and “months of the year”).
In the case where , you’re probably comfortable with the fact that “odd” and “even” form something like a system of numbers (because you can add them and subtract them and multiply them), but while they’ve obviously got something to do with , there’s no one integer called “odd” and no one integer called “even”.
Modular arithmetic, to other moduli, is similar (we just don’t have clever names like “even” and “odd”).
Congruence equations
We’ve now laid the foundations of modular arithmetic, the study of congruences. After all that philosophy, we should do some sums.
The set of all solutions to seems like a perfectly explicit description of a class of numbers: it’s a congruence class modulo , the class of numbers of the form . So we can start listing them easily:
But what is the set of solutions to ?
That’s not a particularly satisfactory description of a set of numbers: it’s a pain to list them, so we should ask for better.
However, we can get a more satisfactory list just using techniques we already know. The condition says that , which in turn says that for some . Rearranging, that says that . But we know how to get a general solution for those!
Indeed, we find that , and as there are solutions. First we try to find a single one.
We can get a solution to (by guessing, or by using Euclid’s algorithm backwards) such as . This means (by tripling both sides) that a solution to is given by .
To find other solutions, we subtract from to get .
Hence , so . As and are coprime, this means that . So it’s equivalent to , which is a nice description!
We can regard linear equations in modular arithmetic as asking about division. After all, asking about solutions to the linear equation is asking “can we divide by ”? So the fact that might be regarded as saying that we can divide by (modulo ), and we get when we do so.
But division in modular arithmetic is more complicated than in the integers. Of course, integer division is unique where it exists. In other words, if I choose integers and (with nonzero) and ask about integer solutions to then two things can happen: either there is a unique solution (as with ), or there’s no solution at all (as with ).
That’s not true in modular arithmetic, as the following examples show:
How many residue classes of solutions are there to ?
None: the lhs is even and the rhs odd.
How many residue classes of solutions are there to ?
One: .
How many residue classes of solutions are there to ?
Two: and .
How many residue classes of solutions are there to ?
Four: .
Even if you don’t want to do division in modular arithmetic, you still have to be careful about cancellation.
In ordinary arithmetic over the integers, we know that implies (provided that isn’t zero, of course). This is true even though we don’t know how to divide integers in general.
But we can’t always cancel in modular arithmetic: the third example above tells (for example) that , but that .
Here’s a fact, mostly a repackaging of some observations we made in a previous lecture, about diophantine equations, saying when we can divide by things in modular arithmetic.
Proposition
Let and be integers. There is an integer such that if and only if .
When such a number does exist, it’s unique (modulo ).
Proof
We deal with existence first.
Using Bezout’s lemma, we know we can find integers and such that if and only if .
But if and only if , and the equation says exactly that .
Now we deal with uniqueness.
Suppose that we have two numbers and such that and . Then which shows uniqueness modulo .