Thue–Morse sequence
In mathematics, the Thue–Morse sequence, or Prouhet–Thue–Morse sequence, is the binary sequence (an infinite sequence of 0s and 1s) obtained by starting with 0 and successively appending the Boolean complement of the sequence obtained thus far. The first few steps of this procedure yield the strings 0 then 01, 0110, 01101001, 0110100110010110, and so on, which are prefixes of the Thue–Morse sequence. The full sequence begins:
Definition
There are several equivalent ways of defining the Thue–Morse sequence.
Direct definition
To compute the n^{th} element t_{n}, write the number n in binary. If the number of ones in this binary expansion is odd then t_{n} = 1, if even then t_{n} = 0.^{[1]} For this reason John H. Conway et al. call numbers n satisfying t_{n} = 1 odious (for odd) numbers and numbers for which t_{n} = 0 evil (for even) numbers. In other words, t_{n} = 0 if n is an evil number and t_{n} = 1 if n is an odious number.
This method leads to a fast method for computing the Thue–Morse sequence: start with t_{0} = 0, and then, for each n, find the highestorder bit in the binary representation of n that is different from the same bit in the representation of n − 1. (This bit can be isolated by letting x be the bitwise exclusive or of n and n − 1, shifting x right by one bit, and computing the exclusive or of this shifted value with x.) If this bit is at an even index, t_{n} differs from t_{n − 1}, and otherwise it is the same as t_{n − 1}. The resulting algorithm takes constant time to generate each sequence element, using only a logarithmic number of bits (constant number of words) of memory.^{[2]}
Recurrence relation
The Thue–Morse sequence is the sequence t_{n} satisfying the recurrence relation

t_{0} = 0, t_{2n} = t_{n}, and t_{2n+1} = 1 − t_{n}.
for all nonnegative integers n.^{[1]}
Lsystem
The Thue–Morse sequence is a morphic word:^{[3]} it is the output of the following Lindenmayer system:
Variables  0, 1 

Constants  None 
Start  0 
Rules  (0 → 01), (1 → 10) 
Characterization using bitwise negation
The Thue–Morse sequence in the form given above, as a sequence of bits, can be defined recursively using the operation of bitwise negation. So, the first element is 0. Then once the first 2^{n} elements have been specified, forming a string s, then the next 2^{n} elements must form the bitwise negation of s. Now we have defined the first 2^{n+1} elements, and we recurse.
Spelling out the first few steps in detail:
 We start with 0.
 The bitwise negation of 0 is 1.
 Combining these, the first 2 elements are 01.
 The bitwise negation of 01 is 10.
 Combining these, the first 4 elements are 0110.
 The bitwise negation of 0110 is 1001.
 Combining these, the first 8 elements are 01101001.
 And so on.
So
 T_{0} = 0.
 T_{1} = 01.
 T_{2} = 0110.
 T_{3} = 01101001.
 T_{4} = 0110100110010110.
 T_{5} = 01101001100101101001011001101001.
 T_{6} = 0110100110010110100101100110100110010110011010010110100110010110.
 And so on.
Infinite product
The sequence can also be defined by:
where t_{j} is the j^{th} element if we start at j = 0.
Some properties
Because each new block in the Thue–Morse sequence is defined by forming the bitwise negation of the beginning, and this is repeated at the beginning of the next block, the Thue–Morse sequence is filled with squares: consecutive strings that are repeated. That is, there are many instances of XX, where X is some string. Indeed, is such a string if and only if or where for some and denotes the bitwise negation of (interchange 0s and 1s).^{[4]} For instance, with , we have , and the square appears in starting at the 16th bit. (Thus, squares in have length either a power of 2 or 3 times a power of 2.) However, there are no cubes: instances of XXX. There are also no overlapping squares: instances of 0X0X0 or 1X1X1.^{[5]}^{[6]} The critical exponent is 2.^{[7]}
Notice that T_{2n} is palindrome for any n > 1. Further, let q_{n} be a word obtain from T_{2n} by counting ones between consecutive zeros. For instance, q_{1} = 2 and q_{2} = 2102012 and so on. The words T_{n} do not contain overlapping squares in consequence, the words q_{n} are palindrome squarefree words.
The statement above that the Thue–Morse sequence is "filled with squares" can be made precise: It is a uniformly recurrent word, meaning that given any finite string X in the sequence, there is some length n_{X} (often much longer than the length of X) such that X appears in every block of length n_{X}.^{[8]}^{[9]} The easiest way to make a recurrent sequence is to form a periodic sequence, one where the sequence repeats entirely after a given number m of steps. Then n_{X} can be set to any multiple of m that is larger than twice the length of X. But the Morse sequence is uniformly recurrent without being periodic, not even eventually periodic (meaning periodic after some nonperiodic initial segment).^{[10]}
We define the Thue–Morse morphism to be the function f from the set of binary sequences to itself by replacing every 0 in a sequence with 01 and every 1 with 10.^{[11]} Then if T is the Thue–Morse sequence, then f(T) is T again; that is, T is a fixed point of f. The function f is a prolongable morphism on the free monoid {0,1}^{∗} with T as fixed point: indeed, T is essentially the only fixed point of f; the only other fixed point is the bitwise negation of T, which is simply the Thue–Morse sequence on (1,0) instead of on (0,1). This property may be generalized to the concept of an automatic sequence.
The generating series of T over the binary field is the formal power series
This power series is algebraic over the field of formal power series, satisfying the equation^{[12]}
In combinatorial game theory
The set of evil numbers (numbers with ) forms a subspace of the nonnegative integers under nimaddition (bitwise exclusive or). For the game of Kayles, evil nimvalues occur for few (finitely many) positions in the game, with all remaining positions having odious nimvalues.
The Prouhet–Tarry–Escott problem
The Prouhet–Tarry–Escott problem can be defined as: given a positive integer N and a nonnegative integer k, partition the set S = { 0, 1, ..., N1 } into two disjoint subsets S_{0} and S_{1} that have equal sums of powers up to k, that is:
 for all integers i from 1 to k.
This has a solution if N is a multiple of 2^{k+1}, given by:
 S_{0} consists of the integers n in S for which t_{n} = 0,
 S_{1} consists of the integers n in S for which t_{n} = 1.
For example, for N = 8 and k = 2,
 0 + 3 + 5 + 6 = 1 + 2 + 4 + 7,
 0^{2} + 3^{2} + 5^{2} + 6^{2} = 1^{2} + 2^{2} + 4^{2} + 7^{2}.
The condition requiring that N be a multiple of 2^{k+1} is not strictly necessary: there are some further cases for which a solution exists. However, it guarantees a stronger property: if the condition is satisfied, then the set of k^{th} powers of any set of N numbers in arithmetic progression can be partitioned into two sets with equal sums. This follows directly from the expansion given by the binomial theorem applied to the binomial representing the n^{th} element of an arithmetic progression.
For generalizations of the Thue–Morse sequence and the Prouhet–Tarry–Escott problem to partitions into more than two parts, see Bolker, Offner, Richman and Zara, "The Prouhet –Tarry –Escott problem and generalized Thue –Morse sequences".^{[13]}
Fractals and Turtle graphics
A Turtle Graphics is the curve that is generated if an automaton is programmed with a sequence. If the Thue–Morse Sequence members are used in order to select program states:
 If t(n) = 0, move ahead by one unit,
 If t(n) = 1, rotate counterclockwise by an angle of π/3,
the resulting curve converges to the Koch snowflake, a fractal curve of infinite length containing a finite area. This illustrates the fractal nature of the Thue–Morse Sequence.^{[14]}
Equitable sequencing
In their book on the problem of fair division, Steven Brams and Alan Taylor invoked the Thue–Morse sequence but did not identify it as such. When allocating a contested pile of items between two parties who agree on the items' relative values, Brams and Taylor suggested a method they called balanced alternation, or taking turns taking turns taking turns . . . , as a way to circumvent the favoritism inherent when one party chooses before the other. An example showed how a divorcing couple might reach a fair settlement in the distribution of jointlyowned items. The parties would take turns to be the first chooser at different points in the selection process: Ann chooses one item, then Ben does, then Ben chooses one item, then Ann does.^{[15]}
Lionel Levine and Katherine Stange, in their discussion of how to fairly apportion a shared meal such as an Ethiopian dinner, proposed the Thue–Morse sequence as a way to reduce the advantage of moving first. They suggested that “it would be interesting to quantify the intuition that the ThueMorse order tends to produce a fair outcome.”^{[16]}
Robert Richman addressed this problem, but he too did not identify the Thue–Morse sequence as such at the time of publication.^{[17]} He presented the sequences T_{n} as step functions on the interval [0,1] and described their relationship to the Walsh and Rademacher functions. He showed that the n^{th} derivative can be expressed in terms of T_{n}. As a consequence, the step function arising from T_{n} is orthogonal to polynomials of order n − 1. A consequence of this result is that a resource whose value is expressed as a monotonically decreasing continuous function is most fairly allocated using a sequence that converges to ThueMorse as the function becomes flatter. An example showed how to pour cups of coffee of equal strength from a carafe with a nonlinear concentration gradient, prompting a whimsical article in the popular press.^{[18]}
Joshua Cooper and Aaron Dutle showed why the ThueMorse order provides a fair outcome for discrete events.^{[19]} They considered the fairest way to stage a Galois duel, in which each of the shooters has equally poor shooting skills. Cooper and Dutle postulated that each dueler would demand a chance to fire as soon as the other’s a priori probability of winning exceeded their own. They proved that, as the duelers’ hitting probability approaches zero, the firing sequence converges to the Thue–Morse sequence. In so doing, they demonstrated that the ThueMorse order produces a fair outcome not only for sequences T_{n} of length 2^{n}, but for sequences of any length.
Thus the mathematics supports using the Thue–Morse sequence instead of alternating turns when the goal is fairness but earlier turns differ monotonically from later turns in some meaningful quality, whether that quality varies continuously^{[17]} or discretely.^{[19]}
Sports competitions form an important class of equitable sequencing problems, because strict alternation often gives an unfair advantage to one team. Richman suggested that the fairest way for “captain A” and “captain B” to choose sides for a pickup game of basketball mirrors T_{3}: captain A has the first, fourth, sixth, and seventh choices, while captain B has the second, third, fifth, and eighth choices.^{[17]} Ignacio PalaciosHuerta proposed changing the sequential order to ThueMorse to improve the ex post fairness of various tournament competitions, such as the kicking sequence of a penalty shootout in soccer, the rotation of color of pieces in a chess match, and the serving order in a tennis tiebreak.^{[20]} In competitive rowing, T_{2} is the only arrangement of port and starboardrowing crew members that eliminates transverse forces (and hence sideways wiggle) on a fourmembered coxless racing boat, while T_{3} is one of only four rigs to avoid wiggle on an eightmembered boat.^{[21]}
History
The Thue–Morse sequence was first studied by Eugène Prouhet in 1851, who applied it to number theory. However, Prouhet did not mention the sequence explicitly; this was left to Axel Thue in 1906, who used it to found the study of combinatorics on words. The sequence was only brought to worldwide attention with the work of Marston Morse in 1921, when he applied it to differential geometry. The sequence has been discovered independently many times, not always by professional research mathematicians; for example, Max Euwe, a chess grandmaster, who held the world championship title from 1935 to 1937, and mathematics teacher, discovered it in 1929 in an application to chess: by using its cubefree property (see above), he showed how to circumvent a rule aimed at preventing infinitely protracted games by declaring repetition of moves a draw.
See also
Notes
 ^ ^{a} ^{b} Allouche & Shallit (2003, p. 15)
 ^ Arndt (2011).
 ^ Lothaire (2011, p. 11)
 ^ Brlek (1989).
 ^ Lothaire (2011, p. 113)
 ^ Pytheas Fogg (2002, p. 103)
 ^ Krieger (2006).
 ^ Lothaire (2011, p. 30)
 ^ Berthé & Rigo (2010).
 ^ Lothaire (2011, p. 31)
 ^ Berstel et al. (2009, p. 70)
 ^ Berstel et al. (2009, p. 80)
 ^ Bolker, Ethan; Offner, Carl; Richman, Robert; Zara, Catalin (2016). "The Prouhet –Tarry –Escott problem and generalized Thue –Morse sequences". Journal of Combinatorics. 7 (1): 117–133.
 ^ Ma & Holdener (2005).
 ^ Brams & Taylor (1999).
 ^ Levine & Stange (2012).
 ^ ^{a} ^{b} ^{c} Richman (2001)
 ^ Abrahams (2010).
 ^ ^{a} ^{b} Cooper & Dutle (2013)
 ^ PalaciosHuerta (2012).
 ^ Barrow (2010).
References
 Abrahams, Marc (12 July 2010). "How to pour the perfect cup of coffee". The Guardian.
 Arndt, Jörg (2011). "1.16.4 The Thue–Morse sequence". Matters Computational: Ideas, Algorithms, Source Code (PDF). Springer. p. 44.
 Allouche, JeanPaul; Shallit, Jeffrey (2003). Automatic Sequences: Theory, Applications, Generalizations. Cambridge University Press. ISBN 9780521823326. Zbl 1086.11015.
 Berstel, Jean; Lauve, Aaron; Reutenauer, Christophe; Saliola, Franco V. (2009). Combinatorics on words. Christoffel words and repetitions in words. CRM Monograph Series. 27. Providence, RI: American Mathematical Society. ISBN 9780821844809. Zbl 1161.68043.
 Berthé, Valérie; Rigo, Michel, eds. (2010). Combinatorics, automata, and number theory. Encyclopedia of Mathematics and its Applications. 135. Cambridge: Cambridge University Press. p. 7. ISBN 9780521515979. Zbl 1197.68006.
 Brams, Steven J.; Taylor, Alan D. (1999). The WinWin Solution: Guaranteeing Fair Shares to Everybody. W. W. Norton & Co., Inc. pp. 36–44. ISBN 0393047296.
 Brlek, Srećko (1989). "Enumeration of Factors in the ThueMorse Word". Discrete Applied Mathematics. 24: 83–96. doi:10.1016/0166218x(92)90274e.
 Bugeaud, Yann (2012). Distribution modulo one and Diophantine approximation. Cambridge Tracts in Mathematics. 193. Cambridge: Cambridge University Press. ISBN 9780521111690. Zbl 1260.11001.
 Cooper, Joshua; Dutle, Aaron (2013). "Greedy Galois Games" (PDF). American Mathematical Monthly. 120 (5): 441–451. doi:10.4169/amer.math.monthly.120.05.441.
 Krieger, Dalia (2006). "On critical exponents in fixed points of nonerasing morphisms". In Ibarra, Oscar H.; Dang, Zhe. Developments in Language Theory: Proceedings 10th International Conference, DLT 2006, Santa Barbara, CA, USA, June 2629, 2006. Lecture Notes in Computer Science. 4036. SpringerVerlag. pp. 280–291. ISBN 354035428X. Zbl 1227.68074.
 Levine, Lionel; Stange, Katherine E. (2012). "How to Make the Most of a Shared Meal: Plan the Last Bite First" (PDF). American Mathematical Monthly. 119 (7): 550–565. doi:10.4169/amer.math.monthly.119.07.550.
 Lothaire, M. (2011). Algebraic combinatorics on words. Encyclopedia of Mathematics and Its Applications. 90. With preface by Jean Berstel and Dominique Perrin (Reprint of the 2002 hardback ed.). Cambridge University Press. ISBN 9780521180719. Zbl 1221.68183.
 Lothaire, M. (2005). Applied combinatorics on words. Encyclopedia of Mathematics and Its Applications. 105. A collective work by Jean Berstel, Dominique Perrin, Maxime Crochemore, Eric Laporte, Mehryar Mohri, Nadia Pisanti, MarieFrance Sagot, Gesine Reinert, Sophie Schbath, Michael Waterman, Philippe Jacquet, Wojciech Szpankowski, Dominique Poulalhon, Gilles Schaeffer, Roman Kolpakov, Gregory Koucherov, JeanPaul Allouche and Valérie Berthé. Cambridge: Cambridge University Press. ISBN 0521848024. Zbl 1133.68067.
 Ma, Jun; Holdener, Judy (2005). "When ThueMorse meets Koch" (PDF). Fractals. 13 (3): 191–206. doi:10.1142/S0218348X05002908. MR 2166279.
 PalaciosHuerta, Ignacio (2012). "Tournaments, fairness and the Prouhet–Thue–Morse sequence" (PDF). Economic inquiry. 50 (3): 848–849. doi:10.1111/j.14657295.2011.00435.x.
 Pytheas Fogg, N. (2002). Substitutions in dynamics, arithmetics and combinatorics. Lecture Notes in Mathematics. 1794. Editors Berthé, Valérie; Ferenczi, Sébastien; Mauduit, Christian; Siegel, A. Berlin: SpringerVerlag. ISBN 3540441417. Zbl 1014.11015.
 Richman, Robert (2001). "Recursive Binary Sequences of Differences" (PDF). Complex Systems. 13 (4): 381–392.
 Barrow, John D. (2010). "Rowing and the SameSum Problem Have Their Moments" (PDF). American Journal of Physics. 78 (7): 728–732. doi:10.1119/1.3318808.
External links
Wikimedia Commons has media related to Thue–Morse sequence. 
 Hazewinkel, Michiel, ed. (2001) [1994], "ThueMorse sequence", Encyclopedia of Mathematics, Springer Science+Business Media B.V. / Kluwer Academic Publishers, ISBN 9781556080104
 Weisstein, Eric W. "ThueMorse Sequence". MathWorld.
 Allouche, J.P.; Shallit, J. O. The Ubiquitous ProuhetThueMorse Sequence. (contains many applications and some history)
 Thue–Morse Sequence over (1,2) (sequence A001285 in the OEIS)
 Odious numbers (sequence A000069 in the OEIS)
 Evil numbers (sequence A001969 in the OEIS)
 Reducing the influence of DC offset drift in analog IPs using the ThueMorse Sequence. A technical application of the Thue–Morse Sequence
 MusiNum  The Music in the Numbers. Freeware to generate selfsimilar music based on the Thue–Morse Sequence and related number sequences.
 Parker, Matt. "The Fairest Sharing Sequence Ever" (video). standupmaths. Retrieved 20 January 2016.