q -QUASIADDITIVE FUNCTIONS SARA KROPF AND STEPHAN WAGNER q -quasiadditivity of arithmetic functions, q -quasimultiplicativity, which generalises complete q -additivity Abstract. In this paper, we introduce the notion of as well as the related concept of and -multiplicativity, respectively. We show that there are many natural examples for these f (q k+r a + b) = f (a) + f (b) f (q k+r a+b) = f (a)f (b) for all b < q k and a xed parameter r. In addition to some elementary properties of q -quasiadditive and q -quasimultiplicative functions, we prove characterisations of q -quasiadditivity and q -quasimultiplicativity for the special class of q -regular functions. The concepts, which are characterised by functional equations of the form or nal main result provides a general central limit theorem that includes both classical and new examples as corollaries. 1. Introduction Arithmetic functions based on the digital expansion in some base q -additive function called q -additive if e.g., [26]) The notion of a nonnegative integers) is q have a long history (see, is due to [4]: an arithmetic function (dened on f (q k a + b) = f (q k a) + f (b) whenever 0 ≤ b < qk . said to be completely A stronger version of this concept is q -additive complete q-additivity: a function f is if we even have f (q k a + b) = f (a) + f (b) whenever 0 ≤ b < qk . q -multiplicative functions is dened in an analogous q -additivity of a function means that it can be evaluated Typical examples of completely q -additive functions are the The class of (completely) fashion. Loosely speaking, (complete) by breaking up the base-q expansion. q -ary sum of digits and the number of occurrences of a specied digit. There are, however, many simple and natural functions based on the not q -additive. A very basic example of this kind are a certain block of digits in the q -ary block counts : q -ary expansion that are the number of occurrences of expansion. This and other examples provide the motivation for the present paper, in which we dene and study a larger class of functions with comparable properties. Denition. An arithmetic function (a function dened on the set of nonnegative integers) is called q -quasiadditive if there exists some nonnegative integer r such that f (q k+r a + b) = f (a) + f (b) (1) whenever 0 ≤ b < qk . Likewise, f is said to be f (q (2) for some xed nonnegative integer Key words and phrases. q -additive r k+r if it satises the identity a + b) = f (a)f (b) whenever function, q -quasimultiplicative 0 ≤ b < qk . q -quasiadditive function, q -regular function, central limit theorem. The rst author is supported by the Austrian Science Fund (FWF): P 24644-N26. The second author is supported by the National Research Foundation of South Africa under grant number 96236. The authors were also supported by the Karl Popper Kolleg ModelingSimulationOptimization funded by the Alpen-Adria-Universität Klagenfurt and by the Carinthian Economic Promotion Fund (KWF). Part of this paper was written while the second author was a Karl Popper Fellow at the Mathematics Institute in Klagenfurt. He would like to thank the institute for the hospitality received. 1 2 SARA KROPF AND STEPHAN WAGNER We remark that the special case term completely q -quasiadditive r=0 q -additivity, is exactly complete so strictly speaking the function might be more appropriate. However, since we are not considering a weaker version (for which natural examples seem to be much harder to nd), we do not make a distinction. In the following section, we present a variety of examples of q -quasiadditive and q -quasimultipli- cative functions. In Section 3, we give some general properties of such functions. Since most of our examples also belong to the related class of q -regular functions, we discuss the connection in Section 4. Finally, we prove a general central limit theorem for q -quasiadditive and -multiplicative functions that contains both old and new examples as special cases. 2. Examples of q -quasiadditive and q -quasimultiplicative q -quasiadditivity Let us now back up the abstract concept of functions by some concrete examples. Block counts. As mentioned in the introduction, the number of occurrences of a xed digit is a typical example of a B = 1 2 · · · ` q -additive function. However, the number of occurrences of a given block n, which we denote by cB (n), q -ary expansion of q k a + b is obtained by joining the expansions of a and b, so occurrences of B in a and occurrences of B in b are counted by cB (a) + cB (b), but occurrences that involve digits of both a and b are not. However, if B is a block dierent from 00 · · · 0, then cB is q -quasiadditive: note that the k+` representation of q a + b is of the form of digits in the expansion of a nonnegative integer does not represent a q -additive function. The reason is simple: the a1 a2 · · · aµ 00 · · · 0 b1 b2 · · · bν | {z } | {z } | {z } expansion of a ` zeros expansion of b 0 ≤ b < q k , so occurrences of the block B have to belong to either a or b only, implying cB (q a + b) = cB (a) + cB (b), with one small caveat: if the block starts and/or ends with whenever that k+` a sequence of zeros, then the count needs to be adjusted by assuming the digital expansion of a nonnegative integer to be padded with zeros on the left and on the right. For example, let B be the block 0101 in base 2. The binary representations of 469 and 22 are 111010101 and 10110 respectively, so we have cB (469) = 2 and cB (22) = 1 (note the occurrence of 0101 at the beginning of 10110 if we assume the expansion to be padded with zeros), as well as cB (240150) = cB (29 · 469 + 22) = cB (469) + cB (22) = 3. Indeed, the block B occurs three times in the expansion of 240150, which is 111010101000010110. The number of runs and the Gray code. The number of ones in the Gray code of a nonnegative integer n, which we denote by hGRAY (n), is also equal to the number of runs (maximal n (counting the number hGRAY (n) is A005811 in Sloane's sequences of consecutive identical digits) in the binary representations of of runs in the representation of 0 as 0); the sequence dened by On-Line Encyclopedia of Integer Sequences [16]. An analysis of its expected value is performed hGRAY is 2-quasiadditive f (n) = hGRAY (n) + 1 if n in [8]. The function if n is even and up to some minor modication: set is odd. the total number of occurrences of the two blocks 01 The new function and 10 f f (n) = hGRAY (n) can be interpreted as in the binary expansion (considering binary expansions to be padded with zeros at both ends), so the argument of the previous example applies again and shows that f is 2-quasiadditive. The nonadjacent form and its Hamming weight. The nonadjacent form (NAF) of a nonnegative integer is the unique base-2 representation with digits as 1 0, 1, −1 (−1 is usually represented in this context) and the additional requirement that there may not be two adjacent nonzero digits, see [17]. For example, the NAF of 27 is 100101. It is well known that the NAF always has minimum Hamming weight (i.e., the number of nonzero digits) among all possible binary representations with this particular digit set, although it may not be unique with this property (compare, e.g., [17] with [14]). q -QUASIADDITIVE The Hamming weight hNAF FUNCTIONS 3 of the nonadjacent form has been analysed in some detail [11, 19], and it is also an example of a 2-quasiadditive function. It is not dicult to see that hNAF is characterised by the recursions hNAF (2n) = hNAF (n), hNAF (4n + 1) = hNAF (n) + 1, together with the initial value hNAF (0) = 0. hNAF (4n − 1) = hNAF (n) + 1 The identity hNAF (2k+2 a + b) = hNAF (a) + hNAF (b) can be proved by induction. In Section 4, this example will be generalised and put into a greater context. The number of optimal {0, 1, −1}-representations. As mentioned above, the NAF may not be the only representation with minimum Hamming weight among all possible binary representations with digits n 0, 1, −1. The number of optimal representations of a given nonnegative integer is therefore a quantity of interest in its own right. Its average over intervals of the form was studied by Grabner and Heuberger [10], who also proved that the number representations of n rOPT (n) [0, N ) of optimal can be obtained in the following way: Lemma 1 (GrabnerHeuberger [10]). Let sequences ui (i = 1, 2, . . . , 5) be given recursively by u1 (0) = u2 (0) = · · · = u5 (0) = 1, u1 (1) = u2 (1) = 1, u3 (1) = u4 (1) = u5 (1) = 0, and u1 (2n) = u1 (n), u1 (2n + 1) = u2 (n) + u4 (n + 1), u2 (2n) = u1 (n), u2 (2n + 1) = u3 (n), u3 (2n) = u2 (n), u3 (2n + 1) = 0, u4 (2n) = u1 (n), u4 (2n + 1) = u5 (n + 1), u5 (2n) = u4 (n), u5 (2n + 1) = 0. The number rOPT (n) of optimal representations of n is equal to u1 (n). A straightforward calculation shows that u1 (8n) = u2 (8n) = · · · = u5 (8n) = u1 (8n + 1) = u2 (8n + 1) = u1 (n), (3) u3 (8n + 1) = u4 (8n + 1) = u5 (8n + 1) = 0. This gives us the following result: The number of optimal {0, 1, −1}-representations of a nonnegative integer is a 2quasimultiplicative function. Specically, for any three nonnegative integers a, b, k with b < 2k , we have Lemma 2. rOPT (2k+3 a + b) = rOPT (a)rOPT (b). Proof. We will prove a somewhat stronger statement by induction on t: write u(n) = (u1 (n), u2 (n), u3 (n), u4 (n), u5 (n))t . We show that u(2k+3 a + b) = rOPT (a)u(b) and u(2k+3 a + b + 1) = rOPT (a)u(b + 1) for all a, b, k satisfying the conditions of the lemma, from which the desired result follows by considering the rst entry of the vector u(2k+3 a + b). Note rst that both identities are clearly 4 SARA KROPF AND STEPHAN WAGNER true for k=0 in view of (3). For the induction step, we distinguish two cases: if b is even, we have 1 1 u(2k+3 a + b) = 0 1 0 1 1 = 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 k+2 0 a + b/2) · u(2 0 0 0 0 0 · rOPT (a)u(b/2) 0 0 = rOPT (a)u(b) by the induction hypothesis, as well as 0 0 u(2k+3 a + b + 1) = 0 0 0 0 0 = 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 k+2 0 a + b/2) + 0 · u(2 0 0 0 0 0 0 0 0 0 · rOPT (a)u(b/2) + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 k+2 0 a + b/2 + 1) · u(2 1 0 0 0 0 · rOPT (a)u(b/2 + 1) 1 0 = rOPT (a)u(b + 1). The case that b is odd is treated in an analogous fashion. In Section 4, we will show that this is also an instance of a more general phenomenon. The run length transform and cellular automata. The run length transform of a sequence is dened in a recent paper of Sloane [18]: it is based on the binary representation, but could in principle also be generalised to other bases. Given a sequence s1 , s2 , . . ., its run length transform is obtained by the rule t(n) = Y si , i∈L(n) where L(n) is the multiset of run lengths of n (lengths of blocks of consecutive ones in the binary 1910 t(1910) = s2 s23 . representation). For example, the binary expansion of of run lengths would be {3, 3, 2}, giving is 11101110110, so the multiset L(n) A typical example is obtained for the sequence of Jacobsthal numbers given by the formula sn = 31 (2n+2 −(−1)n ). The associated run length transform tn (sequence A071053 in the OEIS [16]) counts the number of odd coecients in the expansion of as the number of active cells at the n-th (1+x+x2 )n , and it can also be interpreted generation of a certain cellular automaton. Further examples stemming from cellular automata can be found in Sloane's paper [18]. The argument that proved q -quasiadditivity of block counts also applies here, and indeed it is easy to see that the identity t(2k+1 a + b) = t(a)t(b), 0 ≤ b < 2k , holds for the run length transform of any sequence, meaning that any such transform is 2-quasimultiplicative. In fact, it is not dicult to show that every 2-quasimultiplicative function with parameter r = 1 is the run length transform of some sequence. where q -QUASIADDITIVE FUNCTIONS 5 3. Elementary properties Now that we have gathered some motivating examples for the concepts of q -quasimultiplicativity, q -quasiadditivity and let us present some simple results about functions with these properties. First of all, let us state an obvious relation between q -quasiadditive and q -quasimultiplicative functions: If a function f is q-quasiadditive, then the function dened by g(n) = cf (n) for some positive constant c is q-quasimultiplicative. Conversely, if f is a q-quasimultiplicative function that only takes positive values, then the function dened by g(n) = logc f (n) for some positive constant c 6= 1 is q-quasiadditive. Proposition 3. The next proposition deals with the parameter Proposition 4. r in the denition of a q -quasiadditive function: If the arithmetic function f satises f (q k+r a + b) = f (a) + f (b) for some xed nonnegative integer r whenever 0 ≤ b < qk , then it also satises f (q k+s a + b) = f (a) + f (b) for all nonnegative integers s ≥ r whenever 0 ≤ b < qk . Proof. If a, b are nonnegative integers with 0 ≤ b < qk , then clearly also 0 ≤ b < qk+s−r if s ≥ r, and thus f (q k+s a + b) = f (q (k+s−r)+r a + b) = f (a) + f (b). If two arithmetic functions f and g are q-quasiadditive functions, then so is any linear combination αf + βg of the two. Proof. In view of the previous proposition, we may assume the parameter r in (1) to be the same Corollary 5. for both functions. The statement follows immediately. Finally, we observe that by breaking the q -ary q -quasiadditive and q -quasimultiplicative functions can be computed expansion into pieces. If f is a q-quasiadditive (q-quasimultiplicative) function, then • f (0) = 0 (f (0) = 1, respectively, unless f is identically 0), • f (qa) = f (a) for all nonnegative integers a. Proof. Assume rst that f is q-quasiadditive. Setting a = b = 0 in the Lemma 6. dening functional equation (1), we obtain f (0) = f (0) + f (0), b = 0 while a is arbitrary, and the rst statement follows. Setting f (q for all k ≥ 0. k+r we now nd that a) = f (a) In particular, this also means that f (a) = f (q r+1 a) = f (q r · qa) = f (qa), which proves the second statement. For q -quasimultiplicative functions, the proof is analogous (and one can also use Proposition 3 for positive functions). Suppose that the function f is q-quasiadditive with parameter r, i.e. f (qk+r a + b) = f (a) + f (b) whenever 0 ≤ b < q k . Going from left to right, split the q -ary expansion of n into blocks by inserting breaks after each run of r or more zeros. If these blocks are the q-ary representations of n1 , n2 , . . . , n` , then we have Proposition 7. f (n) = f (n1 ) + f (n2 ) + · · · + f (n` ). Moreover, if m1 , m2 , . . . , m` are obtained from n1 , n2 , . . . , n` by dividing o the highest possible powers of q, then f (n) = f (m1 ) + f (m2 ) + · · · + f (m` ). 6 SARA KROPF AND STEPHAN WAGNER Analogous statements hold for q-quasimultiplicative functions, with sums replaced by products. Proof. This is obtained by a straightforward induction on ` together with the fact that f (qh a) = f (a), which follows from the previous lemma. Example 1. Recall that the Hamming weight of the NAF (which is the minimum Hamming {0, 1, −1}-representation) is 2-quasiadditive with parameter r = 2. To determine hNAF (314 159 265), we split the binary representation, which is 10010101110011011000010100001,, weight of a into blocks by inserting breaks after each run of at least two zeros: 100|101011100|110110000|1010000|1. n1 , n2 , . . . , n` in the statement of the proposition are now 4, 348, 432, 80, 1 respecm1 , m2 , . . . , m` are therefore 1, 87, 27, 5, 1. Now we use the values hNAF (1) = 1, hNAF (5) = 2, hNAF (27) = 3 and hNAF (87) = 4 to obtain The numbers tively, and the numbers hNAF (314 159 265) = 2hNAF (1) + hNAF (5) + hNAF (27) + hNAF (87) = 11. Example 2. In the same way, we consider the number of optimal representations 2-quasimultiplicative with parameter r = 3. Consider for instance the binary 204 280 974, namely 1100001011010001010010001110.. We split into blocks: rOPT , which is representation of 110000|101101000|101001000|1110. The four blocks correspond to the numbers rOPT (3) = 2, rOPT (45) = 5, rOPT (41) = 1 4. 48 = 16·3, 360 = 8·45, 328 = 8·41 and 14 = 2·7. Since rOPT (7) = 1, we obtain rOPT (204 280 974) = 10. and q -Regular functions q -regular functions and examine the connection to our concepts. q -regular sequences. t if f = u f for a vector u and a vector-valued function f with matrices In this section, we introduce See [1] for more background on A function Mi , 0 ≤ i < q f is q -regular satisfying f (qn + i) = Mi f (n) (4) 0 ≤ i < q , qn + i > 0. for v = f (0). q -regular if and We set Equivalently, a function f is only if f (n) = ut (5) L Y f can be written as M ni v i=0 nL · · · n0 q -ary expansion of n. q -regular functions is a generalization of q -additive and q -multiplicative functions. However, we emphasise that q -quasiadditive and q -quasimultiplicative functions are not necessarily q -regular: a q -regular sequence can always be bounded by O(nc ) for a constant c, see [1, Thm. 16.3.1]. In our setting however, the values of f (n) can be chosen arbitrarily for those n whose q -ary expansion does not contain 0r . Therefore a q -quasiadditive or -multiplicative function can where is the The notion of grow arbitrarily fast. (u, (Mi )0≤i<q , v) a representation of the q -regular function f . Such a representation is if M0 v = v , meaning that in (5), leading zeros in the q -ary expansion of n do not change anything. We call a representation minimal if the dimension of the matrices Mi is minimal among all representations of f . Following [7], every q -regular function has a zero-insensitive minimal representation. We call called zero-insensitive 4.1. When is a of q -regular q -regular function functions that are q -quasimultiplicative? q -quasimultiplicative. We now give a characterisation Let f be a q-regular sequence with zero-insensitive minimal representation (5). Then the following two assertions are equivalent: • The sequence f is q -quasimultiplicative with parameter r. • M0r = vut . Theorem 8. q -QUASIADDITIVE Proof. 1}, I Let d be the dimension of the vectors. FUNCTIONS We prove that nite} is a generating system of the whole 7 {ut d-dimensional Q i∈I Mni | ni ∈ {0, . . . , q − vector space by contradiction: d0 < d unit vectors form M | n ∈ {0, . . . , q − 1}, I nite}. This ni i i∈I coordinate transform denes a dierent representation of f with matrices M̂i and vectors û and Q v̂ . However, only the rst d0 coordinates of any vector ut i∈I Mni are nonzero. Thus we can reduce the dimension of the matrices and vectors from d to d0 to obtain a new representation of f . This contradicts Q the minimality of the original representation. Analogously, { j∈J Mnj v | nj ∈ {0, . . . , q − 1}, J nite} is also a generating system for the assume that there is a coordinate transformation such that the rst a basis of the transformed space spanned by {ut Q whole vector space. The q -quasimultiplicativity f (n) with parameter r is equivalent Y Y ut Mni (M0r − vut ) M nj v = 0 of i∈I to the identity j∈J {ut Q Q i∈I Mni } and { j∈J t r t ating systems of the entire vector space, this is equivalent to x (M0 − vu )y = r t and y , which in turn is equivalent to M0 = vu . for all nite tuples Example (ni )i∈I and (nj )j∈J . Since both Mnj v} are gener0 for all vectors x {0, 1, −1}-representations). The number of optimal {0, 1, −1}2-regular sequence by Lemma 1. A minimal zerot vector (u1 (n), u2 (n), u3 (n), u1 (n + 1), u4 (n + 1), u5 (n + 1)) is 3 (The number of optimal representations as described in Section 2 is a insensitive representation for the given by 1 1 0 M0 = 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 , 0 1 0 0 0 0 M1 = 0 0 0 ut = (1, 0, 0, 0, 0, 0) and v = (1, 1, 1, 1, 0, 0)t . 3 t As M0 = vu , this sequence is 2-quasimultiplicative 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 with parameter 1 0 0 0 0 1 3, 0 0 0 , 0 0 0 which is the same result as in Lemma 2. Remark. The condition on the minimality of the representation in Theorem 8 is necessary as illustrated by the following example: f (n) = 2s2 (n) where s2 (n) is the binary sum of digits function. This sequence is 2-regular and 2-(quasi-)multiplicative with parameter r = 0. A minimal representation 0 t is given by M0 = 1, M1 = 2, v = 1 and u = 1. As stated in Theorem 8, we have M0 = vu = 1. 1 13 27 If we use the zero-insensitive non-minimal representation dened by M0 = 0 2 , M1 = 2 0 5 , v = (1, 0)t and ut = (1, 0) instead, we have rank M0r = 2 for all r ≥ 0. Thus M0r 6= vut . Consider the sequence 4.2. When is a q -regular function q -quasiadditive? The characterisation of q -regular funcq -quasiadditive is somewhat more complicated. Again, we consider a zeroinsensitive (but not necessarily minimal) representation. We let U be the smallest vector space Q t t t t such that all vectors of the form u i∈I Mni lie in the ane subspace u + U (U is used as a t t shorthand for {x : x ∈ U }). Such a vector space must exist, since u is a vector of this form (corresponding to the empty product, where I = ∅). Likewise, let V be the smallest vector space Q such that all vectors of the form j∈J Mnj v lie in the ane subspace v + V . tions that are also Let f be a q-regular sequence with zero-insensitive representation (5). The sequence is q-quasiadditive with parameter r if and only if all of the following statements hold: • ut v = 0, • U t is orthogonal to (M0r − I)v , i.e. xt (M0r − I)v = xt M0r v − xt v = 0 for all x ∈ U , • V is orthogonal to ut (M0r − I), i.e. ut (M0r − I)y = ut M0r y − ut y = 0 for all y ∈ V , • U t M0r V = 0, i.e. xt M0r y = 0 for all x ∈ U and y ∈ V . Theorem 9. f 8 SARA KROPF AND STEPHAN WAGNER Proof. ut v = 0 The rst statement necessary condition by Lemma 6. f (0) = 0, which we already know to ut M0r v = ut v = 0 by the assumption is equivalent to Note also that be a that the representation is zero-insensitive. For the remaining statements, we write the quasiadditivity condition in terms of our matrix representation as we did in the quasimultiplicative case: ut Y Mni M0r i∈I J = ∅, Specically, when Y M nj v = u t j∈J Y M ni v + u t i∈I Y Mnj v. j∈J we get ut Y Mni M0r − I v = ut v = 0. i∈I I=∅ Setting also gives us u t (M0r − I)v = 0, so together we obtain Y ut Mni − ut M0r − I v = 0. i∈I t i∈I Mni − u , the second statement follows. The proof of the third statement is analogous. Finally, if we assume that the rst three statements U Since t ut is spanned by all vectors of the form Q hold, then we nd that ut Y Mni M0r i∈I Y M nj v j∈J = ut Y Y Y Y Mni − ut M0r M nj v − v + u t Mni − ut M0r v + ut M0r M nj v − v i∈I j∈J i∈I j∈J + ut M0r v Y Y Y Y = ut Mni − ut M0r M nj v − v + u t Mni − ut v + ut M nj v − v i∈I = u t Y j∈J t M ni − u M0r i∈I Thus Y being valid for all choices of U and Y j∈J M ni v + u i∈I t Y Mnj v. j∈J is equivalent to ut Example 4. M nj v − v + u j∈J q -quasiadditivity denition of i∈I t Y Y Mni − ut M0r M nj v − v = 0 i∈I j∈J I, J , ni and nj . The desired fourth condition is clearly equivalent by V. For the Hamming weight of the nonadjacent form, a zero-insensitive (and also minimal) (hNAF (n), hNAF (n + 1), hNAF (2n + 1), 1)t is 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 M0 = 1 0 0 1 , M1 = 0 1 0 1 , 0 0 0 1 0 0 0 1 representation for the vector ut = (1, 0, 0, 0) v = (0, 1, 1, 1)t . w1 = ut M1 − ut , w2 = ut M12 − ut and w3 = ut M1 M0 M1 − ut are linearly independent. If we let W be the vector space spanned by those three, it is easily veried that M0 t t and M1 map the ane subspace u + W to itself, so U = W is spanned by these vectors. 2 Similarly, the three vectors M1 v − v , M1 v − v and M1 M0 M1 v − v span V . and The three vectors The rst condition of Theorem 9 is obviously true. conditions with 2-regular r = 2 for the base vectors of sequence that is also Finding the vector spaces U 2-quasiadditive, U and We only have to verify the other three V, which is done easily. Thus hNAF is a as it was also shown in Section 2. V is not trivial. But in a special case of q -regular functions, we q -additivity, which is easier to check. These q -regular functions as dened in [12]: a transducer transforms the q -ary expansion and can give a sucient condition for are output sums of transducers of an integer n (read from the least signicant to the most signicant digit) deterministically q -QUASIADDITIVE into an output sequence and leads to a state s. FUNCTIONS The output sum is then the sum of this output sequence together with the nal output of the state function evaluated at n. The function hN AF 9 s. This denes the value of the q -regular discussed in the example above, as well as many other examples, can be represented in this way. The output sum of a connected transducer is q-additive with parameter r if the following conditions are satised: • The transducer has the reset sequence 0r going to the initial state, i.e., reading r zeros always leads to the initial state of the transducer. • For every state, the output sum along the path of the reset sequence 0r equals the nal output of this state. • Additional zeros at the end of the input sequence do not change the output sum. Proposition 10. Proof. The matrices of the representation for the output sum of a transducer have the structure Nε Mε = 0 0 δε 1 0 [ε = 0]I 0 [ε = 0]I Nε is a matrix with exactly one nonzero entry per row that is necessarily equal to 1, δ ε are arbitrary vectors (see [12, Remark 3.10]). Furthermore, ut = (1, 0, . . . , 0) and v = (b(0), 1, b(0) − N0 b(0) − δ 0 ) for a vector b(0). The vector b(0) contains the nal outputs of the states. The vectors δ ε contain the outputs of the transitions with input ε, and the matrices Nε are the adjacency matrices of the transitions with input ε. The initial state corresponds to the rst coordinate. where and Then by (4), the output sum of the transducer is the rst coordinate of b(qn + ε) = Nε b(n) + δ ε (6) if qn + ε > 0 and of b(0) otherwise. The third condition ensures that that one leading zero does not change anything. connectivity of the underlying graph implies that (6) also holds for coordinates of Let J v are qn + ε = 0 Thus the and the last zero and we can reduce the dimension of the representation. be nite and nj ∈ {0, . . . , q − 1} j ∈ J . The rst condition 1 0 ··· 0 Y Nnj N0r = ... ... . . . ... j∈J 1 0 ··· 0 for implies that and the second condition implies that Y Nnj b(0) = j∈J Y Nnj (I + · · · + N0r−1 )δ 0 . j∈J Using (6) recursively together with these two conditions gives b(q k+r m + n) = k−1 Y Nnj N0r b(m) + b(n) − j=0 1 .. = . 1 of Nnj b(0) + j=0 ··· 0 . . . .. . . b(m) . 0 ··· . k−1 Y Nnj (I + · · · + N0r−1 )δ 0 j=0 0 + b(n) 0 n with q -ary digit expansion (nk−1 · · · n0 ) b(n) is q -quasiadditive. for all k−1 Y and all m. This implies that the rst coordinate 10 SARA KROPF AND STEPHAN WAGNER 5. A central limit theorem for q -quasiadditive In this section, we prove a central limit theorem for positive values. and -multiplicative functions q -quasimultiplicative functions taking only By Proposition 3, this also implies a central limit theorem for q -quasiadditive functions. To this end, we dene a generating function: let Mk positive values, let integers whose q -ary f be a q -quasimultiplicative function with q k (i.e., those positive be the set of all nonnegative integers less than k X expansion needs at most F (x, t) = digits), and set xk X f (n)t . n∈Mk k≥0 The decomposition of Proposition 7 now translates directly to an alternative representation for F (x, t): let B the function q whose q -ary representation does q -ary representation of n, and dene be the set of all positive integers not divisible by not contain the block B(x, t) 0r , let `(n) denote the length of the by B(x, t) = X x`(n) f (n)t . n∈B q = 2 and r = 1, this X B(x, t) = xk f (2k − 1)t . We remark that in the special case where (7) simplies greatly to k≥1 Proposition 11. F (x, t) = Proof. The generating function F (x, t) can be expressed as 1 · 1−x 1− 1 + (1 + x + · · · + xr−1 )B(x, t) 1 . 1+(1+x+· · ·+xr−1 )B(x, t) = 1 − x − xr B(x, t) 1−x B(x, t) xr The rst factor stands for the initial sequence of leading zeros, the second factor for a (possibly empty) sequence of blocks consisting of an element of B r or more B with up and last factor for the nal part, which may be empty or an element of zeros, and the to r−1 zeros (possibly none) added at the end. Under suitable assumptions on the growth of a q -quasiadditive or q -quasimultiplicative function, we can exploit the expression of Proposition 11 to prove a central limit theorem in the following steps. Denition. at most polynomial growth if f (n) = O(nc ) and f (n) = Ω(n ) for a xed c ≥ 0. We say that f has at most logarithmic growth if f (n) = O(log n). Lemma 12. Assume that the positive, q -quasimultiplicative function f has at most polynomial growth. There exist positive constants δ and such that • B(x, t) has radius of convergence ρ(t) > 1q whenever |t| ≤ δ . • For |t| ≤ δ , the equation x + xr B(x, t) = 1 has a complex solution α(t) with |α(t)| < ρ(t) and no other solutions with modulus ≤ (1 + )|α(t)|. • Thus the generating function F (x, t) has a simple pole at α(t) and no further singularities of modulus ≤ (1 + )|α(t)|. • Finally, α is an analytic function of t for |t| ≤ δ . Proof. The polynomial growth of f implies that C −1 φ−`(n) ≤ f (n) ≤ Cφ`(n) for some positive We say that a function f has −c φ. Moreover, B contains O(β ` ) elements whose q -ary expansion has length at r r−1 most `, where β < q is a root of the polynomial x − (q − 1)x − · · · − (q − 1)x − (q − 1). This −1 δ implies that B(x, t) is indeed an analytic function of x for |x| < β φ whenever |t| ≤ δ . For 1 −1 δ suitably small δ , β φ is greater than q , which proves the rst part of our statement. Next note constants C and that (q − 1)x , 1 − (q − 1)x − · · · − (q − 1)xr r only solution of the equation x + x B(x, 0) = 1. B(x, 0) = 1 q is the statements are therefore a simple consequence of the implicit function theorem. and it follows that α(0) = All remaining q -QUASIADDITIVE FUNCTIONS 11 Assume that the positive, q-quasimultiplicative function f has at most polynomial growth. With δ and as in the previous lemma, we have, uniformly in t, Lemma 13. [xk ]F (x, t) = κ(t) · α(t)−k 1 + O((1 + )−k ) for some function κ. Both α and κ are analytic functions of t for |t| ≤ δ , and κ(t) 6= 0 in this region. Proof. This follows from the previous lemma by means of singularity analysis, see [9]. Assume that the positive, q-quasimultiplicative function f has at most polynomial growth. Let Nk be a randomly chosen integer in {0, 1, . . . , qk − 1}. The random variable Lk = log f (Nk ) has mean µk + O(1) and variance σ2 k + O(1), where the two constants are given by Theorem 14. Bt (1/q, 0) q 2r µ= and (8) σ 2 = −Bt (1/q, 0)2 q −4r+1 (q − 1)−1 + 2Bt (1/q, 0)2 q −3r+1 (q − 1)−1 − Bt (1/q, 0)2 q −4r (q − 1)−1 − 4rBt (1/q, 0)2 q −4r + Btt (1/q, 0)q −2r − 2Bt (1/q, 0)Btx (1/q, 0)q −4r−1 . 2 If f is not the √ constant function f ≡ 1, then σ 6= 0 and the renormalised random variable (Lk − µk)/(σ k) converges weakly to a standard Gaussian distribution. Proof. This follows from the fact that [xk ]F (x, t)/q k is the moment generating function of the Quasi-power theorem, see [13]. The only part that we actually have to verify is that unless f Lk and σ2 = 6 0 is constant. Assume that σ 2 = 0. We rst consider the case that be the least integer greater than expansion of log α(t) at t = 0, 1 such that ts log α(t) is not a linear function. Let s occurs with a nonzero coecient in the Taylor i.e., log α(t) = log α(0) + at + bts + O(ts+1 ). By assumption, we have s ≥ 3. Since α(0) = 1 q and κ(0) = 1, it follows that [xk ]F (x, t) = exp log κ(t) − k log α(t) − k log q + O (1 + )−k k q = exp − akt − bkts + O kts+1 + t + (1 + )−k . E(exp(tLk )) = We see that Lk , a = −µ. Considering the renormalised version Rk = Lk −µk of the random variable k1/s we get for xed τ. It E exp τ Rk = exp − bτ s + O k −1/s + (1 + )−k s follows that limk→∞ E(exp τ Rk ) = exp(−bτ ) for every complex τ , which is a continuous function. By Lévy's continuity theorem, this would imply convergence in distribution M (τ ) = exp(−bτ s ). However, τ = 0 are nite and the second derivative of exp(−bτ s ) at τ = 0 is 0, thus the second moment is 0. A random variable whose second moment is 0 is almost surely equal to 0 and thus would have moment generating function 1. The only remaining possibility is that log α(t) is linear: log α(t) = log α(0) + at, thus α(t) = α(0)eat = eat /q . If we plug this into the dening equation of α(t), we obtain of Rk to a random variable with moment generating function there is no such random variable: All derivatives at 1= eat eart X −`(n) a`(n)t + r q e f (n)t q q n∈B 12 SARA KROPF AND STEPHAN WAGNER |t| ≤ δ . However, the right side of this identity has strictly positive second derivative t unless a = 0 and f (n) = 1 for all n ∈ B (in which case f (n) = 1 for all n). Thus σ 2 6= 0 f ≡ 1. identically for for real unless Assume that the q-quasiadditive function f has at most logarithmic growth. Let Nk be a randomly chosen integer in {0, 1, . . . , qk − 1}. The random variable Lk = f (Nk ) has mean µ̂k + O(1) and variance σ̂2 k + O(1), where the two constants µ and σ2 are given by the same formulas as in Theorem 14, with B(x, t) replaced by Corollary 15. X B̂(x, t) = x`(n) ef (n)t . n∈B √ If f is not the constant function f ≡ 0, then the renormalised random variable (Lk − µ̂k)/(σ̂ k) converges weakly to a standard Gaussian distribution. Remark. By means of the Cramér-Wold device (and Corollary 5), we also obtain joint normal distribution of tuples of q -quasiadditive functions. We now revisit the examples discussed in Section 2 and state the corresponding central limit theorems. Some of them are well known while others are new. We also provide numerical values for the constants in mean and variance. Example a 5 (see also [6, 15]) 2-quasiadditive . The number of blocks 0101 occurring in the binary expansion of n is function of at most logarithmic growth. Thus by Corollary 15, the standardised random variable is asymptotically normally distributed, the constants being Example 6 (see also [11,19]). µ̂ = The Hamming weight of the nonadjacent form is at most logarithmic growth (as the length of the NAF of n 1 16 and σ̂ 2 = 17 256 . 2-quasiadditive with is logarithmic). Thus by Corollary 15, the standardised random variable is asymptotically normally distributed. The associated constants are 1 3 and µ̂ = σ̂ 2 = 2 27 . Example 7 (see Section 2). 0, 1, −1-representations is 2-quasimultiplicative. 2-regular, it has at most polynomial growth. Thus The number of optimal As it is always greater or equal to 1 and Theorem 14 implies that the standardised logarithm of this random variable is asymptotically normally distributed with numerical constants given by Example . µ ≈ 0.060829, σ 2 ≈ 0.038212. s1 , s2 , . . . satises sn ≥ 1 and sn = O(cn ) for a constant c ≥ 1. The run length transformation t(n) of sn is 2-quasimultiplicative. As sn ≥ 1 for all n, we have t(n) ≥ 1 for all n as well. Furthermore, there exists a constant A such that sn ≤ Acn for all n, and the sum of all run lengths is bounded by the length of the binary expansion, thus Y Y t(n) = si ≤ (Aci ) ≤ (Ac)1+log2 n . 8 (see Section 2) Suppose that the sequence i∈L(n) Consequently, t(n) i∈L(n) is positive and has at most polynomial growth. By Theorem 14, we obtain an asymptotic normal distribution for the standardised random variable and σ2 log t(Nk ). The constants µ in mean and variance are given by µ= X (log si )2−i−2 i≥1 and σ2 = X X (log si )2 2−i−2 − (2i − 1)2−2i−4 − (log si )(log sj )(i + j − 1)2−i−j−3 . i≥1 j>i≥1 These formulas can be derived from those given in Theorem 14 by means of the representation (7), P log t(n) = i≥1 Xi (n) log si , where Xi (n) is the number of runs of length i in the binary representation of n. The coecients in the two formulas stem from mean, variance and covariances of the Xi (n). 1 n+2 In the special case that sn is the Jacobsthal sequence (sn = (2 − (−1)n ), see Section 2), 3 2 we have the numerical values µ ≈ 0.429947, σ ≈ 0.121137. and the terms can also be interpreted easily: write q -QUASIADDITIVE FUNCTIONS 13 References 1. Jean-Paul Allouche and Jerey Shallit, Automatic sequences: Theory, applications, generalizations, Cambridge University Press, Cambridge, 2003. 2. Nader L. Bassily and Imre Kátai, Distribution of the values of Acta Math. Hungar. 68 (1995), no. 4, 353361. q -additive functions on polynomial sequences, 3. Emmanuel Cateland, Suites digitales et suites k-régulières, Ph.D. thesis, Université Bordeaux, 1992. 4. Hubert Delange, Sur les fonctions q -additives ou q -multiplicatives, Acta Arith. 21 (1972), 285298. , Sur la fonction sommatoire de la fonction somme des chires , Enseignement Math. (2) 5. 21 (1975), 3147. 6. Michael Drmota, The distribution of patterns in digital expansions, Algebraic Number Theory and Diophantine Analysis (F. Halter-Koch and R. F. Tichy, eds.), de Gruyter (Berlin), 2000, pp. 103121. 7. Philippe Dumas, Asymptotic expansions for linear homogeneous divide-and-conquer recurrences: Algebraic and analytic approaches collated, Theoret. Comput. Sci. 548 (2014), 2553. 8. Philippe Flajolet and Lyle Ramshaw, A note on Gray code and odd-even merge, SIAM J. Comput. 9 (1980), 142158. 9. Philippe Flajolet and Robert Sedgewick, Analytic combinatorics, Cambridge University Press, Cambridge, 2009. 10. Peter J. Grabner and Clemens Heuberger, On the number of optimal base 2 representations of integers, Des. Codes Cryptogr. 40 (2006), no. 1, 2539. 11. Clemens Heuberger and Sara Kropf, Analysis of the binary asymmetric joint sparse form, Combin. Probab. Comput. 23 (2014), 10871113. 12. Clemens Heuberger, Sara Kropf, and Helmut Prodinger, Output sum of transducers: Limiting distribution and periodic uctuation, Electron. J. Combin. 22 (2015), no. 2, 153. 13. Hsien-Kuei Hwang, On convergence rates in the central limit theorems for combinatorial structures, European J. Combin. 19 (1998), 329343. 14. Marc Joye and Sung-Ming Yen, Optimal left-to-right binary signed digit recoding, IEEE Trans. Comput. 49 (2000), no. 7, 740748. 15. Peter Kirschenhofer, Subblock occurrences in the 4 (1983), no. 2, 231236. q -ary representation of n, SIAM J. Algebraic Discrete Methods 16. The On-Line Encyclopedia of Integer Sequences, http://oeis.org, 2016. 17. George W. Reitwiesner, Binary arithmetic, Advances in Computers, Vol. 1, Academic Press, New York, 1960, pp. 231308. 18. Neil J. A. Sloane, The number of ON cells in cellular automata, arXiv:1503.01168 [math.CO]. 19. Jörg M. Thuswaldner, Summatory functions of digital sums occurring in cryptography, Period. Math. Hungar. 38 (1999), no. 1-2, 111130. Institut für Mathematik, Alpen-Adria-Universität Klagenfurt, Austria, and Institute of Statistical Science, Academia Sinica, Taipei, Taiwan E-mail address : sara.kropf@aau.at and sarakropf@stat.sinica.edu.tw Department of Mathematical Sciences, Stellenbosch University, South Africa E-mail address : swagner@sun.ac.za