login
Circle aliasing numbers with 1/n size steps.
0

%I #27 Jul 05 2018 00:56:15

%S 10,1010,110100,11010100,1101100100,110110100100,11101010101000,

%T 1110110101001000,111011010101001000,11101101101001001000,

%U 1110111010101010001000,111011101010101010001000,11110110110101010010010000,1111011011010101010010010000,111101110101101010010100010000

%N Circle aliasing numbers with 1/n size steps.

%C Starting from [-1,0] taking 2*n steps of length 1/n each either up or right, follow the path staying as close to the unit circle as possible. Every step up is considered a 1, every step right is considered a 0.

%e For n=3, we have 110100, meaning if we were to start at [-1, 0] and take 2*n=6 steps of length 1/n = 1/6 which can either be up or to the right, to follow the path of the unit circle the closest we would move up 1, up 1 again, then right, then up again, then right two more times, which we translate to the binary number 110100.

%o (Python)

%o def closer(pos1, pos2):

%o dpos1 = (pos1[0]**2.0+pos1[1]**2.0)**.5

%o dpos2 = (pos2[0]**2.0+pos2[1]**2.0)**.5

%o if (1.0-dpos1)**2.0 < (1.0-dpos2)**2.0:

%o return True

%o else:

%o return False

%o def converts(path):

%o return ''.join(path)

%o l = []

%o for steps in range(1, 20):

%o stepsize = 1.0/steps

%o pos = [-1.0, 0.0]

%o paths = []

%o for i in range(0, 2*steps):

%o if closer([pos[0]+stepsize, pos[1]], [pos[0], pos[1]+stepsize]):

%o pos = [pos[0]+stepsize, pos[1]]

%o paths.append(str(0))

%o else:

%o pos = [pos[0], pos[1]+stepsize]

%o paths.append(str(1))

%o l.append(int(converts(paths)))

%o print(l)

%Y Subsequence of A035928 in binary.

%K nonn

%O 1,1

%A _Ben Paul Thurston_, May 06 2018