OFFSET
0,2
COMMENTS
Complex base i-1 of Khmelnik and Penney uses an integer n>=0 to represent a complex integer z(n) = A318438(n) + A318439(n)*i. a(n) is the negation of z in this representation, so that z(a(n)) = -z(n). Every z is uniquely represented, so this is a self-inverse permutation.
Khmelnik's table 4 is carries applied to z which become states and transitions by bits of n and certain 0<->1 bit flips in n. The result is the transformation in the formulas below. Bit flips may extend into 0-bits above the most significant bit of n causing the bit length of a(n) to be greater than the bit length of n.
LINKS
Kevin Ryde, Table of n, a(n) for n = 0..8192
Joerg Arndt, The fxt demos: bit wizardry. radix(-1+i)
Solomon I. Khmelnik, Specialized Digital Computer for Operations with Complex Numbers (in Russian), Questions of Radio Electronics, volume 12, number 2, 1964.
Kevin Ryde, Iterations of the Dragon Curve, see index MinusNeg.
Andrey Zabolotskiy, English translation of theorems from Khmelnik, Seqfan mailing list, September 2016.
Andrey Zabolotskiy, Python Code by bit flips or conversion and Python Code by Khmelnik's Pi and Beta, September 2016.
FORMULA
a(n) is formed by transforming n as follows. Write n in binary with four high 0-bits and consider bits from least to most significant. At a 01 pair (high 0, low 1), apply an 0<->1 flip to three bits immediately above this pair. At a 11 pair, flip one bit immediately above this pair. Repeat, each time seeking the next higher 01 or 11 pair above the bits just flipped.
EXAMPLE
For n=1506, location z(1506) = 11-35*i. Its negation is -(11-35*i) = z(29914) so a(1506) = 29914. And being self-inverse conversely a(29914) = 1506.
In terms of bit flips, in the following "^^" is each 01 or 11 and F marks the bits flipped above them.
n = 1506 = binary 00001 0 1 11 100 01 0
FFF^^ F ^^ FFF ^^
a(n) = 29914 = binary 11101 0 0 11 011 01 0
PROG
(PARI) { a(n) = for(i=0, if(n, logint(n, 2)),
if(bittest(n, i),
if(bittest(n, i+1), n=bitxor(n, 4<<i); i+=2,
n=bitxor(n, 28<<i); i+=4))); n; }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Kevin Ryde, Jan 15 2021
STATUS
approved