22.2 Modular arithmetic
Given that we now know that division really exists (as if there was ever any doubt), we can start to talk about remainders.
22.2.1 Core definitions
Definition 22.2.1
We say that for that
if and only if .
Theorem 22.2.1
For , if and only if .
Proof: first we prove the \sayif direction; suppose that and where we define . In this case
(22.30) | ||||
(22.31) |
and thus .
For the \sayonly if direction, things are marginally more hairy. Let us suppose that , then
Here we will apply the division algorithm (Theorem 22.1.1), which tells us that we have unique and such that
(22.33) |
Then, it follows from that
which in turn implies that
Therefore, we can write that
from which we can show that ; as by definition there exists integer such that , and thus that
Then as it must be true that
and thus the desired equality holds.
22.2.2 The properties which make modular arithmetic
The first core property is this
Theorem 22.2.2
If and , then
Proof: TODO
Theorem 22.2.3
If and , then
Proof: TODO
Example 22.2.1
Calculate
This requires a bit of careful thinking about, but the result should be
(22.42) | |||||
(22.43) | |||||
(22.44) | |||||
(22.45) |
22.2.3 Fermat’s little theorem
There is also Fermat’s non-little theorem (called Fermat’s Last Theorem which was unproven for 358 years).
Theorem 22.2.4 (Fermat’s little theorem)
Let and be two coprime integers (i.e. ) then
todo: proof (it’s by induction, or using some abstract algebra).
Example 22.2.2
Find the value of
. That is, the remainder when is divided by .
The first thing to do is quickly write down that by Fermat’s Little Theorem (Theorem 22.2.4) we know that
Therefore, if we let be the quotient and the remainder of dividing by , we can then write
(22.48) | ||||
(22.49) | ||||
(22.50) | ||||
(22.51) | ||||
(22.52) |
We have substantially simplified this problem because it is now only a problem of finding , which we can do by computing . This requires a bit of arithmetic, but (if you know the rules of modular arithmetic) nothing too horrible;
(22.53) | ||||
(22.54) | ||||
(22.55) | ||||
(22.56) |
Therefore, the answer is that .
22.2.4 The Chinese remainder theorem (and related problems)
Example 22.2.3
Consider the function , where is defined by . Prove or disprove whether is surjective.
This statement is false, and we can prove it like this; first note that for to be surjective it must be true that for every there exists some such that
which is equivalent to the system of congruence equations
(22.58) | |||
(22.59) |
I found it helpful to draw a number line here, e.g. something like this
Thinking about some values for and , to me at least, the problematic values will be those that are close to and (or multiples therefore). If we think about, for example, numbers which are divisible by , but one bigger than or a multiple of (i.e. divisible by with remainder ), we encounter a problem, which is this; for the specific values and we are trying to solve the system of modular equations
(22.60) | |||
(22.61) |
But there are no numbers which are both odd and even, so there exists no such that , i.e. cannot be surjective.