Lecture 15
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 .
When there is a number such that , we call it the inverse of , modulo (and we say that is invertible). We write for the inverse of .
Notice that, as a consequence modular arithmetic modulo a prime is fantastically well-behaved: any nonzero residue has an inverse (since we have unless is a multiple of ).
Spotting inverses modulo is quite difficult; in general the best way is to use Euclid’s algorithm.
There are a few exceptions:
The inverse of modulo is always
.
The inverse of modulo is always
.
If is odd, then is invertible modulo , because . The inverse is:
.
Two other fairly easy, but useful, facts are as follows:
Proposition
If is invertible modulo , then so is , with inverse given by .
Proof
We have , which says that is an inverse for .
Proposition
If and are both invertible, then is too, with inverse given by
Proof
We have .
As a big example of all of this, let’s find an inverse for , modulo . We want with . In other words, we seek a solution to in the integers. We’ll get one from working through Euclid’s algorithm: So we have that That means that , so the inverse of is , which is congruent to (mod ).
Checking our working
And, of course, we can check this easily: as claimed.
The Chinese Remainder Theorem
We’ve come to understand congruence equations: given something like we can, with some effort, turn it into something nice like
Now we’ll discuss a different sort of problem with congruences: what if we have two of them for the same number? For example, These things happen all the time: two things happening periodically with different periods.
And it turns out we can solve them using exactly the same machinery as we’ve been using all along. Indeed, these equations say that for some numbers and .
That means that or in other words . We have lots of experience solving these, and, since , it’s possible.
A solution to is given by , , and so a solution to is given by doubling that to get , .
What’s the general solution? Well, if we have , then subtracting gives This means that , so . Hence is of the form . and in fact any such works.
Now, we had , which in turn is . In other words:
There need not always be solutions to simultaneous congruences. For example, the simultaneous congruences don’t have solutions. Why is this obvious?
The first equation implies even, the second odd.
Of course, if we go through the same solution process as above it will fail. We set and find that , and hence . This has no solutions because , and .