INTEGERS 11 (2011) #A26 ANALOGS OF THE STERN SEQUENCE Song Heng Chan Division of Mathematical Sciences, School of Physical and Mathematical Sciences, Nanyang Technological University, Singapore, Republic of Singapore chansh@ntu.edu.sg Received: 6/24/10, Revised: 1/6/11, Accepted: 2/7/11, Published: 4/16/11 Abstract We present two infinite families of sequences that are analogous to the Stern sequence. Sequences in the first family enumerate the set of positive rational numbers, while sequences in the second family enumerate the set of positive rational numbers with either an even numerator or an even denominator. 1. Introduction N. Calkin and H. Wilf presented in [3] an explicit way of enumerating the positive rational numbers, as opposed to the more common non-explicit enumeration by casting out duplicates that is often used in a classroom proof of the countability of the rational numbers. Their result can be stated as the following theorem. Theorem 1. For |x| < 1, let ∞ ! n=0 an xn := ∞ " n n (1 + x2 + x2·2 ). n=0 Then there exists a bijection between % # $ an $ ∈ Q$n ∈ N and Q+ , an+1 where Q+ denotes the set of positive rational numbers. Thus the sequence gives an enumeration of the set of positive rational numbers. & an an+1 ' n∈N As can be seen from the generating function, the sequence {an }n∈N counts the number of ways a natural number n can be expressed as a sum of powers of 2, each power being used at most twice. In [6], B. Reznick showed that the sequence {an }n∈N is related to the classical Stern sequence, {s(n)}n∈N , which was originally 2 INTEGERS 11 (2011) discovered by M. A. Stern [7] and was studied in greater detail by D. H. Lehmer [5]. The Stern sequence may be defined by s(0) = 0, s(1) = 1, and the recurrence relations, for all n ≥ 1, s(2n) = s(n), s(2n + 1) = s(n) + s(n + 1). Reznick [6, Theorem 5.2] showed that the terms in these two sequences satisfy for all n ≥ 0. an = s(n + 1), See [5] and [6] for many interesting properties of the Stern sequence. The Stern sequence is often discussed together with a binary tree of fractions known as the Stern-Brocot tree, discovered independently by Stern [7] and A. Brocot [2]. Some of the recent developments include the following. In [1], B. Bates et. al. gave a simple method of identifying both the level and the position within the level of each fraction in the Stern-Brocot tree. In [4], K. Dilcher and K. B. Stolarsky discovered an interesting polynomial analogue to the Stern sequence. Since Theorem 1 involves binary partitions, a natural question that arises is whether there are generating functions involving partitions into powers of other integers that exhibit similar properties. In Section 2 of this article, we present an analogue to Theorem 1 involving partitions into powers of 3. In Section 3, we present two infinite families of sequences involving partitions into powers of k, k ≥ 4, as further analogues to Theorem 1. One feature of the sequence {an }n∈N discussed in [3], is that each consecutive pair of natural numbers, an and an+1 , is coprime. This feature, however, is absent in all of our new sequences presented in this article. In replacement, we state certain restrictions on the greatest common divisor of each consecutive pair. This work was inspired by the first of a series of three Trjitzinsky Memorial Lectures delivered by Wilf at the University of Illinois in 2003, where he lectured on his joint work [3]. Throughout this article, we shall assume that |x| < 1. 2. An Analogue Involving Ternary Partitions We state and prove in detail, our first example of an analogue to Theorem 1. Theorem 2. Let ∞ ! n=0 bn xn := ∞ " n=0 n n n n (1 + 2x3 + x2·3 + 2x3·3 + x4·3 ). 3 INTEGERS 11 (2011) Then there exists a bijection between % # $ $ ) (m bn $ $ ∈ Q$(m, n) = 1, m · n ≡ 0 (mod 2) . ∈ Q$n ∈ N and bn+1 n & bn ' Thus the sequence bn+1 n∈N gives an enumeration of the set of positive rational numbers with either an even numerator or an even denominator. From the generating function, we see that bn , for n > 0, counts the number of ways of representing a natural number n as a sum of powers of 3, each power being used at most four times, with the added condition that whenever a power of 3 is used an odd number of times, we count it twice. So for example 3 + 30 counts for 2, 3 + 30 + 30 for 4 and 30 + 3 + 32 for 8. Proof. The proof we present here is similar to that given in [3]. First, we draw a tree of positive rational numbers beginning with two top vertices where the fractions 12 and 21 lie, and relating each parent vertex to 3 children vertices using the relation r s r 2r+s 2r+s 2s+r 2s+r s Thus the tree looks like 1 2 1 4 1 6 2 1 4 5 6 9 9 4 4 13 13 14 5 2 14 5 5 12 12 9 2 5 9 2 2 9 5 4 9 12 12 5 5 14 14 13 4 1 13 4 4 9 9 6 6 1 . From this tree, we recover a sequence of positive rational numbers by reading from the top row down, from left to right in each row. So we obtain the sequence 1 2 1 4 5 2 5 4 1 , , , , , , , , ,.... 2 1 4 5 2 5 4 1 6 INTEGERS 11 (2011) 4 It is clear from the way we generated this tree, that the numerator of each fraction, without reducing to lowest terms, is the denominator of the previous fraction without reducing to lowest terms. We shall also denote by f (n) := the numerator of the (n + 1)-th fraction. Thus f (0) = 1, f (1) = 2, etc. The properties of this tree are 1. A number rs appears in the tree if and only if rs appears. This is true at the top level, and is true for the rest of the tree by symmetry. 2. Without reducing to lowest terms, every number rs that appears in the tree has gcd(r, s) = 3m for some m ≥ 0. This is true for numbers in the top level. Suppose this is true for some number rs at some level. Then clearly gcd(r, 2r + s) = gcd(2s + r, s) = gcd(r, s), and so the same is true for its first and third children. For the second child, suppose gcd(2r + s, 2s + r) = 3m p for some p ≥ 1. Then 3m p|(r − s), so we have 3m p|3r and 3m p|3s. Since gcd(r, s) = 3m , we must have either p = 1 or 3. Therefore it is also true for the second child. 3. After reducing to lowest terms, every positive rational number rs with r · s ≡ 0 (mod 2) appears in the tree. Otherwise, let r/s be, among all reduced rational numbers with r · s ≡ 0 (mod 2) that do not appear in the tree, one of the smallest denominator, and among those the one of smallest numerator. Then from property (1) above, clearly r > s. Clearly 1/2 and 2 appear in the tree, and so r %= 2s. If r < 2s, then (2r − s)/(2s − r) doesn’t occur either, else its second child is r/s, it satisfies the condition (2r − s)(2s − r) ≡ 0 (mod 2), and its denominator is smaller than s, a contradiction. If r > 2s, then (r − 2s)/s doesn’t occur either, else its third child is r/s, it satisfies the condition (2r − s)s ≡ 0 (mod 2), and its numerator is smaller while its denominator remains the same, a contradiction. 4. No reduced positive rational number appears at more than one vertex. Otherwise, let r/s be, among all reduced rational numbers with r · s ≡ 0 (mod 2) that appear twice in the tree, one of the smallest denominator, and among those the one of smallest numerator. Then from property (1) above, clearly r > s. Clearly 1/2 and 2 appear exactly once in the tree, since the first child of any vertex is always less than 1/2, the second child is always between 1/2 and 2, and the third child is always greater than 2. Therefore r %= 2s. If r < 2s, then r/s must be a second child of two distinct vertices, at both of which lives rational numbers reducing to (2r − s)/(2s − r), contradicting the minimality of the denominator. Similarly if r > 2s. 5 INTEGERS 11 (2011) From properties (1), (3), and (4), we see immediately that after reducing to lowest terms, this tree generates, without repetition, the set of all positive rational numbers r/s with either r or s even. (Property (2) is not used in the proof.) It remains to show that f (n) = bn . The fraction f (n)/f (n + 1) has children f (3n + 2)/f (3n + 3), f (3n + 3)/f (3n + 4), and f (3n + 4)/f (3n + 5). From this, we deduce that f (n) satisfies the recurrence relations f (3n + 2) = f (n), f (3n + 3) = 2f (n) + f (n + 1), f (3n + 4) = f (n) + 2f (n + 1). Denoting by [xn ]f (x) := the coefficient of xn in f (x), we may express b3n+2 ∞ " = [x3n+2 ] n n n n (1 + 2x3 + x2·3 + 2x3·3 + x4·3 ) n=0 * + ∞ " ' 3n 3n 2·3n 3·3n 4·3n = [x ](1 + 2x + x + 2x + x ) [x ] (1 + 2x + x + 2x +x ) & 2 2 3 4 n=1 = [xn ] ∞ " n n n n (1 + 2x3 + x2·3 + 2x3·3 + x4·3 ) = bn , n=0 b3n+3 = [x3n+3 ] ∞ " n n n n (1 + 2x3 + x2·3 + 2x3·3 + x4·3 ) n=0 * + ∞ " ' 3n 3n 2·3n 3·3n 4·3n [x ] (1 + 2x + x + 2x +x ) = [x ](1 + 2x + x + 2x + x ) & 3 2 3 4 n=1 + [x3n+3 ] ∞ " n n n n (1 + 2x3 + x2·3 + 2x3·3 + x4·3 ) n=1 = 2[xn ] ∞ " n n n n (1 + 2x3 + x2·3 + 2x3·3 + x4·3 ) n=0 + [xn+1 ] ∞ " n n n n (1 + 2x3 + x2·3 + 2x3·3 + x4·3 ) = 2bn + bn+1 . n=0 Similarly, we have b3n+4 = bn + 2bn+1 . Therefore the coefficients bn also satisfy the same set of recurrence relations. Since the initial values b0 = f (0) and b1 = f (1), we conclude that bn = f (n) for all n ∈ N. 6 INTEGERS 11 (2011) bn }n∈N does not enumerate Q+ , by We remark that although the sequence { bn+1 making a small modification to the even number terms, we can obtain a new sequence that enumerates Q+ . Corollary 3. For each n ∈ N, let us define b2n , b2n+1 b2n+1 := . 2b2n+2 β2n := β2n+1 Then the sequence {βn }n∈N gives an enumeration of Q+ . Proof. First, we note that the even terms b0 , b2 , b4 , . . . are all odd, and the odd terms b1 , b3 , b5 , . . . are all even. This is because, according to property (2), for any consecutive pair bn and bn+1 , gcd(bn , bn+1 ) = 3m for some nonnegative integer m, which means no two consecutive terms are both even, and according to property (3) in the proof above, bn · bn+1 ≡ 0 (mod 2), which means that at least one of every two consecutive terms is odd. We first show that every reduced positive rational number appears in the sequence. Let rs ∈ Q+ where gcd(r, s) = 1. Case (i): s is even. Since gcd(r, s) = 1, r is odd. Then by Theorem 2, bn }n∈N . Suppose in { bn+1 r s appears r b2k = for some 2k ∈ N. s b2k+1 Then β2k = b2k b2k+1 = rs . bn Case (ii): s is odd. Then 2r is even and so by Theorem 2, 2r s appears in { bn+1 }n∈N , say 2r b2k+1 = for some 2k + 1 ∈ N. s b2k+2 Then β2k+1 = rs . Next, we show that no reduced positive rational number appears more than once in the sequence. Suppose not, let βn = βm for some m, n ∈ N, m %= n. Note that if both m and n are of the same parity, then this leads to a contradiction of Property (4) above. However, when m and n are of different parity, say m is even and n is odd, then bm bn bn /2 = βm = βn = = , bm+1 2bn+1 bn+1 and βm in lowest terms has an even denominator, while βn in lowest terms has an odd denominator, which is a contradiction. 7 INTEGERS 11 (2011) Similar modifications also work for each sequence {dn }n∈N in Theorem 5 below. 3. Families of Sequences In this section, we present extensions of Theorem 1 and 2, respectively, each of them containing infinitely many analogous sequences that enumerate (sub)sets of positive rational numbers. We only sketch briefly the proof of the first extension and skip the proof of the second extension as the proofs are similar to that of Theorem 2. Theorem 4. For each fixed k ≥ 4, k even, let ∞ ∞ , ! " n n n n k k k k n cn xn := 1 + 2xk + 3x2·k + · · · + x( 2 −1)·k + x 2 ·k + · · · + 2x(k−2)·k 2 2 n=0 n=0 n n n n n k 3k k 3k + x(k−1)·k + 2xk·k + · · · + x( 2 −2)·k + x( 2 −1)·k + · · · + x(2k−2)·k . 2 2 Then there exists a bijection between % # $ cn $ ∈ Q$n ∈ N and Q+ . cn+1 cn }n∈N gives an enumeration of the set of positive rational Thus each sequence { cn+1 numbers. Sketch of proof. The corresponding tree of fractions is constructed with k−1 vertices k/2 k/2 3 2 in the top row where the fractions 12 , 23 , . . . , k/2−1 k/2 , k/2 , k/2−1 , . . . , 2 , and 1 sit. Each (k/2−1)(r+s)−s r r 2r+s s in the tree has k children, in the order, 2r+s , 3r+2s , . . . , (k/2)(r+s)−s , (k/2)(r+s)−s (k/2)(r+s) (k/2)(r+s)−r 2r+3s r+2s (k/2)(r+s) , (k/2)(r+s)−r , (k/2−1)(r+s)−r , . . . , r+2s , and s . vertex This tree of fractions has the following properties. 1. A fraction r s appears in the tree if and only if s r also appears. 2. Without reducing to lowest terms, every fraction rs that appears in the tree has gcd(r, s)|(k/2)m for some m ≥ 0. It suffices to note that gcd(r, s) = gcd(t(r + s) − s, t(r + s) + r) = gcd(t(r + s) + s, t(r + s) − r) for all 1 ≤ t < k/2, while for t = k/2, gcd(t(r + s) − s, t(r + s)) = n1 gcd(r, s), gcd(t(r + s), t(r + s) − r) = n2 gcd(r, s), where n1 and n2 are factors of k/2. (Like in the proof of Theorem 2, this property is not needed in the proof.) 8 INTEGERS 11 (2011) 3. Every reduced positive rational number appears in the tree. 4. No reduced positive rational number appears at more than one vertex. For properties (3) and (4), it suffices to note that the (k/2 + 1)-th child always lies in the interval (1, k/(k−2)), the k-th child always lies in the interval (2, ∞), t(r+s)+s while for 1 < t < k/2, the (k + 1 − t)-th child, t(r+s)−r , always lies in the t+1 t interval ( t , t−1 ) since r s t + 1 − r+s t + r+s t+1 t(r + s) + s t < = . = r s < t t − r+s t(r + s) − r t − 1 + r+s t−1 Therefore, the (k/2 + 1)-th, (k/2 + 2)-th, . . . , k-th children always lie in the disjoint open intervals , - , - , , k k/2 k/2 − 1 k/2 − 1 k/2 − 2 3 1, , , , 2 , (2, ∞), , , ,..., k−2 k/2 − 1 k/2 − 2 k/2 − 2 k/2 − 3 2 respectively. So suppose for 1 < t < k/2 we have t+1 r t < < t s t−1 t(r−s)−s t(s−r)+r would have r/s as the (k + 1 − t)t(r−s)−s will serve the purpose of arriving th child, and t(s − r) + r < s, thus t(s−r)+r at a contradiction, like in the proof of Theorem 2. The case rs ∈ (2, ∞) is similar, with r−2s having rs as the k-th child, and r − 2s < r. Likewise, for the s r−s has rs as the (k/2 + 1)-th child and r − s < r. case rs ∈ (1, k/(k − 2)), 2r/k+s−r for some fraction r s with r > s, then The fraction f (n)/f (n + 1) has children f (kn + k − 1)/f (kn + k), . . . , f (kn + 2k − 2)/f (kn + 2k − 1), and so we deduce that f (n) satisfies f (kn + k − 1) = f (n) f (kn + k) = 2f (n) + f (n + 1) .. . , k k f (kn + 3k/2 − 2) = f (n) + − 1 f (n + 1) 2 2 k k f (kn + 3k/2 − 1) = f (n) + f (n + 1) 2 , -2 k k f (kn + 3k/2) = − 1 f (n) + f (n + 1) 2 2 .. . f (kn + 2k − 2) = f (n) + 2f (n + 1). 9 INTEGERS 11 (2011) Similar to the proof of Theorem 2, we can show that the coefficients cn satisfy the same recurrence relations and have the same initial values, thus concluding that f (n) = cn for all n ≥ 0. Theorem 5. For each fixed k ≥ 5, k odd, let ∞ ∞ , ! " n n n k + 1 k−1 ·kn n x 2 dn x := + · · · + 2x(k−2)·k 1 + 2xk + 3x2·k + · · · + 2 n=0 n=0 (k−1)·kn +x k·kn + 2x k + 1 3k−3 ·kn (2k−2)·kn 2 x + ···+ + ···+ x . 2 Then there exists a bijection between % # $ $ (m ) dn $ $ ∈ Q+ $(m, n) = 1, m · n ≡ 0 (mod 2) . ∈ Q$n ∈ N and dn+1 n dn Thus each sequence { dn+1 }n∈N gives an enumeration of the positive rational numbers with either an even numerator or an even denominator. Making the same modification on the following result. dn dn+1 as we did on bn bn+1 in Corollary 3, we have Corollary 6. For each n ∈ N, let us define d2n , d2n+1 d2n+1 := . 2d2n+2 δ2n := δ2n+1 Then the sequence {δn }n∈N gives an enumeration of Q+ . The corresponding tree of fractions is constructed with k − 1 vertices in the top (k+1)/2 3 2 r row where the fractions 12 , 23 , . . . , (k−1)/2 (k+1)/2 , (k−1)/2 , . . . , 2 , and 1 sit. Each vertex s in the tree has k children, in the order, k(r+s)/2−r−2s (k−1)(r+s)/2+r r 2r+s 2r+s , 3r+2s , . . . , k(r+s)/2−s , (k−1)(r+s)/2+s , k(r+s)/2−r−2s 2r+3s r+2s k(r+s)/2−s , . . . , r+2s , and s . Without reducing to lowest r tion s that appears in the tree has gcd(r, s)|k m for some m ≥ 0. terms, every frac- In particular, for k = 4 in Theorem 4 and k = 5 in Theorem 5, we have the following two theorems. Theorem 7. Let ∞ ! n=0 en xn := ∞ " n n n n n n (1 + 2x4 + 2x2·4 + x3·4 + 2x4·4 + 2x5·4 + x6·4 ). n=0 Then there exists a bijection between # % $ en $ ∈ Q$n ∈ N and Q+ . en+1 10 INTEGERS 11 (2011) en }n∈N gives an enumeration of the set of positive rational Thus the sequence { en+1 numbers. Theorem 8. Let ∞ ! n=0 fn xn := ∞ " n n n n n n n n (1 + 2x5 + 3x2·5 + 2x3·5 + x4·5 + 2x5·5 + 3x6·5 + 2x7·5 + x8·5 ). n=0 Then there exists a bijection between # % $ $ ) (m fn $ $ ∈ Q+ $(m, n) = 1, m · n ≡ 0 (mod 2) . ∈ Q$n ∈ N and fn+1 n fn }n∈N gives an enumeration of the set of positive rational Thus the sequence { fn+1 numbers with either an even numerator or an even denominator. Acknowledgement. The author thanks Professor Heng Huat Chan, Professor Bruce Reznick, and the referee for their helpful suggestions. References [1] B. Bates, M. Bunder, and K. Tognetti, Locating terms in the Stern-Brocot tree, European J. Combin., 31 (2010), no. 3, 1020–1033. [2] A. Brocot, Calcul des rouages par approximation, nouvelle méthode, Revue Chronométrique, 6 (1860), 186–194. [3] N. Calkin and H. Wilf, Recounting the rationals, Amer. Math. Monthly, 107 (2000), 360–363. [4] K. Dilcher and K. B. Stolarsky, A polynomial analogue to the Stern sequence, Int. J. Number Theory, 3 (2007), no. 1, 85–103. [5] D. H. Lehmer, On Stern’s diatomic series, Amer. Math. Monthly, 36 (1929), 59–67. [6] B. Reznick, Some binary partition functions, in Analytic Number Theory, Proceedings of a conference in honor of Paul T. Bateman, Birkhäuser, Boston (1990), 451–477. [7] M. A. Stern, Ueber eine zahlentheoretische Funktion, Journal für die reine und angewandte Mathematik, 55 (1858), 193–220.