Okay, let's break down how addition works in modular arithmetic, often referred to as modular addition.
Modular addition is a system of arithmetic for integers where numbers "wrap around" when reaching a certain value—the modulus. It's like arithmetic on a clock, where adding hours eventually brings you back to 12 (or 0).
To "add modulus" (more accurately, to perform addition modulo N
), you typically add the numbers together as usual and then find the remainder when the sum is divided by the modulus N
.
Modular arithmetic follows specific rules that govern how addition interacts with the modulus. The references provided highlight several key properties:
-
Reference 1: Relating Standard Sum to Modular Sum
If you have a standard addition equation,a + b = c
, then the result of performing modular addition ona
andb
moduloN
is equivalent to taking the standard sumc
moduloN
. This is expressed as:
a (mod N) + b (mod N) ≡ c (mod N)
This means(a + b) mod N
is congruent to(a mod N + b mod N) mod N
. It shows that you can either add the numbers first and then find the remainder, or find the remainders of the individual numbers first, add those remainders, and then find the remainder of that sum. The final result will be the same (or congruent modulo N). -
Reference 3: Adding Congruent Numbers
If two numbersa
andb
are congruent moduloN
(a ≡ b (mod N)
), and two other numbersc
andd
are also congruent moduloN
(c ≡ d (mod N)
), then adding these pairs preserves the congruence. The suma + c
will be congruent to the sumb + d
moduloN
.
If a ≡ b ( mod N ) , and c ≡ d ( mod N ) , then a + c ≡ b + d ( mod N ) .
This property is fundamental because it allows us to replace a number with any other number it is congruent to within a modular addition without changing the result moduloN
. -
Reference 2: Adding a Constant
If two numbersa
andb
are congruent moduloN
(a ≡ b (mod N)
), adding the same integerk
to both numbers maintains their congruence moduloN
.
If a ≡ b ( mod N ) , then a + k ≡ b + k ( mod N ) for any integer .
This property shows that adding a constant shifts congruent numbers together. -
Reference 4: Negation
Ifa
is congruent tob
moduloN
(a ≡ b (mod N)
), then their negations,-a
and-b
, are also congruent moduloN
.
If a ≡ b ( mod N ) , then − a ≡ − b ( mod N ) .
While not strictly about addition, this property is related as subtraction is addition of a negative number.
How to Perform Modular Addition
Practically, performing addition modulo N
involves these steps:
- Add the numbers: Perform the standard addition of the numbers
a
andb
to get their sum,S = a + b
. - Divide by the modulus: Divide the sum
S
by the modulusN
. - Find the remainder: The result of
(a + b) mod N
is the remainder obtained in Step 2. The remainder is always a non-negative integer smaller thanN
(in the range0
toN-1
).
Alternatively, based on Reference 1, you can also first find the remainder of each number when divided by N
, add these remainders, and then find the remainder of that sum when divided by N
.
(a + b) mod N ≡ ((a mod N) + (b mod N)) mod N
Example of Modular Addition
Let's add 17 and 11 modulo 5.
- Standard Sum:
17 + 11 = 28
. - Divide by Modulus: Divide 28 by 5.
28 ÷ 5 = 5
with a remainder of3
. - Result:
17 + 11 ≡ 3 (mod 5)
.
Using the alternative method (from Reference 1):
- Find individual remainders:
17 mod 5 = 2
(since17 = 3 * 5 + 2
)11 mod 5 = 1
(since11 = 2 * 5 + 1
)
- Add the remainders:
2 + 1 = 3
. - Find the remainder of the sum of remainders:
3 mod 5 = 3
.
Both methods yield the same result: 3.
Here's another example in a table format:
Numbers to Add (a, b) | Modulus (N) | Standard Sum (a+b) | Division: (a+b) ÷ N | Remainder ( (a+b) mod N ) | Modular Sum |
---|---|---|---|---|---|
17, 11 | 5 | 28 | 28 ÷ 5 = 5 R 3 | 3 | 3 |
8, 9 | 10 | 17 | 17 ÷ 10 = 1 R 7 | 7 | 7 |
5, 7 | 12 | 12 | 12 ÷ 12 = 1 R 0 | 0 | 0 |
Practical Application
Modular addition is used extensively in various fields:
- Timekeeping: Clocks use modulo 12 (or 24) arithmetic for hours. If it's 10 o'clock and you add 4 hours, it's 2 o'clock (10 + 4 = 14; 14 mod 12 = 2).
- Cryptography: Many encryption algorithms rely on modular arithmetic operations.
- Computer Science: Operations on finite data types often implicitly use modular arithmetic (e.g., integer overflow).
In essence, adding modulus involves adding numbers within a system where the results are confined to a range defined by the modulus, effectively wrapping around when the limit is reached.