TOPICS
Search

Thue-Morse Sequence


The Thue-Morse sequence, also called the Morse-Thue sequence or Prouhet-Thue-Morse sequence (Allouche and Cosnard 2000), is one of a number of related sequences of numbers obtained from the parities of the counts of 1's in the binary representation of the nonnegative integers.

The version obtained by directly taking the parities is

 t_n=s_2(n) (mod 2),
(1)

where s_2(n) is the binary digit sum. For n=0, 1, 2, ..., the first few terms are then given by 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, ... (OEIS A010060; Allouche and Shallit 2003, pp. 15 and 153). An alternate form of the sequence obtained by taking the ones' complement is given by 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, ... (OEIS A010059; Wolfram 2002, p. 890).

Interpreting the Thue-Morse sequence as concatenated binary digits gives the Thue-Morse constant.

Thue-Morse sequence recurrence plot

A recurrence plot of the Thue-Morse sequence is illustrated above.

There is an amazing set of products involving the Thue-Morse sequence {t_n} given by

product_(n=0)^(infty)((2n+1)/(2n+2))^((-1)^(t_n))=(sqrt(2))/2
(2)
product_(n=0)^(infty)((2n+1)/(2n+2))^(2t_n)((2n+3)/(2n+2))=(2sqrt(2))/pi
(3)
product_(n=0)^(infty)((2n+1)/(2n+2))^(2(1-t_n))((2n+3)/(2n+2))=(sqrt(2))/pi
(4)

(Allouche and Shallit 2003, pp. 153 and 204, factor-of-two typos corrected), the first of which is due to Woods (1978) and Robbins (1979) and is the special case b=2 of the digit sum identity due to Sondow (2006).

Further infinite product evaluations are given by Tóth (2020). For a complex number s with Re(s)>1, a Dirichlet series identity is

 sum_(n=1)^infty((2^s+1)t_(n-1)+(2^s-1)t_n)/(n^s)=2^szeta(s),
(5)

where zeta(s) is the Riemann zeta function (Tóth 2022, p. 4).

Amazingly, the Thue-Morse sequence can be generated from the substitution system

0->01
(6)
1->10
(7)

to obtain

 0->01->0110->01101001->...
(8)

when starting with 0, and

 1->10->1001->10010110->...
(9)

starting with 1. Interpreting these two sequences as binary numbers and writing their values in decimal notation gives the sequences 0, 1, 6, 105, 27030, 1771476585, ... (OEIS A048707) and 1, 2, 9, 150, 38505, 2523490710, ..., respectively. For integer generation n>=1, with the initial single symbol designated generation 0, each word has 2^(n-1) 0s and 2^(n-1) 1s.

For a nonnegative integer k, Wolfram (2002) provides various pieces of Wolfram Language code that produce the first 2^k terms of the complemented Thue-Morse sequence 1, 0, 0, 1, 0, 1, 1, 0, ... computed as:

1. A substitution system,

2. The position of the evil numbers, which have an even number of 1's in their binary expansion (OEIS A001969),

3. A generating function, following 0->1, 1->-1,

4. A cellular automaton (Wolfram 2002, p. 1186),

5. An algebraic generating function,

6. A closed-form expression in terms of a hypergeometric function.

  (* 1 *)
  Nest[Join[#, 1 - #]&, {1}, k]
  (* 2 *)
  Table[1 - Mod[DigitCount[n - 1, 2, 1], 2],
    {n, 2^k}]
  (* 3 *)
  (CoefficientList[Product[1 - z^(2^s),
    {s, 0, k - 1}], z] + 1)/2
  (* 4 *)
  Flatten[CellularAutomaton[{69540422, 2, 2},
    {{1}, 0}, 2^k - 1, {All, 0}]]
  (* 5 *)
  Mod[CoefficientList[Series[(1 + Sqrt[(1 - 3 x)/
    (1 + x)])/(2 (1 + x)), {x, 0, 2^k - 1}], x], 2]
  (* 6 *)
  Mod[Table[(-1)^n/2 + (-3)^n Sqrt[Pi] *
    Hypergeometric2F1Regularized[3/2, - n, 3/2 - n, - 1/3]/
      (4 n!), {n, 0, 2^k - 1}], 2]

Writing the sequence as a power series over the finite field GF(2),

 F(x)=0+1x+1x^2+0x^3+1x^4+...,
(10)

then F satisfies the quadratic equation

 (1+x)F^2+F=x/(1+x^2) (mod 2).
(11)

This equation has two solutions, F and F^', where F^' is the ones' complement of F, i.e.,

 F+F^'=1+x+x^2+x^3+...=1/(1+x),
(12)

which is consistent with the formula for the sum of the roots of a quadratic equation. The quadratic identity for F can be demonstrated as follows. Let (abcdef...) be a shorthand for the power series

 a+bx+cx^2+dx^3+...,
(13)

so F(x) is (0110100110010110...). To get F^2, simply use the rule for squaring power series over the finite field GF(2)

 (A+B)^2=A^2+B^2  (mod 2),
(14)

which extends to the simple rule for squaring a power series

 (a_0+a_1x+a_2x^2+...)^2=a_0+a_1x^2+a_2x^4+... (mod 2),
(15)

i.e., space the series out by a factor of 2, (0 1 1 0 1 0 0 1 ...), and insert zeros at the odd powers of x to get

 F^2=(0010100010000010...).
(16)

Then multiply by x (which just adds a zero at the front) to get

 xF^2=(00010100010000010...).
(17)

Adding to F^2 gives

 (1+x)F^2=(0011110011000011...).
(18)

This is the first term of the quadratic equation, which is the Thue-Morse sequence with each term doubled up. The next term is F, so we have

(1+x)F^2=(0011110011000011...)
(19)
F=(0110100110010110...).
(20)

The sum is the above two sequences XORed together (there are no carries because we're working over the finite field GF(2)), giving

 (1+x)F^2+F=(0101010101010101...).
(21)

We therefore have

 (1+x)F^2+F=x/(1+x^2)=x+x^3+x^5+x^7+x^9+x^(11)+...  (mod 2).
(22)

The Thue-Morse words are overlapfree (Allouche and Shallit 2003, p. 15), and therefore also cubefree on two symbols (Morse and Hedlund 1944). The sequence therefore contains no substrings of the form WWW, where W is any nonempty word. For example, it does not contain the words 000, 010101, or 010010010. In fact, the following stronger statement is true: the Thue-Morse sequence does not contain any substrings of the form WWa, where W is a nonempty word and a is its first symbol. We can obtain a squarefree sequence on three symbols by doing the following: take the Thue-Morse sequence 0110100110010110... and look at the sequence of words of length 2 that appear at consecutive positions starting with zero-based index 2: 10 01 10 00 01 11 10 .... Replace 01 by 0, 10 by 1, 00 by 2 and 11 by 2 to get the following: 1012021.... Then this sequence is squarefree (Morse and Hedlund 1944).

The Thue-Morse sequence has important connections with the Gray code. Kindermann generates fractal music using the self-similarity of the Thue-Morse sequence.

For a positive integer difference d, let A(d) be the greatest length of an arithmetic progression of indices on which all terms t_j are equal, and let i(d) be the least starting index of an arithmetic progression attaining that length. These are called monochromatic arithmetic progressions. An OpenAI Codex project reported the following first-occurrence formulas for integers n in the indicated ranges, resolving Conjecture 3.8 of Joshi and Rust (2025).

drangeA(d)i(d)
2^n+1n>=22^n+23·2^(2n)-2^n-1
2^(2n)-1n>=12^(2n)+43·2^(4n)-2^(2n)+1
2^(2n+1)-1n>=02^(2n+1)2^(2n+1)-1

The maximal lengths A(d) were known previously. The reported proofs establish global maximality and exclude every earlier starting index. The first family excludes n=1, for which i(3)=45. As of Oct. 5, 2026, the repository recorded successful Lean builds and an axiom audit, but VibeMathed had not independently rebuilt the package. Independent specialist review of the informal-to-formal correspondence and the complete argument had not been reported (dot 2026, VibeMathed 2026).

Kutsukake et al. (2020) proved that for the prefix word w_n of length 2^n, where n is a nonnegative integer, a smallest string attractor has four positions for n>=4. Faro et al. (2026, pp. 17 and 26) classified these smallest string attractors and found 87 when n=4, 40 when n=5, and 32 for every n>=6.


See also

Arithmetic Progression, Digit Count, Evil Number, Gray Code, Mephisto Waltz Sequence, Parity, Rabbit Sequence, Thue-Morse Constant, Thue Sequence, Word Morphism

Explore with Wolfram|Alpha

References

Allouche, J.-P. and Cosnard, M. "The Komornik-Loreti Constant Is Transcendental." Amer. Math. Monthly 107, 448-449, 2000.Allouche, J.-P. and Shallit, J. "The Ubiquitous Prouhet-Thue-Morse Sequence." In Sequences and Their Applications, Proc. SETA'98 (Ed. C. Ding, T. Helleseth, and H. Niederreiter). New York: Springer-Verlag, pp. 1-16, 1999. https://doi.org/10.1007/978-1-4471-0551-0_1.Allouche, J.-P. and Shallit, J. "Example 5.1.2 (The Thue-Morse Sequence)." Automatic Sequences: Theory, Applications, Generalizations. Cambridge, England: Cambridge University Press, pp. 152-153, 2003.dot (OpenAI). "Lean Proofs of the Three Thue-Morse First-Occurrence Formulas." 2026. https://github.com/Sodelin/Research-Commons/blob/3bb3cdc9992dd14369bc5b1299ca18fdfd9e93ed/research/2026-10-04-dot-thue-morse-first-occurrence-lean-0550z/package/README.md.Faro, S.; Marino, F. P.; and Pavone, A. "Smallest String Attractors and Minimal Coverage Certificates of Thue-Morse Words." 7 Oct 2026. https://arxiv.org/abs/2610.10950.Goldstein, S.; Kelly, K. A.; and Speer, E. R. "The Fractal Structure of Rarefied Sums of the Thue-Morse Sequence." J. Number Th. 42, 1-19, 1992.Joshi, G. and Rust, D. "Monochromatic Arithmetic Progressions in the Fibonacci, Thue-Morse, and Rudin-Shapiro Words." Theoret. Comput. Sci. 1050, Article 115391, 2025. https://doi.org/10.1016/j.tcs.2025.115391.Kindermann, L. "MusiNum--The Music in the Numbers." https://reglos.de/musinum/.Kutsukake, K.; Matsumoto, T.; Nakashima, Y.; Inenaga, S.; Bannai, H.; and Takeda, M. "On Repetitiveness Measures of Thue-Morse Words." In Proc. 27th International Symposium on String Processing and Information Retrieval (SPIRE 2020) (Ed. C. Boucher and S. V. Thankachan). Cham, Switzerland: Springer, pp. 213-220, 2020. https://doi.org/10.1007/978-3-030-59212-7_15. https://arxiv.org/abs/2005.09524v3.Lothaire, M. (Ed.). Combinatorics on Words. Cambridge, England: Cambridge University Press, 1997.Morse, M. "Recurrent Geodesics on a Surface of Negative Curvature." Trans. Amer. Math. Soc. 22, 84-100, 1921.Morse, M. and Hedlund, G. A. "Unending Chess, Symbolic Dynamics, and a Problem in Semigroups." Duke Math. J. 11, 1-7, 1944.Pickover, C. A. "The Pipes of Papua." Ch. 17 in Wonders of Numbers: Adventures in Mathematics, Mind, and Meaning. Oxford, England: Oxford University Press, pp. 34-38, 2001.Prouhet, E. "Mémoir sur quelques relations entre les puissances des nombres." C. R. Acad. Sci. Paris 33, 225, 1851.Robbins, D. "Solution to Problem E2692." Amer. Math. Monthly 86, 394-395, 1979.Schroeder, M. R. Fractals, Chaos, and Power Laws: Minutes from an Infinite Paradise. New York: W. H. Freeman, 1991.Sloane, N. J. A. Sequences A001969, A010059, A010060, and A048707 in "The On-Line Encyclopedia of Integer Sequences."Sondow, J. "Problem 11222." Amer. Math. Monthly 113, 459, 2006.Thue, A. "Über unendliche Zeichenreihen." Norske vid. Selsk. Skr. Mat. Nat. Kl. 7, 1-22, 1906. Reprinted in Selected Mathematical Papers of Axel Thue (Ed. T. Nagell). Oslo, Norway: Universitetsforlaget, pp. 139-158, 1977.Thue, A. "Über die gegenseitige Lage gleicher Teile gewisser Zeichenreihen." Norske vid. Selsk. Skr. Mat. Nat. Kl. 1, 1-67, 1912. Reprinted in Selected Mathematical Papers of Axel Thue (Ed. T. Nagell). Oslo, Norway: Universitetsforlaget, pp. 413-478, 1977.Tóth, L. "Transcendental Infinite Products Associated with the +/-1 Thue-Morse Sequence." J. Integer Seq. 23, Article 20.8.2, 2020. https://cs.uwaterloo.ca/journals/JIS/VOL23/Toth/toth46.pdf.Tóth, L. "Linear Combinations of Dirichlet Series Associated with the Thue-Morse Sequence." Integers 22, A98, 2022. https://math.colgate.edu/~integers/w98/w98.pdf.VibeMathed. "Thue-Morse: All Three Joshi-Rust First-Occurrence Formulas." Oct. 4, 2026. https://vibemathed.com/problem/thue-morse-all-three-joshi-rust-first-occurrence-formulas.Wolfram, S. A New Kind of Science. Champaign, IL: Wolfram Media, pp. 890 and 1092, 2002.Woods, D. R. "Problem Proposal E2692." Amer. Math. Monthly 85, 48, 1978.

Referenced on Wolfram|Alpha

Thue-Morse Sequence

Cite this as:

Weisstein, Eric W. "Thue-Morse Sequence." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Thue-MorseSequence.html

Subject classifications