# A ternary notation

Antti Karttunen antti.karttunen at gmail.com
Thu Sep 15 14:31:37 CEST 2005

```Eric Angelini wrote:

> Hello SeqFan and Math-Fun,
> Consider this (hope this is not old-hat):
>
>   3^0  3^1  3^2  3^3  3^4  3^5  3^6  3^7 ...
>=   1    3    9    27   81  243  729  2187 ...
>
>This seq. is known to be very efficient if you
>want to weigh integer weights with a two-tray
>balance, leaving no "holes" behind; use weights
>of 1,3,9,27... units to measure all "natural"
>quantities, from 1 to infinity:
>
>
>
<snip>

>Let's do the same with the powers of 3; we will
>mark with a "1" the powers we need, with a "0"
>the ones we will discard and (novelty!) with
>a "2" the quantity we will substract
>

In a way, this is also consistent and appropriate, as 2 is -1 mod 3.

> (I will
>use the star symbol (*) to indicate hereunder
>an operation in base 10):
>
>   3^0  3^1  3^2  3^3  3^4  3^5  3^6  3^7 ...
>=   1    3    9    27   81  243  729  2187 ...
>
> 1 = 1
> 2 = *3-1* = 121
> 3 = 01 => 10
> 4 = *3+1* = 11
> 5 = *9-4* = 1211
> 6 = *9-3* = 1210
> 7 = *9-2* = 12121
> 8 = *9-1* = 1201
> 9 = 001 => 100
>
>

Why 2 is not marked just as 12 (i.e. +1*3 + -1*1 ?)
And then 3 = 10, 4 = 11 as you have given,
but 5 = +1*9 + -1*3 + -1*1 = 122
6 = +1*9 + -1*3 + 0*1 = 120
7 = +1*9 + -1*3 + 1*1 = 121
8 = +1*9 +  0*3 + -1*1 = 102
9 = +1*9 +  0*3 +  0*1 = 100

I am sorry, but the terms
1,12,10,11,122,120,121,102,100
do not match anything in the table.

>The "ternary notation" above can certainly be
>bettered as the "ternary artefacts" 20, 1220,
>represent nothing.
>
>
No. They represent negative integers:

-1 = -1*1 = 2
-2 = -1*3 + 1*1 = 21
-3 = -1*3+0*1 = 20
-4 = -1*3 + -1*1 = 22
-5 = -1*9 + 1*3 + 1*1 = 211
-6 = -1*9 + 1*3 + 0*1 = 210
-7 = -1*9 + 1*3 + -1*1 = 212
-8 = -1*9 + 0*3 + 1*1 = 201
-9 = -1*9 + 0*3 + 0*3 = 200

We see that to convert an integer to its negative in this notation,
we have just to swap ones and twos 1 <-> 2, and keep zeros
intact.

I am sorry, but the terms
2,21,20,22,211,210,212,201,200
do not match anything in the table.

Now, of course any such ternary string (either 0, or beginning
with a non-zero digit, i.e. either 1 or 2) represents non-negative
integers in the usual ternary notation:

http://www.research.att.com/projects/OEIS?Anum=A007089

And because I'm looking for bijections everywhere, even simple ones,
one expects two to be lurking here. We just need to "fold" the integers
to natural numbers with f: Z -> N as given by f(z) = 2z if z>0 else 2|z|+1,
and vice versa, with its inverse* *g(z) = z/2 if z even else (1-z)/2.

So we get those two sequences (for positive and negative integers)
interleaved:

I am sorry, but the terms
0,1,2,12,21,10,20,11,22,122,211,120,210,121,212,102,201,100,200
do not match anything in the table.

Reinterpreting them in ordinary ternary notation, we get:

I am sorry, but the terms
0,1,2,5,7,3,6,4,8,17,22,15,21,20,16,23,11,19,9,18,
do not match anything in the table.

And actually, this seems to be an involution (self-inverse permutation),
so we get just one permutation, not two.
Why is this? (Or is it?) I have to think about it, but first I will finish
my coffee to raise my IQ temporarily from that of the greater apes.

Salut, Regards, Groetjes, Terveisin,

Antti

>Best,
>É.
>
>(seq. 0,1,121,10,11,1211,1210,12121,1201,100,...
> is not in the OEIS)
>
>
>
>
>

```