 # Balanced base 2+i (and some gratuitous fractals)

Traditional numeral systems, such as binary, decimal, and dozenal, let us represent non-negative numbers in a systematic way. When we want to write down a negative number, we write a $-$ sign followed by a positive number. There are other numeral systems, such as balanced ternary, that let us write down both positive and negative numbers in a seamless, systematic way.

Balanced ternary, like ternary (base three), is based on powers of three, but unlike ternary, whose digits are 0, 1, and 2, the digits used in balanced ternary are 0, 1, and 1, the last of which represents negative one.  As in binary, the product of any two digits is a digit, which can simplify multiplication, but the symmetry around 0 means that to negate a number, you just turn each digit upside down.

Donald Knuth apparently called balanced ternary “perhaps the prettiest number system of all”, but even in balanced ternary, complex numbers have to be written as a real number plus the product of a real number with $i$, the imaginary unit.  Can we represent all complex numbers in a seamless, systematic way?

It turns out that Donald Knuth is again the man to ask; he described what I think was the first complex numeral system, called the the quater-imaginary numeral system, which is based on powers of $2i$ and uses the digits 0, 1, 2, and 3. But not all Gaussian integers can be represented solely using digits before the decimal radix point. For example, $i$ is represented as 10.2.

There’s also base $-1 + i$, based, as you might expect, on powers of $-1 + i$, with just two digits: 0 and 1.  As in binary and balanced ternary, the product of any two digits is a digit, but the usual algorithm for addition runs into a problem.  Think about what happens when you add 11101 (which represents negative one) to 1.  Each time you calculate the next-least-significant digit, it’ll turn out to be 0, but you’ll often have to carry a lot of other digits, and you’ll never run out of carried non-zero digits to add to each other. (This is a problem with the quater-imaginary base, too.)

Also, base $-1 + i$ and the quater-imaginary base don’t really feel as “balanced” as balanced ternary; their sets of digits aren’t as symmetrical.

But if we use powers of $2 + i$ instead, we can come up with what I’m calling balanced base $2 + i$, using five digits to represent the numbers $0$, $1$, $-1$, $i$, and $-i$.  It won’t do to have $-$ signs running around in the middle of multiple-digit numbers, though, so I propose these digits:

• $0$: • $i$: • $-i$: • $1$: • $-1$: So for the non-zero digits, the tittle indicates where to find on an Argand diagram the number represented by the digit. (I admit that a font whose $i$ has a less rotationally symmetric stem would make it easier to distinguish a string of s from a string of s in the middle of a long number.)

As in binary, balanced ternary, and base $-1 + i$, balanced base $2 + i$ has the property that the product of any two digits is a digit. As is the case with the quater-imaginary base and base $-1 + i$, it can be used to seamlessly represent any complex number. As is the case with base $-1 + i$, it can represent any Gaussian integer without resorting to digits after the radix point. As is the case with balanced ternary and all of the more traditional numeral systems, I think its addition algorithm is immune to infinite carries of the kind base $-1 + i$ and the quater-imaginary base are susceptible to.

And as is the case with balanced ternary, the set of digits used in balanced base $2 + i$ has significant symmetry around 0, so that negating a number requires just rotating each digit by two right angles. What’s more: multiplying a number by $i$ requires just rotating each digit anticlockwise by one right angle; this trick isn’t possible in any of the other bases we’ve looked at so far. (Okay, so a rotated 0 might look a bit strange if it wasn’t a perfect circle to begin with, but it’ll be recognizable.)

# Gratuitous fractals

When you’re representing a number in balanced base $2 + i$, one of the questions you have to answer is Which part of the number do I put before the radix point, and which part after? Actually, this question is important when representing a number in any base.  In traditional base systems, you can just put the floor of the number before the radix point and the rest can be represented after it.  In balanced ternary, you can’t represent, say, the number two thirds after the radix point; instead, you round the number to the nearest integer, put that before the point, and put the rest after it, so two thirds is represented as 1.1.

In balanced base $2 + i$, the numbers you can represent using non-zero digits only after the point are the numbers inside (and on) this boundary: So you round your number to a Gaussian integer so that the remainder falls inside or on that boundary, put the rounded part before the point, and the rest after it. Not necessarily the most helpful description for actual computation, I admit, but a pretty description, nonetheless.

If you like the look of that fractal, perhaps you might enjoy watching its construction. I believe it’s a valid GIF, but the file is large, and my browser struggles with it, so you might find you need to download it and view it in another image viewer.

## Cantor lace

There’s a fractal related to balanced ternary known as the Cantor set. One way of defining it is as the set of all numbers that can be represented after the radix point in balanced ternary, without using the digit 0.

This is sometimes generalized to Cantor dust, which can be defined as the Cartesian product of the Cantor set with itself. Boring.

What if we defined a different generalization of the Cantor set — this time as the set of all numbers that can be represented after the radix point in some base system, without using the digit 0? For balanced base $2+i$, we’d get something like this: Cantor lace seems an adequate name for it.

And here’s an animation of its construction: 