Tuesday, April 30, 2013

Base Eighteen on a Chinese Abacus

For the sake of simplicity, my use here of number words (ten, hundred) instead of digits (10, 100) will refer to decimal values. "Ten" =

I've been interested in arithmetic on the abacus for a while now, although I'm still quite the amateur. Last year I wrote a (not yet officially adopted) plugin to the Khan Academy Exercises engine to allow practice exercises on a 4x1 soroban, which helped me improve my speed and accuracy with basic addition, and I've acquired these two real-world abaci:

The top abacus is a cheap Chinese 5x2 Suanpan I bought in Chicago's Chinatown a few years back when my wife and I vacationed there, and the bottom abacus is a better quality Japanese 4x1 Soroban that Liberty ordered for me as a Christmas present last year (along with a book on the Haskell programming language I've been wanting - best wife ever!). "Suanpan" and "Soroban" are language variants on the same word, which roughly translates to English as "counting tray", and neither name implies a specific number of beads.

On each abacus in the picture above, one column is set to the number nine, and the others to zero. If you are unfamiliar with how numbers work on an Asian abacus, it's very simple: The bottom beads (Earth) are worth 1 each, the top beads (Heaven) are worth 5. When a bead is moved toward the dividing bar, it counts toward the final number. On the 4x1 Soroban, numbers from 0 to 4 can be represented with earth beads, and either 0 or 5 with the heaven bead, so each column can represent the digit 0 through 9.

On the 5x2 Suanpan, however, earth beads can represent 0 through 5, and the heaven beads can have a value of 0, 5, or 10. In modern practice, the extra top and bottom beads are used to cache carry operations, however the Wikipedia entry on Suanpan makes a reference to this also being used historically for base sixteen (hexadecimal) fractions, which merchants took advantage of back before measurements or money (it's unclear which - as is the validity of the assertion) became standardized to base ten.

After thinking that through, I saw that the 5x2 abacus could instead represent base eighteen (octodecimal) if the heaven beads were worth 6 instead of 5, which better aligns with the eighteen possible positions each column has. With that method, this enumeration shows the values for each position:

Wacky, and according to a handful of Google searches, seemingly undiscovered by anyone before me. I hope I'm wrong on that point, as it seems like a straightforward deduction (please shoot me a reference if you've heard of this before). So what exactly can one do in the octodecimal world, and more importantly, what makes it interesting enough to investigate?

The visual

For starters, I can "see" 10 in my head only with moderate effort (I picture two dice with 5 facing up), but I can't look at a group of approximately fourteen random objects and tell you whether the number of them is closer to ten or eighteen without counting. Representing 10 in octodecimal as:

seems as visually "right" as if 10 is represented the normal decimal way:

Similarly, 100 represented octodecimally...

...could pass visually for my idea of what 100 should look like as if it were represented decimally:

When you think of higher powers of 10 visually - a thousand, or ten thousand - what do you see? I see a whole lot, and a huge, unidentifiable mass, and if I came across collections of that size unexpectedly, I doubt I could estimate them within a factor of two.

Multiplication table

The closest match to octodemical in popular use now is hexadecimal (base sixteen, or "hex" as the cool kids say), commonly used in software development. Hexadecimal values less than ten are represented as 0 through 9, and values ten through fifteen are represented by the letters "a" through "f" so that those values can still be shown as single "digits". We can easily expand that another two characters, using "g" for sixteen, and "h" for seventeen. Using that framework, an octodecimal multiplication table looks like this:

2 * 2 =  4
2 * 3 =  6    3 * 3 =  9
2 * 4 =  8    3 * 4 =  c    4 * 4 =  g
2 * 5 =  a    3 * 5 =  f    4 * 5 = 12    5 * 5 = 17
2 * 6 =  c    3 * 6 = 10    4 * 6 = 16    5 * 6 = 1c    6 * 6 = 20
2 * 7 =  e    3 * 7 = 13    4 * 7 = 1a    5 * 7 = 1h    6 * 7 = 26    7 * 7 = 2d
2 * 8 =  g    3 * 8 = 16    4 * 8 = 1e    5 * 8 = 24    6 * 8 = 2c    7 * 8 = 32
2 * 9 = 10    3 * 9 = 19    4 * 9 = 20    5 * 9 = 29    6 * 9 = 30    7 * 9 = 39
2 * a = 12    3 * a = 1c    4 * a = 24    5 * a = 2e    6 * a = 36    7 * a = 3g
2 * b = 14    3 * b = 1f    4 * b = 28    5 * b = 31    6 * b = 3c    7 * b = 45
2 * c = 16    3 * c = 20    4 * c = 2c    5 * c = 36    6 * c = 40    7 * c = 4c
2 * d = 18    3 * d = 23    4 * d = 2g    5 * d = 3b    6 * d = 46    7 * d = 51
2 * e = 1a    3 * e = 26    4 * e = 32    5 * e = 3g    6 * e = 4c    7 * e = 58
2 * f = 1c    3 * f = 29    4 * f = 36    5 * f = 43    6 * f = 50    7 * f = 5f
2 * g = 1e    3 * g = 2c    4 * g = 3a    5 * g = 48    6 * g = 56    7 * g = 64
2 * h = 1g    3 * h = 2f    4 * h = 3e    5 * h = 4d    6 * h = 5c    7 * h = 6b


8 * 8 = 3a
8 * 9 = 40    9 * 9 = 49
8 * a = 48    9 * a = 50    a * a = 5a
8 * b = 4g    9 * b = 59    a * b = 62    b * b = 6d
8 * c = 56    9 * c = 60    a * c = 6c    b * c = 76    c * c = 80
8 * d = 5e    9 * d = 69    a * d = 74    b * d = 7h    c * d = 8c    d * d = 97
8 * e = 64    9 * e = 70    a * e = 7e    b * e = 8a    c * e = 96    d * e = a2
8 * f = 6c    9 * f = 79    a * f = 86    b * f = 93    c * f = a0    d * f = af
8 * g = 72    9 * g = 80    a * g = 8g    b * g = 9e    c * g = ac    d * g = ba
8 * h = 7a    9 * h = 89    a * h = 98    b * h = a7    c * h = b6    d * h = c5


e * e = ag
e * f = bc    f * f = c9
e * g = c8    f * g = d6    g * g = e4
e * h = d4    f * h = e3    g * h = f2    h * h = g1

A few things jump out at me from this table. First, there aren't a lot of products that end with "h" (seventeen). In fact, there are only two. Here they are in octodecimal, and converted to base ten:

Octodecimal    Decimal
5 * 7 = 1h     5 * 7 =   (1 * 18) + 17 = 35
b * d = 7h     11 * 13 = (7 * 18) + 17 = 126 + 17 = 143

I imagine this is due in part to seventeen being the largest prime less than the radix. Similarly, in a base ten multiplication table constructed the same way, the largest prime less than the radix is 7, which ends a product only once, 3 * 9 = 27. In both the "h" and 7 examples, the multiplicand and multiplier are coprime to the radix. Maybe that's significant, or maybe it doesn't apply to other bases the same way; couldn't say, but I find it interesting.

Another thing that is neat is that all the "h" equations have a product whose digits sum to "h" (h * 2 = 1g, 1 + g = h; g * h = f2, f + 2 = h), similar to base 10 where the products of the 9 equations all have digits that sum to 9 (3 * 9 = 27, 2 + 7 = 9; 7 * 9 = 63, 6 + 3 = 9). This page (pdf) from the Dozenal Society shows that the same principal applies to all other bases as well (at least to all the ones I can read, they use a custom character set for large bases).

The last fun thing that stands out is the products ending with 0:

6 * 3 = 10    
6 * 6 = 20    9 * 2 = 10
6 * 9 = 30    9 * 4 = 20
6 * c = 40    9 * 6 = 30
6 * f = 50    9 * 8 = 40
              9 * a = 50
c * 3 = 20    9 * c = 60
c * 6 = 40    9 * e = 70
c * 9 = 60    9 * g = 80
c * c = 80    
c * f = a0    

The numbers 6, 9, and c (twelve) all share two factors with 10 (eighteen), and the number they are multiplied with contains the third factor, producing a multiple of 10. Neat.

Relearning multiplication tables at 40

In short, it's a bear. I wrote a quick HTML5 flashcard app below to time how quickly I could convert octodecimal digits to decimal numbers, as well as multiply by 2 in octodecimal. After I recorded the video below I kept practicing and got a little better, and then added the other tables up to h... but I couldn't do it. Not yet. I got about 90% with the 3's multiplication table, and barely made a dent in 4's. I think I'd have to spend a couple hours a day at this for weeks (and avoid decimal numbers in everyday life) before I memorized up to the H's table. Anyway, here's me plugging away at basic decimal conversion and the 2's table:

In closing, our concept of "10" is arbitrary, like a few things in mathematics that I once assumed were natural laws. It's a cultural decision, like order of operations and multiplying matrices. Scaling 10 up to contain eighteen things is only as jarring to my internal estimator as software development's hexadecimal or New Math's octal, and much less so than hardware engineering's binary, or the Sumerian base sixty for angle calculations. Why base eighteen? Because there exists a popular tool which naturally lends itself to calculating in that base. I don't think there is a current need in the world for octodemical, but it's a fun exercise, and fun is enough.

No comments:

Post a Comment