Baum-Sweet Sequence Generator
Generate terms of the Baum-Sweet binary sequence with configurable count and output separator.
Baum-Sweet Sequence Generator
The Baum-Sweet sequence is a fundamental binary sequence introduced by Leonard Baum and Melvin Sweet in 1976. It encodes a simple parity rule on the binary representation of each non-negative integer: a term is 1 if every maximal block of consecutive 0-bits in the binary expansion of the index has even length, and 0 otherwise. This tool generates any desired number of Baum-Sweet terms, optionally displaying index labels and choosing your preferred output separator.
Definition and Rule
For a non-negative integer n, write n in binary. Inspect every maximal run of consecutive zero bits. Define:
- b(n) = 1 if every maximal run of 0-bits has even length (including zero length, i.e., no zeros).
- b(n) = 0 if any maximal run of 0-bits has odd length.
Special case: b(0) = 1 (zero has no 0-bit runs in the conventional sense). The first 16 values are: 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1.
Worked Examples
- n = 1 = "1"₂ → no 0-runs → b(1) = 1
- n = 2 = "10"₂ → one 0-run of length 1 (odd) → b(2) = 0
- n = 3 = "11"₂ → no 0-runs → b(3) = 1
- n = 4 = "100"₂ → one 0-run of length 2 (even) → b(4) = 1
- n = 5 = "101"₂ → one 0-run of length 1 (odd) → b(5) = 0
Mathematical Properties
- Sparsity: The density of 1s in the Baum-Sweet sequence tends to 0 as $n \to \infty$. Most large integers have at least one odd-length run of zeros in their binary expansion.
- 2-Automaticity: The Baum-Sweet sequence is 2-automatic — it can be generated by a finite-state automaton reading the binary digits of $n$.
- Algebraic curves: The generating function $\sum_{n \geq 0} b(n) x^n$ over $\mathbb{F}_2$ is algebraic of degree 2. Baum and Sweet studied this sequence in the context of algebraic function fields over finite fields.
- Self-similarity: The sequence satisfies $b(2n) = b(n)$ and $b(4n+1) = b(4n+3) = b(n)$, $b(4n+2k) = ?$ depending on the run-length parity.
How to Use This Tool
- Enter the number of terms to generate (up to 10,000).
- Set a start index to generate a contiguous subsequence starting at any position.
- Choose a separator for the output (comma, newline, space, etc.).
- Enable index labels if you want to see which index each term corresponds to.
- The sequence updates automatically as you change parameters.
Historical Context
Leonard Baum and Melvin Sweet introduced this sequence in their 1976 paper "Badly approximable power series in characteristic 2". They were studying continued fraction expansions of formal power series over the field $\mathbb{F}_2$. The sequence appears as the coefficient sequence of an algebraic function over $\mathbb{F}_2((x))$ that lacks periodic continued fraction expansions.
Frequently Asked Questions
What is the Baum-Sweet sequence?
The Baum-Sweet sequence $b(n)$ is a binary sequence where $b(n) = 1$ if the binary representation of $n$ has no odd-length block of consecutive zeros, and $b(n) = 0$ otherwise. It starts: 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, ...
How do you determine if b(n) = 1 or b(n) = 0?
Write $n$ in binary. Find every maximal run of consecutive 0-bits. If every such run has even length (0, 2, 4, 6, ...), then $b(n) = 1$. If any run has odd length (1, 3, 5, ...), then $b(n) = 0$. Note that a run of length 0 means no zeros, which trivially satisfies the even condition.
Why does the density of 1s tend to 0?
As numbers grow larger, they tend to have longer binary representations with various run lengths. The probability that all zero-runs happen to have even lengths decreases as the number of runs increases. More precisely, one can show that the count of 1s up to $N$ grows as $O(N^{c})$ for some $c < 1$, so the density $\to 0$.
Is the Baum-Sweet sequence 2-automatic?
Yes. A sequence is called $k$-automatic if it can be computed by a finite automaton that reads the base-$k$ digits of the index $n$. The Baum-Sweet sequence is 2-automatic because a simple 3-state automaton reading the bits of $n$ from left to right can determine whether $b(n) = 0$ or $b(n) = 1$.
What was the original motivation for studying this sequence?
Baum and Sweet (1976) were studying formal power series over the two-element field $\mathbb{F}_2$. They showed that the power series $f = \sum b(n) x^n$ over $\mathbb{F}_2((x))$ satisfies a polynomial equation of degree 2, making it algebraic but not rational, and it has a very irregular continued fraction expansion — unlike real algebraic numbers, which have bounded partial quotients.
Related tools
Your recent visits