Mathematical System (Applications)
Mathematical System (Applications)
Applications of Modular
Arithmetic
Applications of Modular Arithmetic
Modular arithmetic is used in many areas. Two
particular areas are error checking and
encryption. Error checking is the study of
methods to determine if there is something
wrong with the information. Encryption is the
study of converting information into “codes” so
that only certain people may receive the
original information.
Error Checking
Error Checking
There are many ways to check for errors.
One method involves using check digits. Check
digits are typically used to determine if there is
something wrong with a given sequence of
numbers. Thus, these are typically used for
barcodes, credit cards, International Standard
Book Numbers (ISBNs), and International
Standard Serial Numbers (ISSNs).
Note: The check digit is typically the rightmost
digit in the sequence of numbers. Thus, for
123456789, the check digit is 9.
Universal Product Code-A number
Definition: A UPC-A number
x1x2x3x4x5x6x7x8x9x10x11x12 is valid, if the following
congruence is true:
3x1 + x2 + 3x3 + x4 + 3x5 + x6 + 3x7 + x8 + 3x9 + x10
+ 3x11 + x12 ≡ 0 (mod 10)
Note that aside from the usual digits, you may see
an “X” for the check digit. This is used to represent
the number 10.
Examples
(2) Starting with the first number on the list, double every other number.
5, 7, 3, 4, 6, 2, 1, 9, 3, 3, 8, 7, 0, 9, 1, 2
⇒ 2×5, 7, 2×3, 4, 2×6, 2, 2×1, 9, 2×3, 3, 2×8, 7, 2×0, 9, 2×1, 2
⇒ 10, 7, 6, 4, 12, 2, 2, 9, 6, 3, 16, 7, 0, 9, 2, 2
(3) If there are any 2 digit numbers, list them as two separate single digits.
10, 7, 6, 4, 12, 2, 2, 9, 6, 3, 16, 7, 0, 9, 2, 2
⇒ 1, 0, 7, 6, 4, 1, 2, 2, 2, 9, 6, 3, 1, 6, 7, 0, 9, 2, 2
The 10 becomes a 1 and 0; the 12 becomes a 1 and 2; and the 16
becomes a 1 and 6.
Example
4) Add the numbers in the list.
1, 0, 7, 6, 4, 1, 2, 2, 2, 9, 6, 3, 1, 6, 7, 0, 9, 2, 2
1+0+7+6+4+1+2+2+2+9+6+3+1+6+7+0+9+
2+2
= 70
(5) The 16 digit credit card number is valid if the resulting sum is congruent to zero
modulo ten. Otherwise, it is invalid.
Since, 79 ≡ 9 (mod 10) INVALID
The credit card number 2915 3846 7123 5734 is not valid .
To make it valid, we will add 1 to 9 to make it 10 , since 10 is congruent to 0 (mod
10).
Note that the check digit is 4, we add 1 to make it 5. Then the number would be
valid. So, the check digit should be 5.
Try This!
1) Determine if the following are valid UPC-A numbers. If the number is not
valid, indicate what the check digit should be to make it valid. 5392 4040 6038
2) Determine if the following are valid ISBN-10 numbers. If the number is not
valid, indicate what the check digit should be to make it valid. 6597 9380 2X
3) Determine if the following are valid ISSNs. If the number is not valid, indicate
what the check digit should be to make it valid. 8348 7622
4) Determine if the following are valid credit card numbers. If the number is not
valid, indicate what the check digit should be to make it valid. 0241 6683 9099
2596
Mathematical System
Encryption
Encryption
• Encryption involves converting information into
another form so that it is not easily understood. The
purpose of this is to try and ensure that only the
intended recipients understand the original
information.
• This section will go over two methods of
encryption, which are the Caesar cipher (or shift
cipher), and the affine cipher
Definition
The shift cipher transforms messages by shifting the
alphabets.
• Example
The following table is a shift cipher that uses a shift of
6 letters to encrypt a message.
A B C D E F G H I J K L MNO P Q R S T U VWX Y Z
G H I J K L MNO P Q R S T U VWX Y Z A B C D E F
A B C D E F G H I J K L MNO P Q R S T U VWX Y Z
G H I J K L MNO P Q R S T U VWX Y Z A B C D E F
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
“DAYLIGHT” is first converted to its numerical equivalent using the table,
so it becomes “3, 0, 24, 11, 8, 6, 7, 19”. The shift value is then added to
each number. In the example, the shift value was 6, thus “3, 0, 24, 11, 8,
6, 7, 19” becomes “9, 6, 30, 17, 14, 12, 13, 25”. Next, determine the
residues with respect to modulo 26. Thus, “9, 6, 30, 17, 14, 12, 13, 25”
becomes “9, 6, 4, 17, 14, 12, 13, 25”. Finally, get the letters
corresponding to the numbers. Thus, “9, 6, 4, 17, 14, 12, 13, 25”
becomes “JGEROMNZ”.
• In summary, if E is the number for the encrypted
letter, O the number for the original letter, and S the
shift value, then:
• E ≡ O + S (mod 26)
• Similarly, to decrypt a message, the following
congruence can be used:
• O ≡ E – S (mod 26)
Example
Encrypt the following messages using a shift cipher with the
indicated shift value.
1) “LOVE”; S = 9
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
Example
Encrypt the following messages using affine cipher with the
indicated shift value.
1) “LOVE”; S = 9 ; M = 15
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25