Real life applications of modular arithmetic

Modular arithmetic might seem like a strange concept, but we use it all the time in our daily life.

For example, we keep the hour by using mod 12 (some people use mod 24 instead).

Write 1pm as a maple command of a mod 12 and then execute your statement.

>

Explain how you chose your a for a mod 12 .

If it was 2:00 A.M. now, what time would it be 3736 hours from now? Explain using a maple command and

text comments.

>

Modular arithmetic is an indispensable tool in computer science.

One application concerns the generation of "random" numbers: a sequence of integers that is easily produced and passes a number of

statistical tests for randomness . A common method for generating such numbers is to use a recursion formula of the form

X n+1 = (a*X n + c) mod m . To use such a formula, one chooses the modulus m, the multiplier a,

and the increment c, as well as an initial value for Xo (often called the seed). Over the

years, guidelines have evolved for selecting a,c, and m. Typically , m is a large power of 2

(example, 2^32) and a=5. Numbers generated by this method are completely determined by the choice of these parameters and the initial value, and so they are not random . Nevertheless, the numbers to possess many properties that we expect of random numbers, and so they are very useful in building codes and in security . Let's generate a list of such numbers! C will be 0, a=5, Xo=1. We'll print out the first

100 elements of the sequence:

> X := n -> if n>1 then 5*X(n-1) mod 2^32 else 1 fi:

> seq(X(k), k=1..100);

So, we could use Maple to easily create a large list of numbers that behave like random numbers do using

modular arithmetic.

Modular arithmetic is often used in assigning an extra digit to identification numbers for the purpose of

detecting forgery or errors . For example, airline companies, UPS

and Avis and National rental car companies use the modulo 7 values of identification numbers to

assign check digits, while the US Postal service uses modulo 9 :

A United States Postal Service money order (mod 9) has an identification number consisting of 10 digits

together with an extra digit called a check. The check digit is the 10-digit number modulo 9.

Thus, the number 3953988164 has the check digit 2 since

> 3953988164 mod 9;

So, the number printed on the top of the money order is 39539881642. If this number were

incorrectly entered into a computer (programmed to calculate the check digit) as, say,

39559881642 (and error in the fourth position),

then the machine would calculate the check digit (the last number on the check) as

> 3955988164 mod 9;

The error would be detected if the check digit of 2 (the last number on the money order number 39559881642) does not match the computer's calculation.

Does the machine calculate the error in this case? Explain why or why not.

Suppose that a money order with the identification number and check digit 21720421168 is erroneously copied as 27750421168. Will the check digit 8 detect the error? Explain using Maple statements and a text explanation.

>

>