How to compute ¼ + ¼ in balanced ternary?

127 Views Asked by At

Let’s recall that balanced ternary is a variant of classic ternary base, where instead of having digits $\{0\ ; 1\ ; 2\}$, the three digits are $\{-1\ ; 0\ ; 1\}$. For practical reasons I will use the character $\mathrm{S}$ as digit of value $-1$.

In this system, one can see that $0,1\mathrm{S}1\mathrm{S}1\mathrm{S}1\mathrm{S}… = 1\mathrm{S} \times 0,01010101… = 2 \cdot\sum_{k = 1}^{\infty} 9^{-k} = 1/4$.

Now, what happens if we try to sum $0,1\mathrm{S}1\mathrm{S}1\mathrm{S}1\mathrm{S}… + 0,1\mathrm{S}1\mathrm{S}1\mathrm{S}1\mathrm{S}…$ ? We expect to get $½$, that is : either $0,111111…$ or $1,\mathrm{S}\mathrm{S}\mathrm{S}\mathrm{S}\mathrm{S}\mathrm{S}…$ . Let’s do it using the primary school method, just presented a bit differently. Let $a = b = 0,1\mathrm{S}1\mathrm{S}1\mathrm{S}1\mathrm{S}…$ considered as infinite arrays, each digit being indexed by its corresponding power of $3$, that is : $$a[i \geq 0] = 0\ ;\ a[i = 2k < 0] = \mathrm{S}\ ;\ a[i = 2k + 1 < 0] = 1$$ (the same goes for $b$).

Let’s define $a’$ and $b’$ as : $a’[i] = (a[i] + b[i])\ \mathrm{mod}\ 3$ and $b’[i] = (a[i-1] + b[i-1] – a’[i-1]) / 3$.

This makes more sense when written as $a[i] + b[i] = 3\cdot b’[i+1] + a’[i]$.

$b’$ represents an array of carries.

We have $a’ + b’ = a + b$, so we iterate recursively with $a := a’$ and $b := b’$.

For instance : \begin{equation*} \begin{array}{@{}B2} & 0&1& \\ {} +& 0&1& \\ \hline & 0&\mathrm{S}& \\ {} +& 1&0& \\ \hline & 1&\mathrm{S}& \\ {} +& 0&0& \\ \end{array} \end{equation*}

As far as I know this method always terminates with usual decimal notation in the sense that for any index $i$, the carry register at this index $b’[i]$ will be permanently set to $0$ after a finite (though arbitrarily long) number of steps. Note : in the general case one can not expect the whole carry register $b’$ to be equal to $0$ after a (however long) finite number of steps.

In our case this method gives : \begin{equation*} \begin{array}{@{}B2} & 0&,&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&…& \\ {} +& 0&,&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&…& \\ \hline & 0&,&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&…& \\ {} +& 1&,&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&…& \\ \hline & 1&,&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&…& \\ {} +& \mathrm{S}&,&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&…& \\ \hline & 0&,&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&…& \\ {} +& 1&,&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&\mathrm{S}&1&…& \\ \hline & & & & & &…& & & & & & \end{array} \end{equation*}

The calculus loops. I wonder if this is linked to $½$ having two representations, none being better than the other : since the addition method presented here introduces no symmetry-breaking convention, the computation stalls.

Apart from abstracting the expression $0,1\mathrm{S}1\mathrm{S}1\mathrm{S}1\mathrm{S}…$ as $¼$ and then conclude, is there a general addition algorithm that terminates for this specific calculus ?

1

There are 1 best solutions below

0
On BEST ANSWER

One possible answer is to generalize the addition algorithm that is presented in introduction.

We keep the idea of two arrays, one for summation with a modulo, the second for the carries. We also keep the recursive iteration, though we won't need it this time.

However, instead of processing digit-by-digit summation, we will proceed pair of digits-by-pair of digits.

The « symmetry-breaking convention » I suspected above lies here : how do we group digits in pairs ? There are two possible ways : $0,\ 1\mathrm{S}\ 1\mathrm{S}\ 1\mathrm{S}\ …$ or $0,1\ \mathrm{S}1\ \mathrm{S}1\ \mathrm{S}1\ …$.

Reminding that $1\mathrm{S} + 1\mathrm{S} = 11$ ; $\mathrm{S}1 + \mathrm{S}1 = \mathrm{S}\mathrm{S}$ and $0,1 + 0,1 = 1,\mathrm{S}$ ; we see that first convention gives $$0,\ 1\mathrm{S}\ 1\mathrm{S}\ 1\mathrm{S}\ … + 0,\ 1\mathrm{S}\ 1\mathrm{S}\ 1\mathrm{S}\ … = 0,\ 11\ 11\ 11\ …$$ and second convention gives $$0,1\ \mathrm{S}1\ \mathrm{S}1\ \mathrm{S}1\ … + 0,1\ \mathrm{S}1\ \mathrm{S}1\ \mathrm{S}1\ … = 1,\mathrm{S}\ \mathrm{S}\mathrm{S}\ \mathrm{S}\mathrm{S}\ \mathrm{S}\mathrm{S}\ …$$ which are both writings of $1/2$.