On the minimal Hamming weight of a multi-base representation

Given a finite set of bases $b_1$, $b_2$, \dots, $b_r$ (integers greater than $1$), a multi-base representation of an integer~$n$ is a sum with summands $db_1^{\alpha_1}b_2^{\alpha_2} \cdots b_r^{\alpha_r}$, where the $\alpha_j$ are nonnegative integers and the digits $d$ are taken from a fixed finite set. We consider multi-base representations with at least two bases that are multiplicatively independent. Our main result states that the order of magnitude of the minimal Hamming weight of an integer~$n$, i.e., the minimal number of nonzero summands in a representation of~$n$, is $\log n / (\log \log n)$. This is independent of the number of bases, the bases themselves, and the digit set. For the proof, the existing upper bound for prime bases is generalized to multiplicatively independent bases, for the required analysis of the natural greedy algorithm, an auxiliary result in Diophantine approximation is derived. The lower bound follows by a counting argument and alternatively by using communication complexity, thereby improving the existing bounds and closing the gap in the order of magnitude. This implies also that the greedy algorithm terminates after $\mathcal{O}(\log n/\log \log n)$ steps, and that this bound is sharp.

For simplicity, we make the natural assumption that every positive integer has at least one such representation, which implies in particular that 1 ∈ D. We will also assume that the bases b 1 , b 2 , . . . , b r are multiplicatively independent, i.e., the only integers α 1 , α 2 , . . . , α r for which b α 1 1 b α 2 2 · · · b αr r = 1 are α 1 = α 2 = · · · = α r = 0. Intuitively, this means that there is no "redundancy" in the set of bases.
1.2. Notes on the set-up. The set-up for multi-base representations that we described is quite standard (except possibly for the multiplicative independence). However, our proofs still apply with the following modifications: • All digits d B in the multi-base representations ( ) of n are assumed to be in O(log n) (in contrast to a finite, nonnegative digit set). • All exponents α j in the multi-base representations ( ) of n are assumed to be in O(log n). This is essentially trivial if all digits are nonnegative (see Section 1.7), but we can also allow negative digits if this additional assumption is imposed. • At least two of the bases are assumed to be multiplicative independent (in contrast to the entire set being multiplicatively independent).

Hamming weight.
Of course, only finitely many terms of the sum ( ) can be nonzero. The number of these terms is called the Hamming weight of a representation. The Hamming weight is a measure of how efficient a certain representation is. A multi-base representation of an integer n is called minimal if it minimizes the Hamming weight among all multi-base representations of n with the same bases and digit set. An overview on previous works concerning the Hamming weight of multi-base representations will follow in Sections 1.6 to 1.9. At this point, we only mention that the Hamming weight of single-base representations has been thoroughly studied (see Section 1.9), not only in the case of the standard set {0, 1, . . . , b − 1} of digits, but also for more general types of digit sets. Both the worst case (maximum) and the average order of magnitude of the Hamming weight are log n.

Main result.
In this short note, we investigate the Hamming weight of multi-base representations and find that the Hamming weight can be reduced-even in the worst case-by using multi-base representations. However, the reduction compared to single-base representations is fairly small. Perhaps surprisingly, the order of magnitude is independent of the number r of bases (provided only that r ≥ 2), the set of bases and the set of digits: it is always log n log log n . The precise statement is as follows. Theorem 1. Suppose that r ≥ 2, and that the multiplicatively independent bases b 1 , b 2 , . . . , b r and the digit set D are such that every positive integer n has a representation of the form ( ). There exist two positive constants K 1 and K 2 (depending on b 1 , b 2 , . . . , b r and D) such that the following hold: (U) For all integers n > 2, there exists a representation of the form ( ) with Hamming weight at most K 1 log n log log n . (L) For infinitely many positive integers n, there is no representation of the form ( ) whose Hamming weight is less than K 2 log n log log n . The upper bound of this theorem needs weaker assumptions on the bases than the result of Dimitrov, Jullien and Miller [12]: They require that all the bases b 1 , . . . , b r are primes, 1 whereas we only need that (two of) the bases are multiplicatively independent. The order of 1 The proof of the bound in [12] is carried out for double-base representations with bases 2 and 3, and it is stated that it generalizes to sets of bases being finite sets of primes. magnitude of both bounds coincides. We will prove the bound (U) for our general multi-base set-up in Section 2 by analyzing the Greedy algorithm.
The best known lower bound 2 for the minimal Hamming weight seems to be of order log n log log n · log log log n (see Dimitrov and Howe [11]) for double-base representations with bases 2 and 3. Yu, Wang, Li and Tian [30] extend this result to triple-base representations with bases 2, 3 and 5. Our lower bound (L) closes the gap to the upper bound in the order by getting rid of the factor log log log n in the denominator. We show this result in Section 3 by a counting argument and in Section 4 by using communication complexity.

Background on multi-base representations.
Motivation for studying multi-base representations comes from fast and efficient arithmetical operations. One particular starting point is [12], where double-base and multi-base representations are used for modular exponentiation. Beside many other references, [2,10,13] describe the usage of double-base systems for cryptographic applications; the typical bases used are 2 and 3. Questions such as: does every integer have a multi-base representation, or: what is the smallest number that cannot be represented in a certain system, are also of great interest; cf. [4,5,6,19]. The number of multi-base representations has also been analyzed; see [17,18].
1.6. Greedy algorithm. Let us come back to multi-base representations in this work's set-up. The natural greedy algorithm finds a multi-base representation of a nonnegative integer n successively by • adding the largest power-product B ∈ B less than or equal to n to the representation, and • continuing in the same manner with n − B.
The greedy algorithm does not produce a minimal representation in general. For instance, for double-base representations with bases 2 and 3, the smallest counter-example is The upper bound for the minimal Hamming weight is derived by Dimitrov, Jullien and Miller [12] by analyzing the greedy algorithm (as mentioned for prime bases). This is also our approach in this paper. Our result translates to the following corollary, which is a direct consequence of the proof and the statement of Theorem 1.

Corollary 2.
Suppose that r ≥ 2, and that the multiplicatively independent bases b 1 , b 2 , . . . , b r and the digit set D are such that every positive integer n has a representation of the form ( ). Then, the natural greedy algorithm with input n terminates after O log n log log n steps, and this bound is sharp. The output is a representation containing only digits 0 and 1.
Note that this corollary is valid if the greedy algorithm is suitably preprocessed. To make this more precise, the algorithm needs representations with only digits 0 and 1 for all numbers from 0 to some N 0 . This N 0 is to be found in the proof of Theorem 1, part (U); it might actually be huge (if it can even be calculated with reasonable effort). On the other hand, relaxing the condition on the digits being only 0 and 1 for the numbers up to N 0 also suffices for the validity of Corollary 2.
Yu, Wang, Li and Tian [30] use the proof of the O log n log log n bound of [12] for double-base representations with bases 2 and 3 to show the same bound for triple-base representations with bases 2, 3 and 5.
It is already mentioned in [12] that their upper bound of the Hamming weight of the representations obtained by the greedy algorithm is best possible. Such a lower bound is also derived in [8].
1.7. Lower bounds. Clearly, the minimal Hamming weight of integers n ∈ B is 1. So a goal related to lower bounds is to find sequences of integers with large minimal Hamming weight.
As mentioned, Dimitrov and Howe [11] and Yu, Wang, Li and Tian [30] state the existence of a constant K 2 and the existence of infinitely many integers n whose minimal Hamming weight is greater than K 2 log n log log n · log log log n for representations with bases 2 and 3, and bases 2, 3 and 5, respectively.

Distribution of the Hamming weight.
Beside the minimal Hamming weight of an integer n, the expected Hamming weight of a random multi-base representation of n and more generally the distribution of the Hamming weight of all representations of n have been studied. In [17,18], an asymptotic formula of the form K(log n) r + O (log n) r−1 log log n for the expected Hamming weight of a random representation of an integer n is derived with explicit constant K; see [18,Theorem IV]. The order of magnitude (log n) r of this result depends, in contrast to the minimal Hamming weight, on the number r of bases. Moreover, it is shown in [17,18] that the Hamming weight asymptotically follows a Gaussian distribution, and an asymptotic expression for the variance is provided as well. Papers [16] and [24] provide a way to compute minimal representations. The minimal Hamming weight of different kinds of single-base representations is studied in [9,22,23,26,27]. One particular representation, which often is minimal, is the so-called non-adjacent form (cf. [25,15]); it uses a signed digit set, i.e., a digit set containing also negative integers. Grabner and Heuberger [14] count representations with minimal Hamming weight for such a signed digit set.

The upper bound
The proof of the first statement of Theorem 1 follows from an analysis of the natural greedy algorithm and is based on some results from Diophantine approximation.
The following lemma is the statement corresponding to the result of Tijdeman [28] on which the analysis of Dimitrov, Jullien and Miller in [12] is based on.

Lemma 3.
There are positive constants C and κ with the following property: for every integer n > 1, there is an element B ∈ B such that Proof. It clearly suffices to prove the statement in the case where r = 2; let us use the abbreviations p = b 1 , q = b 2 , and set λ = log p q. Since p and q are multiplicatively independent, λ is irrational, which will be crucial for us.
Let {x} = x − x denote the fractional part of a real number x. As a first step, we consider the sequence Λ M = ({λm}) M −1 m=0 and show that its "gaps" (intervals that do not contain a value of Λ M ) can be bounded in terms of M . The structure of these gaps is in fact very well understood (see [1]), but we only require an upper bound.
Recall that the discrepancy of Λ M is given by The fact that the irrationality measure γ is in fact finite in our case, where λ = log p q, is a simple consequence of Baker's theory of linear forms in logarithms; see [3] for a general reference. Bugeaud [7] even provides explicit bounds for this specific case. Note that if {log p n} ≤ C 1 M −κ , we may simply choose m = 0. Since λm ≤ λ(M − 1) ≤ log p q log q n = log p n, it follows that there is a nonnegative integer such that which is equivalent to This in turn implies that there exist nonnegative and m such that where C = (C 1 log p)(log q) κ . This proves the lemma. Now we are ready to prove statement (U) of Theorem 1.
Proof of Theorem 1, part (U). Take C and κ as in the lemma, and note that log(Cn/(log n) κ ) log log(Cn/(log n) κ ) = log n log log n − κ + O 1 log log n .
Let N 0 be large enough so that C/(log n) κ < 1 2 as well as log(Cn/(log n) κ ) log log(Cn/(log n) κ ) ≤ log n log log n − κ 2 (1) for all n > N 0 . Moreover, choose a constant K 1 ≥ 2 κ sufficiently large so that every positive integer n ∈ {3, 4, . . . , N 0 } has a representation of the form ( ) of Hamming weight at most min K 1 log n log log n , K 1 log N 0 log log N 0 . Now it follows by induction that in fact every integer n > 2 has a representation whose Hamming weight is at most K 1 log n log log n . For n ≤ N 0 , this holds by our choice of N 0 and K 1 . For n > N 0 , Lemma 3 guarantees the existence of an element B ∈ B for which The number n − B therefore has a representation whose Hamming weight is at most because of (1). Since n − B ≤ Cn/(log n) κ < n 2 , we must have n − B < B, so the element B does not occur in the representation of n − B (i.e., its coefficient d B is zero). So we can add B to the representation of n − B to obtain a multi-base representation of the form ( ) whose Hamming weight is at most K 1 log n log log n . This completes the induction and thus the proof of the desired upper bound.

The lower bound
The second statement (L) of Theorem 1 is proven by means of a simple counting argument. We will use the assumptions made in Section 1.2. Multiplicative independence is not actually required, though.
Note first that in any representation of the form with nonnegative d B ∈ D, a digit d B can only be nonzero if B ≤ n. The number B, on the other hand, can be represented as for some nonnegative integers α 1 , α 2 , . . . , α r by definition. We must have as N → ∞. The number R K (N ) of representations using only the power-products in B N and having Hamming weight at most K is bounded above by since we have at most T (N ) k choices for those B ∈ B N with nonzero digits d B , and at most (|D| − 1) k choices for the digits. A crude estimate gives us, at least for K ≤ T (N )/2, We claim that for every positive constant K 2 < 1 r , the following holds: for all sufficiently large positive integers s, there is an integer n ∈ {2 s−1 + 1, 2 s−1 + 2, . . . , 2 s } without a representation whose Hamming weight is less than K 2 log n log log n . This implies that there are infinitely many values of positive integers n for which there is no representation whose Hamming weight is less than or equal to K 2 log n log log n , completing the proof. To prove the claim, suppose all integers in the set {2 s−1 + 1, 2 s−1 + 2, . . . , 2 s } have a representation whose Hamming weight is at most K. Then we must have Taking logarithms yields for sufficiently large s. The claim follows.

From the point of view of communication complexity
In this section, we will provide an alternative proof based on communication complexity, to show that the upper bound obtained in Section 2 is asymptotically tight; i.e., we prove (L) of Theorem 1.
As mentioned, we use communication complexity to prove the statement. Consider the situation where Alice and Bob both hold bits of information (or equivalently a nonnegative integer less than 2 ), denoted by the messages m Alice and m Bob . Bob wants to check if they hold the same information. To do that, Alice can send some message (according to some protocol) to Bob. Every time Bob got a bit of information from Alice, he can announce "equal" if he is sure that m Alice = m Bob , "not equal" when he is sure that m Alice = m Bob , or "more information" to request more information on m Alice from Alice. Alice wants to minimize the number of bits that she sends to Bob; see Yao [29].
It is known that, when Alice uses any deterministic algorithm/protocol, there always exist messages m Alice and m Bob such that the number of communication bits is at least ; see Kushilevitz [21].
For the proof below, we will use the assumptions made in Section 1.2, but again we do not require multiplicative independence.
Proof of Theorem 1, part (L). We assume for contradiction that for each n, there exists a multi-base representation with only o log n log log n summands. Set = log n . Let m Alice and m Bob be -bit messages so that bits need to be communicated in order to determine equality. Now, suppose that Alice converts the -bit message m Alice to a multi-base representation with o log n log log n summands. Since all exponents are in O(log n) and the number r of bases is fixed, each summand of a multi-base representation can be denoted by O(log log n) bits. Therefore, Alice can tell Bob the whole message m A by only O(log log n) · o log n log log n = o(log n) bits; a contradiction.