In mathematics, the **Thue–Morse** or **Prouhet–Thue–Morse sequence** is the binary sequence (an infinite sequence of 0s and 1s) that can be obtained by starting with 0 and successively appending the Boolean complement of the sequence obtained thus far.^{ [1] } It is sometimes called the **fair share sequence** because of its applications to fair division or **parity sequence**. The first few steps of this procedure yield the strings 0, 01, 0110, 01101001, 0110100110010110, and so on, which are the prefixes of the Thue–Morse sequence. The full sequence begins:

- Definition
- Direct definition
- Fast sequence generation
- Recurrence relation
- L-system
- Characterization using bitwise negation
- Infinite product
- Properties
- In combinatorial game theory
- The Prouhet–Tarry–Escott problem
- Fractals and turtle graphics
- Equitable sequencing
- Hash collisions
- Riemann zeta function
- History
- See also
- Notes
- References
- Further reading
- External links

- 01101001100101101001011001101001....
^{ [1] }

The sequence is named after Axel Thue and Marston Morse.

There are several equivalent ways of defining the Thue–Morse sequence.

To compute the *n*th element *t _{n}*, write the 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 highest-order bit in the binary representation of *n* that is different from the same bit in the representation of *n* − 1. If this bit is at an even index, *t _{n}* differs from

In Python:

`defgenerate_sequence(seq_length:int):"""Thue–Morse sequence."""value=1forninrange(seq_length):# Note: assumes that (-1).bit_length() gives 1x=(n^(n-1)).bit_length()+1ifx&1==0:# Bit index is even, so toggle valuevalue=1-valueyieldvalue`

The resulting algorithm takes constant time to generate each sequence element, using only a logarithmic number of bits (constant number of words) of memory.^{ [3] }

The Thue–Morse sequence is the sequence *t _{n}* satisfying the recurrence relation

for all non-negative integers *n*.^{ [2] }

The Thue–Morse sequence is a morphic word:^{ [4] } it is the output of the following Lindenmayer system:

Variables | 0, 1 |
---|---|

Constants | None |

Start | 0 |

Rules | (0 → 01), (1 → 10) |

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.

In Python:

`defthue_morse_bits(n):"""Return an int containing the first 2**n bits of the Thue-Morse sequence, low-order bit 1st."""bits=0foriinrange(n):bits|=((1<<(1<<i))-1-bits)<<(1<<i)returnbits`

Which can then be converted to a (reversed) string as follows:

`n=7print(f"{thue_morse_bits(n):0{1<<n}b}")`

The sequence can also be defined by:

where *t*_{j} is the *j*th element if we start at *j* = 0.

The Thue–Morse sequence contains many *squares*: instances of the string , where denotes the string , , , or , where for some and is the bitwise negation of .^{ [5] } For instance, if , then . The square appears in starting at the 16th bit. Since all squares in are obtained by repeating one of these 4 strings, they all have length or for some . contains no *cubes*: instances of . There are also no *overlapping squares*: instances of or .^{ [6] }^{ [7] } The critical exponent of is 2.^{ [8] }

The Thue–Morse sequence is a uniformly recurrent word: given any finite string *X* in the sequence, there is some length *n _{X}* (often much longer than the length of

The sequence *T*_{2n} is a palindrome for any *n*. Furthermore, let *q*_{n} be a word obtained by counting the ones between consecutive zeros in *T*_{2n} . For instance, *q*_{1} = 2 and *q*_{2} = 2102012. Since *T _{n}* does not contain

The **Thue–Morse morphism ***μ* is defined on alphabet {0,1} by the substitution map *μ*(0) = 01, *μ*(1) = 10: every 0 in a sequence is replaced with 01 and every 1 with 10.^{ [12] } If *T* is the Thue–Morse sequence, then *μ*(*T*) is also *T*. Thus, *T* is a fixed point of *μ*. The morphism *μ* is a prolongable morphism on the free monoid {0,1}^{∗} with *T* as fixed point: *T* is essentially the *only* fixed point of *μ*; 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 rational functions, satisfying the equation^{ [13] }

The set of *evil numbers* (numbers with ) forms a subspace of the nonnegative integers under nim-addition (bitwise exclusive or). For the game of Kayles, evil nim-values occur for few (finitely many) positions in the game, with all remaining positions having odious nim-values.

The Prouhet–Tarry–Escott problem can be defined as: given a positive integer *N* and a non-negative integer *k*, partition the set *S* = { 0, 1, ..., *N*-1 } 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*= 0,_{n}*S*_{1}consists of the integers*n*in*S*for which*t*= 1._{n}

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".^{ [14] }

Using turtle graphics, a curve can be generated if an automaton is programmed with a sequence. When 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 by an angle of π/3 radians (60°)

The resulting curve converges to the Koch curve, a fractal curve of infinite length containing a finite area. This illustrates the fractal nature of the Thue–Morse Sequence.^{ [15] }

It is also possible to draw the curve precisely using the following instructions:^{ [16] }

- If
*t*(*n*) = 0, rotate by an angle of π radians (180°), - If
*t*(*n*) = 1, move ahead by one unit, then rotate by an angle of π/3 radians.

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 jointly-owned 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.^{ [17] }

Lionel Levine and Katherine E. 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 Thue–Morse order tends to produce a fair outcome.”^{ [18] }

Robert Richman addressed this problem, but he too did not identify the Thue–Morse sequence as such at the time of publication.^{ [19] } 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

Joshua Cooper and Aaron Dutle showed why the Thue–Morse order provides a fair outcome for discrete events.^{ [21] } 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 Thue–Morse order produces a fair outcome not only for sequences *T _{n}* of 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^{ [19] } or discretely.^{ [21] }

Sports competitions form an important class of equitable sequencing problems, because strict alternation often gives an unfair advantage to one team. Ignacio Palacios-Huerta proposed changing the sequential order to Thue–Morse to improve the * ex post * fairness of various tournament competitions, such as the kicking sequence of a penalty shoot-out in soccer.^{ [22] } He did a set of field experiments with pro players and found that the team kicking first won 60% of games using ABAB (or *T*_{1}), 54% using ABBA (or *T*_{2}), and 51% using full Thue–Morse (or *T*_{n}). As a result, ABBA is undergoing extensive trials in FIFA (European and World Championships) and English Federation professional soccer (EFL Cup).^{ [23] } An ABBA serving pattern has also been found to improve the fairness of tennis tie-breaks.^{ [24] } In competitive rowing, *T*_{2} is the only arrangement of port- and starboard-rowing crew members that eliminates transverse forces (and hence sideways wiggle) on a four-membered coxless racing boat, while *T*_{3} is one of only four rigs to avoid wiggle on an eight-membered boat.^{ [25] }

Fairness is especially important in player drafts. Many professional sports leagues attempt to achieve competitive parity by giving earlier selections in each round to weaker teams. By contrast, fantasy football leagues have no pre-existing imbalance to correct, so they often use a “snake” draft (forward, backward, etc.; or *T*_{1}).^{ [26] } Ian Allan argued that a “third-round reversal” (forward, backward, backward, forward, etc.; or *T*_{2}) would be even more fair.^{ [27] } Richman suggested that the fairest way for “captain A” and “captain B” to choose sides for a pick-up 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.^{ [19] }

The initial 2^{k} bits of the Thue–Morse sequence are mapped to 0 by a wide class of polynomial hash functions modulo a power of two, which can lead to hash collisions.^{ [28] }

Certain linear combinations of Dirichlet series whose coefficients are terms of the Thue–Morse sequence give rise to identities involving the Riemann Zeta function (Tóth, 2022 ^{ [29] }). For instance:

where is the term of the Thue-Morse sequence. In fact, for all with real part greater than , we have

The Thue–Morse sequence was first studied by Eugène Prouhet in 1851,^{ [30] } 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 and mathematics teacher, discovered it in 1929 in an application to chess: by using its cube-free property (see above), he showed how to circumvent the threefold repetition rule aimed at preventing infinitely protracted games by declaring repetition of moves a draw. At the time, consecutive identical board states were required to trigger the rule; the rule was later amended to the same board position reoccurring three times at any point, as the sequence shows that the consecutive criterion can be evaded forever.

- 1 2 Sloane, N. J. A. (ed.). "SequenceA010060(Thue-Morse sequence)".
*The On-Line Encyclopedia of Integer Sequences*. OEIS Foundation. - 1 2 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 et al. (2016).
- ↑ Ma & Holdener (2005).
- ↑ Abel, Zachary (January 23, 2012). "Thue-Morse Navigating Turtles".
*Three-Cornered Things*. - ↑ Brams & Taylor (1999).
- ↑ Levine & Stange (2012).
- 1 2 3 Richman (2001)
- ↑ Abrahams (2010).
- 1 2 Cooper & Dutle (2013)
- ↑ Palacios-Huerta (2012).
- ↑ Palacios-Huerta (2014).
- ↑ Cohen-Zada, Krumer & Shapir (2018).
- ↑ Barrow (2010).
- ↑ "Fantasy Draft Types".
*NFL.com*. Archived from the original on October 12, 2018. - ↑ Allan, Ian (July 16, 2014). "Third-Round Reversal Drafts".
*Fantasy Index*. Retrieved September 1, 2020. - ↑ Pachocki, Jakub; Radoszewski, Jakub (2013). "Where to Use and How not to Use Polynomial String Hashing" (PDF).
*Olympiads in Informatics*.**7**: 90–100. - ↑ Tóth, László (2022). "Linear Combinations of Dirichlet Series Associated with the Thue-Morse Sequence".
*Integers*.**22**(article 98). arXiv: 2211.13570 . - ↑ The ubiquitous Prouhet-Thue-Morse sequence by Jean-Paul Allouche and Jeffrey Shallit
- ↑ Fredricksen, Harold (1992). "Gray codes and the Thue-Morse-Hedlund sequence".
*Journal of Combinatorial Mathematics and Combinatorial Computing (JCMCC)*.**11**. Naval Postgraduate School, Department of Mathematics, Monterey, California, USA: 3–11. - ↑ Erickson, John (2018-10-30). "On the Asymptotic Relative Change for Sequences of Permutations" . Retrieved 2021-01-31.

- 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" (PDF).
*Matters Computational: Ideas, Algorithms, Source Code*. Springer. p. 44. - Allouche, Jean-Paul; Shallit, Jeffrey (2003).
*Automatic Sequences: Theory, Applications, Generalizations*. Cambridge University Press. ISBN 978-0-521-82332-6. Zbl 1086.11015. - Barrow, John D. (2010). "Rowing and the Same-Sum Problem Have Their Moments".
*American Journal of Physics*.**78**(7): 728–732. arXiv: 0911.3551 . Bibcode:2010AmJPh..78..728B. doi:10.1119/1.3318808. S2CID 119207447. - Berstel, Jean; Lauve, Aaron; Reutenauer, Christophe; Saliola, Franco V. (2009).
*Combinatorics on words. Christoffel words and repetitions in words*. CRM Monograph Series. Vol. 27. Providence, RI, USA: American Mathematical Society. ISBN 978-0-8218-4480-9. Zbl 1161.68043. - Berthé, Valérie; Rigo, Michel, eds. (2010).
*Combinatorics, automata, and number theory*. Encyclopedia of Mathematics and its Applications. Vol. 135. Cambridge: Cambridge University Press. p. 7. ISBN 978-0-521-51597-9. Zbl 1197.68006. - 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. arXiv: 1304.6756 . doi:10.4310/JOC.2016.v7.n1.a5. S2CID 118040795.} - Brams, Steven J.; Taylor, Alan D. (1999).
*The Win-Win Solution: Guaranteeing Fair Shares to Everybody*. W. W. Norton & Co., Inc. pp. 36–44. ISBN 978-0-393-04729-5. - Brlek, Srećko (1989). "Enumeration of Factors in the Thue-Morse Word".
*Discrete Applied Mathematics*.**24**(1–3): 83–96. doi:10.1016/0166-218x(92)90274-e. - Cohen-Zada, Danny; Krumer, Alex; Shapir, Offer Moshe (2018). "Testing the effect of serve order in tennis tiebreak".
*Journal of Economic Behavior and Organization*.**146**: 106–115. doi:10.1016/j.jebo.2017.12.012. S2CID 89610106. - Cooper, Joshua; Dutle, Aaron (2013). "Greedy Galois Games" (PDF).
*American Mathematical Monthly*.**120**(5): 441–451. arXiv: 1110.1137 . doi:10.4169/amer.math.monthly.120.05.441. S2CID 1291901. - Krieger, Dalia (2006). "On critical exponents in fixed points of non-erasing morphisms". In Ibarra, Oscar H.; Dang, Zhe (eds.).
*Developments in Language Theory: Proceedings 10th International Conference, DLT 2006, Santa Barbara, California, USA, June 26-29, 2006*. Lecture Notes in Computer Science. Vol. 4036. Springer-Verlag. pp. 280–291. ISBN 978-3-540-35428-4. 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. arXiv: 1104.0961 . doi:10.4169/amer.math.monthly.119.07.550. S2CID 14537479. - Lothaire, M. (2011).
*Algebraic combinatorics on words*. Encyclopedia of Mathematics and Its Applications. Vol. 90. With preface by Jean Berstel and Dominique Perrin (Reprint of the 2002 hardback ed.). Cambridge University Press. ISBN 978-0-521-18071-9. Zbl 1221.68183. - Ma, Jun; Holdener, Judy (2005). "When Thue-Morse meets Koch" (PDF).
*Fractals*.**13**(3): 191–206. doi:10.1142/S0218348X05002908. MR 2166279. - Palacios-Huerta, Ignacio (2012). "Tournaments, fairness and the Prouhet–Thue–Morse sequence" (PDF).
*Economic Inquiry*.**50**(3): 848–849. doi:10.1111/j.1465-7295.2011.00435.x. S2CID 54036493. - Palacios-Huerta, Ignacio (2014).
*Beautiful Game Theory*. Princeton University Press. ISBN 978-0691144023. - Pytheas Fogg, N. (2002). Berthé, Valérie; Ferenczi, Sébastien; Mauduit, Christian; Siegel, A. (eds.).
*Substitutions in dynamics, arithmetics and combinatorics*. Lecture Notes in Mathematics. Vol. 1794. Berlin, Germany: Springer-Verlag. ISBN 978-3-540-44141-0. Zbl 1014.11015. - Richman, Robert (2001). "Recursive Binary Sequences of Differences" (PDF).
*Complex Systems*.**13**(4): 381–392.

- Bugeaud, Yann (2012).
*Distribution modulo one and Diophantine approximation*. Cambridge Tracts in Mathematics. Vol. 193. Cambridge: Cambridge University Press. ISBN 978-0-521-11169-0. Zbl 1260.11001. - Lothaire, M. (2005).
*Applied combinatorics on words*. Encyclopedia of Mathematics and Its Applications. Vol. 105. A collective work by Jean Berstel, Dominique Perrin, Maxime Crochemore, Eric Laporte, Mehryar Mohri, Nadia Pisanti, Marie-France Sagot, Gesine Reinert, Sophie Schbath, Michael Waterman, Philippe Jacquet, Wojciech Szpankowski, Dominique Poulalhon, Gilles Schaeffer, Roman Kolpakov, Gregory Koucherov, Jean-Paul Allouche and Valérie Berthé. Cambridge: Cambridge University Press. ISBN 978-0-521-84802-2. Zbl 1133.68067.

Wikimedia Commons has media related to Thue-Morse sequence .

- "Thue-Morse sequence",
*Encyclopedia of Mathematics*, EMS Press, 2001 [1994] - Weisstein, Eric W. "Thue-Morse Sequence".
*MathWorld*. - Allouche, J.-P.; Shallit, J. O. The Ubiquitous Prouhet-Thue-Morse Sequence. (contains many applications and some history)
- Thue–Morse Sequence over (1,2) (sequence A001285 in the OEIS )
- OEIS sequenceA000069(Odious numbers: numbers with an odd number of 1's in their binary expansion)
- OEIS sequenceA001969(Evil numbers: numbers with an even number of 1's in their binary expansion)
- Reducing the influence of DC offset drift in analog IPs using the Thue-Morse Sequence. A technical application of the Thue–Morse Sequence
- MusiNum - The Music in the Numbers. Freeware to generate self-similar music based on the Thue–Morse Sequence and related number sequences.
- Parker, Matt. "The Fairest Sharing Sequence Ever" (video). standupmaths. Retrieved 20 January 2016.

This page is based on this Wikipedia article

Text is available under the CC BY-SA 4.0 license; additional terms may apply.

Images, videos and audio are available under their respective licenses.

Text is available under the CC BY-SA 4.0 license; additional terms may apply.

Images, videos and audio are available under their respective licenses.