Jun 13, 2010

More ±modular arithmetic

I have been playing around with modular arithmetic sporadically since earlier this year, and I posted a couple of entries about my observations in my old blog.

Fun with modular arithmetic (1)
Fun with modular arithmetic (2)

What is modular arithmetic? Here is the introductory sentence from the Wikipedia article about the subject:
In mathematicsmodular arithmetic (sometimes called clock arithmetic) is a system of arithmetic for integers, where numbers "wrap around" after they reach a certain value—the modulus 
Ordinary arithmetic may be thought of as using numbers on a line stretching infinitely from left to right; modular arithmetic may be thought of as using numbers wrapped around a circle.



I have noted that introducing negative numbers gives added symmetry to the modular multiplication table. With mod 10, for example, the conventional multiplication table (omitting the 0 column and row for simplicity) looks like this, with symmetry across both diagonals:



But with negative numbers, we get this:







I think the additional symmetry is beautiful—specifically, the negative mirroring left to right and top to bottom across the ±5 column and row. Nothing surprising about it, of course, but pretty nonetheless. Oh, and I would call your attention to the main diagonal (colored blue), which gives the products of numbers multiplied by themselves, i.e., squares. It turns out that all the squares are either plus or minus 1, plus or minus 4, or 5. And of course we mustn't forget 0, which is the product of 0 times 0. Using positive values, we have six possibilities: 0, 1, 4, 5, 6, and 9. In regular arithmetic, the final digit of any square number must be one of these six; i.e., no square numbers end in 2, 3, 7, or 8.

Moving right along, let's look at the multiplication table for mod 13, using both positive and negative numbers:





Here, since the modulus is odd, we don't have anything like the ±5 row and column in the ±mod 10 table, but we still have the negative mirroring of the left and right halves and top and bottom halves. And in this case it turns out that the squares, aside from 0, are limited to plus and minus 1, 3, and 4. Which may not be such an interesting observation, but note also that each row and column includes all the digits. This is because the modulus is prime. And each half row and half column includes either the positive or the negative value of all of the digits. This is a regularity that isn't be so obvious with the usual sort of notation, using positive numbers only, where the left-right and top-bottom mirroring is not to be seen:





With a prime modulus like 13 we can also present a complete division table, since every number except zero is uniquely divisible by every other number. I will show that another time. Meanwhile, here is a link to a page with many more interesting observations about modular arithmetic—which would be even better, IMHO, if it used negative numbers:

http://www.cut-the-knot.org/blue/Modulo.shtml