login
Ternary Thue-Morse sequence: closed under a->abc, b->ac, c->b.
5

%I #46 Apr 15 2024 11:24:15

%S 0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,0,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,2,1,2,

%T 0,1,0,2,1,2,0,2,1,0,1,2,0,1,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,0,1,2,0,1,

%U 0,2,1,2,0,2,1,0,1,2,0,1,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,2,0,2,1

%N Ternary Thue-Morse sequence: closed under a->abc, b->ac, c->b.

%C This sequence and A108694 are squarefree (they do not contain any substring XX). - _Bill Gosper_, Jul 22 2005

%C Trajectory of 1 under the morphism 0 -> 021, 1 -> 2 & 2 -> 01. - _Robert G. Wilson v_, Apr 06 2008

%C I believe that this is the sequence Cummings refers to as the Morse-Hedlund sequence. It can be constructed by starting with the Thue-Morse binary sequence A010060, 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,..., reading successive pairs of digits: 01, 11, 10, 01, 10, 00, 01, 11, 10, 00, 01, ..., and mapping 01 to 0, 10 to 1, and both 00 and 11 to 2, getting 0,2,1,0,1,2,0,2,1,... - _N. J. A. Sloane_, Oct 17 2012

%D L. J. Cummings, On the construction of Thue sequences, Proc. 9th S-E Conf. Combinatorics, Graph Theory and Computing, pp. 235-242. - From _N. J. A. Sloane_, Oct 17 2012

%D M. Lothaire, Combinatorics on Words. Addison-Wesley, Reading, MA, 1983, p. 26.

%H R. J. Mathar, <a href="/A036581/b036581.txt">Table of n, a(n) for n = 0..10000</a>

%H A. Cobham, <a href="http://dx.doi.org/10.1007/BF01706087">Uniform Tag Sequences</a>, Mathematical Systems Theory, 6 (1972), 164-192.

%H Marston Morse and Gustav A. Hedlund, <a href="http://dx.doi.org/10.1215/S0012-7094-44-01101-4">Unending chess, symbolic dynamics and a problem in semigroups</a>, Duke Math. J., Volume 11, Number 1 (1944), 1-7. - From _N. J. A. Sloane_, Oct 17 2012

%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>

%F a(n) = A010060(n+1) - A010060(n) - 1 mod 3. - _Bill Gosper_, Jul 22 2005

%p A036581 := proc(n)

%p A010060(n+1)-A010060(n)-1 ;

%p % mod 3 ;

%p end proc: # _R. J. Mathar_, Oct 17 2012

%t Nest[ # /. {0 -> {0, 2, 1}, 1 -> {2}, 2 -> {0, 1}} &, {0}, 7] // Flatten (* _Robert G. Wilson v_, Apr 06 2008 *)

%t a010060[n_]:=Mod[DigitCount[n, 2, 1], 2]; Table[Mod[a010060[n + 1] - a010060[n] - 1, 3], {n, 0, 100}] (* _Indranil Ghosh_, Apr 25 2017 *)

%t SubstitutionSystem[{0->{0,2,1},1->{2},2->{0,1}},{0},{7}][[1]] (* _Harvey P. Dale_, Dec 26 2021 *)

%o (Haskell)

%o a036581 n = a036581_list !! n

%o a036581_list = zipWith (\u v -> if u /= v then 2 * u + v - 1 else 2)

%o a010060_list $ tail a010060_list

%o -- According to _N. J. A. Sloane_'s comment from Oct 17 2012

%o -- _Reinhard Zumkeller_, Nov 30 2012

%o (Python)

%o def a010060(n): return bin(n)[2:].count("1")%2

%o def a(n): return (a010060(n + 1) - a010060(n) - 1)%3 # _Indranil Ghosh_, Apr 25 2017

%Y Cf. A036583, A108694.

%K nonn,nice

%O 0,2

%A _N. J. A. Sloane_

%E More terms from _Robert G. Wilson v_, Apr 06 2008