Analysis of carries in signed digit expansions
 719 Downloads
Abstract
The number of positive and negative carries in the addition of two independent random signed digit expansions of given length is analyzed asymptotically for the (q, d)system and the symmetric signed digit expansion. The results include expectation, variance, covariance between the positive and negative carries and a central limit theorem. Dependencies between the digits require determining suitable transition probabilities to obtain equidistribution on all expansions of given length. A general procedure is described to obtain such transition probabilities for arbitrary regular languages. The number of iterations in von Neumann’s parallel addition method for the symmetric signed digit expansion is also analyzed, again including expectation, variance and convergence to a double exponential limiting distribution. This analysis is carried out in a general framework for sequences of generating functions.
Keywords
Carry Central limit theorem Transducer Probabilistic automaton Symmetric signed digit expansion Von Neumann’s additionMathematics Subject Classification
11A63 60C05 60F05 68Q45 68W401 Introduction
Addition is an essential arithmetic operation in many algorithms. As the efficiency of addition is influenced by the number of occurring carries, we asymptotically analyze this number, which depends on the base and the digit set of the digit expansion.
We consider two different types of digit expansions: On the one hand, we investigate (q, d)expansions, that are extensions of the standard qary digit expansion with digit set \(\{d,\ldots ,q+d1\}\). With \(d=0\), this includes the case of the standard qary expansion. Consecutive digits are independent in this case. On the other hand, the symmetric signed digit expansion [6] has an even base q and the redundant digit set \(\{q/2,\ldots ,q/2\}\). To remove the redundancy, there is a syntactical rule to decide which of the digits \(q/2\) and q / 2 is used. This rule introduces dependencies between consecutive digits.
Example for standard addition in the decimal system
In the case of positive and negative digits, positive and negative carries occur. The parameter of interest is their number for an independent pair of random summands of given length.
Example for von Neumann’s addition in the decimal system
The number of iterations of von Neumann’s addition is of interest as it corresponds to the running time.
Diaconis and Fulman [1] and Nakano and Sadahiro [9] consider the carries of the standard addition as a Markov chain. This is only valid if the digits of the digit expansion are independent. In their analysis, they obtain a stationary distribution. In this article, we determine the expectation, variance and central limit theorem for the number of positive and negative carries as well as the covariance between the positive and negative carries in the (q, d)system and the symmetric signed digit system. The authors of [1] concentrate on an odd basis q and the symmetric digit set \(\{(q1)/2,\ldots ,(q1)/2\}\). The symmetric signed digit expansion (defined later) is the natural way to define a unique representation with a symmetric set of digits and an even base q. Thus, a part of the present paper can be seen as a complement of [1].
The expected number of iterations of von Neumann’s addition was analyzed in [8] and [7] for standard qary expansions and (q, d)expansions, respectively. It turns out that the expected number of iterations is logarithmic in the length of the expansions. In [7], symmetric signed digit expansions are analyzed, too, but with a simplified probabilistic model since a precise probabilistic model exceeded computing resources available at that time. This simplification has a significant influence on the main term. In this paper, we combine advances in soft and hardware with sophisticated use of the finite state machine package of SageMath [13] to tackle the precise model in roughly 10 minutes of CPU time. The results include expectation, variance and convergence to a double exponential distribution.
The outline of the paper is as follows. In Sect. 2, we define (q, d)expansions and symmetric signed digit expansions. We first analyze the standard addition in Sects. 3–5. The algorithms and the corresponding transducers for the standard addition of (q, d)expansions and symmetric signed digit expansions are presented in Sect. 3. Our probabilistic model is to choose both summands of length \(\ell \) independently such that each expansion of length \(\ell \) is equally likely. In the case of the symmetric signed digit expansions, the dependencies between the digits require approximating the equidistribution with an error that does not influence the final result. The corresponding probabilities are defined in Lemma 4.1 in Sect. 4 for general regular languages, see also [10, 14]. In Sect. 5, we combine this approximate equidistribution with the transducers from Sect. 3.2 to obtain an asymptotic analysis including the expectation, the variance and asymptotic normality in the main Theorems 1 and 2 for the (q, d)system and the symmetric signed digit system, respectively.
Then, we analyze von Neumann’s addition. We start in Sect. 6 with the algorithms and the automaton. Theorem 3 provides a general framework for the analysis of sequences occurring in this context. Then we again use the approximate equidistribution from Sect. 4 to asymptotically analyze the number of iterations of von Neumann’s addition in Theorem 4 in Sect. 7. This analysis extends the results in [7, 8] to the symmetric signed digit expansions and to include not only the expected value but also the variance and a convergence in distribution.
Obtaining the values of the constants occuring in the asymptotic analysis of standard and von Neumann’s addition requires computations involving finite state machines and determinants of matrices in several variables. These computations are performed using the mathematical software system SageMath [13]. Notebooks containing all the computations can be found at [4]. However, the existence of these constants follows from the theoretical results.
2 Digit expansions
In this section, we define the digit expansions which will be used in later sections. We also recall their properties.
2.1 (q, d)expansions
Definition 2.1
Let \(q<d\le 0\) be two integers with \(q\ge 2\). The (q, d)expansion of an integer x is the qary expansion \((x_{\ell }\ldots x_{0})_{q}\) with digits \(x_{i}\in \{d,\ldots , q+d1\}\) such that \(x=\sum _{i=0}^{\ell }x_{i}q^{i}\).
Example 2.2
The \((4,1)\)expansion of 3 is \((1\bar{1})_{4}\), where we write \(\bar{1}\) for the digit \(1\).
The (q, d)expansion exists for all integers if \(d\ne 0\) and \(d\ne q+1\). For \(d=0\) (this is the standard qary expansion), only the nonnegative integers have a (q, d)expansion. Conversely, for \(d=q+1\), only the nonpositive integers have a (q, d)expansion. If the (q, d)expansion of an integer exists, then it is unique up to leading zeros.
If q is odd and \(d=\frac{q+1}{2}\), then the (q, d)expansion minimizes the sum of absolute values of the digits among all qary expansions with arbitrary digits (see [6]).
2.2 Symmetric signed digit expansion
We recall the definition of the symmetric signed digit expansion (SSDE) as defined in [6] and further analyzed in [7].
Definition 2.3
In [6], it is shown that each integer n has a unique SSDE (up to leading zeros). It minimizes the sum of absolute values of the digits among all qary expansions of n with arbitrary digits (cf. [6]).
For \(q=2\), we obtain the digit set \(\{0,\pm 1\}\) and the syntactical rule that at least one of any two adjacent digits is zero. This digit expansion is also called nonadjacent form (cf. [12]).
3 Standard addition
We write bold face letters for sequences which are padded with zeros on the left.
We will mostly use this point of view. Most of the algorithms and transducers require the input of \(\varvec{s}\). If there are syntactical rules for \(\varvec{x}\) and \(\varvec{y}\), then the sequence \(\varvec{s}\) can not be arbitrary.
Remark 3.1
From this point of view, it is clear that interchanging two digits \(x_{i}\) and \(y_{i}\) of the two summands does not influence the result, but only both summands. The carries, the digitwise sum and the steps taken by the algorithms and the transducers stay the same as they depend only on the digitwise sum.
3.1 Algorithms
3.1.1 Standard addition for (q, d)expansions
The digit set is \(D=\{d,\ldots , q+d1\}\). Algorithm 1 transforms a qary expansion with digit set \(D+D\) into a (q, d)expansion. As there are no syntactical rules, all digits are independent. Thus, we do not have to look ahead when choosing the carry.
Example for standard addition for \((5,1)\)expansions
3.1.2 Standard addition for SSDEs
Let \(q\ge 2\) be even. Algorithm 2 transforms a qary expansion with digit set \(\{q,\ldots ,q\}\) into a SSDE. As the choice between the redundant digits \(\frac{q}{2}\) and \(\frac{q}{2}\) depends on the next digit, we have to look ahead at the next digit in these cases. This algorithm is an extension of the one in [7] taking into account that we start with a larger digit set.
Example for standard addition for SSDEs for \(q=4\)
3.2 Transducers
In this section, we present the transducers for the algorithms presented in the last section.
We are not interested in the output of the addition, but only in the carries. Thus we only use the carries as the output of the transducer. But, if required, the output digits can easily be reconstructed.
In our setting, a transducer consists of a finite set of states S, a finite input alphabet \(D+D\), an output alphabet, a set of transitions \(E\subseteq S^{2}\times (D+D)\) with input labels in \(D+D\), output labels in the output alphabet for each transition, and an initial state. All states are final.
The input of the transducer is a digit expansion with digits in \(D+D\). The output of the transducer is the sequence of labels of a path starting in the initial state with the given input as the input label. In our cases, always exists such a path and it is unique (i.e., the transducer is complete and deterministic).
The labels of the states encode the current carry (except for the situations when we have to look ahead). The number of states is independent of q. The number of transitions between two states depends on the base q.
To plot the transducer, we group these transitions and their labels. We draw only one arc and write the label \(M\mid c\) for a set \(M\subset D+D\) to represent a group of transitions consisting of one transition with input label m and output label c for every \(m\in M\). If M is the empty set, then there are no such transitions. This may happen for special values of d or q.
The output label of a transition is one carry c, a pair of carries c, or no carry c, i.e., \(c\in \{0,1,\bar{1},\}\cup \{0,1,\bar{1}\}^{2}\), where “−” denotes the empty output. The input of the transducer is the sequence \(\varvec{s}\) of digitwise sums.
3.2.1 Standard addition for (q, d)expansions
The transducer in Fig. 1 computes the carries as in Algorithm 1. We use the sets \(L=\{2d,\ldots ,d1\}\), \(D=\{d,\ldots ,q+d1\}\) and \(H=\{q+d,\ldots ,2q+2d2\}\).
3.2.2 Standard addition for SSDEs
The transducer in Fig. 2 computes the carries as in Algorithm 2. We use the sets \(L=\{0,\ldots ,\frac{q}{2}1\}\), \(H=\{\frac{q}{2}+1,\ldots ,q\}\) and \(H_{q}=\{\frac{q}{2},\ldots ,q1\}\).
The transitions are constructed by using Algorithm 2 for the current input and carry.
4 Approximate equidistribution
As a probabilistic input model, we want to use an equidistribution on all digit expansions satisfying certain syntactical rules. This is easy in the case of (q, d)expansions (see Sect. 4.1) because there are no syntactical rules. But in the case of a general regular language, like the SSDE, we can only approximate an equidistribution by Lemma 4.1. However, this approximation does not influence the main terms of the results.
A regular language is recognized by an automaton. An automaton is defined to consist of states, transitions between these states with labels, an initial state and final states. So to say, it is a transducer without output. The automaton recognizes a word from a language, if there exists a path starting at the initial state, leading to a final state with this word as the label.
We call an automaton aperiodic if its underlying directed graph is aperiodic, i.e., the greatest common divisor of all lengths of directed cycles of the graph is 1. If the underlying directed graph is strongly connected, then the automaton is so, too. If an automaton is strongly connected and aperiodic, then the adjacency matrix of the underlying graph is primitive.
Given an automaton \(\mathcal {A}\) for a regular language, we automatically construct transition probabilities between the states to obtain an approximate equidistribution on all words of given length \(\ell \). The weight of the word is the product of the transition probabilities multiplied with an exit weight [the factor in front of the product in (2) below]. This corresponds to an approximate equidistribution on all paths of length \(\ell \) of the underlying graph of the automaton starting in the initial state. Without the exit weights, these transition probabilities are the same as defined by Shannon in [14] and Parry in [10]. We implemented the computations of this lemma as part of SageMath [13] as Automaton.shannon_parry_markov_chain.
Lemma 4.1
Let \(\mathcal {A}\) be a deterministic automaton with set of states \(\{1,\ldots , n\}\), initial state 1, final states \(\emptyset \ne F\subseteq \{1,\ldots , n\}\) recognizing a regular language \(\mathcal {L}\). We assume that the adjacency matrix A of the underlying graph of \(\mathcal {A}\) is primitive.
The dominant eigenvalue of A is denoted by \(\lambda \), all other eigenvalues of A are assumed to be of modulus less than or equal to \(\xi \lambda \) for some \(0<\xi <1\). If there are eigenvalues of modulus \(\xi \lambda \), then each of them must be semisimple, i.e., its algebraic and geometric multiplicities coincide.
Let \(w>0\) and \(u>0\) be right and left eigenvectors of A for the eigenvalue \(\lambda \), respectively, such that \(w_1=1\) and \(\langle u,w\rangle =1\).
For large \(\ell \) and a transition t from some state i to some state j, \(p_t\) can be thought as the probability of using t under the condition that the automaton is currently in state i. Note that the sum in (3) runs over all transitions leaving i such that multiple transitions between i and j are counted separately although their individual weights \(p_t\) only depend on i and j. It turns out that the exit weights do not influence the main term of our asymptotic expressions.
Proof of Lemma 4.1
The weight \(W_{\ell }\) induces a measure on the words of length \(\ell \). The total measure of all words of length \(\ell \) is 1 up to an exponentially small error, thus it is a probability measure up to an exponentially small error. Each word has exactly the same weight. If we see the transition probabilities as a part of the automaton, we obtain a probabilistic automaton:
Definition 4.2
4.1 Weights for (q, d)expansions
Remark 4.3
The same weights can be obtained by Lemma 4.1. The transition probabilities are \(p_{0\rightarrow 0}=q^{1}\). As the automaton recognizing (q, d)expansions has only one state (see Fig. 3), there is no error term in (4).
4.2 Weights for SSDEs
5 Asymptotic analysis of the standard addition
In this section, we use the probabilistic model defined in Sect. 4 for the input sequence of the transducers in Sect. 3.2. Then we will use Lemma 5.1 to obtain expectation, variance and asymptotic normality of the number of carries.
In Sects. 5.1 and 5.2, we will construct probabilistic automata whose transition labels are the carries and where each transition has a weight corresponding to the weight constructed in Sect. 4.
Let m and n be two functions mapping the output of a transition into the real numbers; for brevity we write m(t) and n(t) without mentioning the output label of the transition t. In our setting m will count the number of carries 1, and n the number of carries \(1\) of the output of a transition. We consider the two random variables \(M_{\ell }\) and \(N_{\ell }\) which are the sum of the values of m and n, respectively, over a path of length \(\ell \) with probability the product of the weights of this path multiplied with the exit weight.
We will use multivariate generating functions in three variables x, y and z. The variables x and y mark the number of carries 1 and \(1\), respectively, and the variable z marks the length of the expansion.
The next lemma is a slight modification of [5, Theorem 3.9] taking into account the nonuniform distribution of the input alphabet.
Lemma 5.1
Let \(\mathcal A\) be a strongly connected, aperiodic probabilistic automaton where all states are final. Let m and n be functions mapping the output of a transition into the real numbers and A(x, y) be the associated transition matrix of the automaton, where x and y mark m and n, respectively. Let \(M_\ell \) and \(N_\ell \) be the associated random variables as defined above.
Proof
5.1 Standard addition for (q, d)expansions
To construct the probabilistic automaton, we start with the transducer in Fig. 1, and use the weights from Sect. 4.1.
All steps in this section, including the computation of the constants in Theorem 1, can be done in the mathematical software system SageMath [13] by using the included finite state machine package described in [3]. The corresponding SageMath file is available at [4].
The construction in this section is more general than needed for the case of independent digits as in (q, d)expansions. But discussing it here in full generality allows reusing the same ideas for the case of dependent digits as in SSDEs later on. We will use the same construction for SSDEs in Sects. 5.2 and 7.

The states of \(\mathcal {A}^{2}\) are pairs of states of \(\mathcal {A}\).

There is a transition from (a, b) to (c, d) with label \(x+y\) in \(\mathcal {A}^{2}\) if there are transitions from a to c with label x and b to d with label y in \(\mathcal {A}\).

The weight of a transition in \(\mathcal {A}^{2}\) is the product of the weights of the two transitions in \(\mathcal {A}\).

The exit weight of a state in \(\mathcal {A}^{2}\) is the product of the exit weights of the two states in \(\mathcal {A}\).

The states of \(\mathcal {S}_{(q,d)}\) are pairs of states of \(\mathcal {B}\) and \(\mathcal {A}^{2}\).

For each pair of transitions from a to c with input label s and output label k in \(\mathcal {B}\) and from b to d with weight w and label s in \(\mathcal {A}^{2}\), there is a transition from (a, b) to (c, d) with weight w and label k in \(\mathcal {S}_{(q,d)}\).

The exit weight of a state in \(\mathcal {S}_{(q,d)}\) is the exit weight of the corresponding state in \(\mathcal {A}^{2}\).
To determine the transition matrix of \(\mathcal {S}_{(q,d)}\), we use the following lemma to compute the number of transitions between two states. The lemma is proved by an inclusionexclusion argument.
Lemma 5.2
With the transition matrix, the next theorem follows directly from Lemma 5.1.
Theorem 1
In Fig. 5, variances and covariance for (10, d)expansions are shown.
Remark 5.3
5.2 Standard addition for SSDEs
To cope with the dependencies between the digits, we have to combine the conditional probabilities of the automaton in Fig. 4 with the carries computed by the automaton in Fig. 2. This is done in the same way as in Sect. 5.1.
All steps in this section, including the computation of the constants in Theorem 2, can be done in the mathematical software system SageMath [13] by using its included finite state machine package described in [3]. The corresponding SageMath file is available at [4].
In this section, let \(\mathcal {A}\) be the automaton in Fig. 4 equipped with the weights in (6) and let \(\mathcal {B}\) be the transducer in Fig. 2 performing the standard addition of two SSDEs.
We first construct the additive Cartesian product \(\mathcal {A}^{2}\), recognizing all possible sequences \(\varvec{s}\) of digitwise sums with the correct weights approximating the equidistribution on two independent SSDEs \(\varvec{x}\) and \(\varvec{y}\). This probabilistic automaton has 9 states.
Next, we construct \(\mathcal {S}_{\text {SSDE}}\) as the composition \(\mathcal {B}\circ \mathcal {A}^{2}\). This probabilistic automaton recognizes the sequence of carries \(\varvec{c}\) with the correct weights approximating the equidistribution on two independent SSDEs \(\varvec{x}\) and \(\varvec{y}\). This gives a transducer with 45 states.
Because of symmetries (cf. Remark 3.1), we can simplify \(\mathcal {S}_{\text {SSDE}}\) such that it has only 14 states^{2}:
Lemma 5.4

If between two states, there are two transitions with the same label, then these two transitions can be combined. The weights are summed up in this process.

Let \(\{C_{1},\ldots ,C_{k}\}\) be a partition of the states of the automaton with the following property: If a, \(b\in C_{j}\) are two states, then there is a bijection between the transitions leaving a and the ones leaving b which preserves the label, the weight of the transition and into which set of the partition the transitions lead. These bijections define an equivalence relation on the transitions leaving a set of the partition. Then each set of the partition can be contracted to a new state. For each equivalence class of transitions, there is one transition in the simplified transducer.
Thus, we obtain a \(14\times 14\) transition matrix of \(\mathcal {S}_{\text {SSDE}}\) given in Table 7 in the appendix (using Lemma 5.2).
Theorem 2
In Fig. 6, variance and covariance for SSDEs are shown.
Proof
We can compute the determinant \(f(x,y,z)=\det (IzA(x,y))\) of the transition matrix A(x, y) in the appendix of the simplified automaton \(\mathcal {S}_{\text {SSDE}}\) with 14 states. Thus, Lemma 5.1 implies the expected value, the variance and the central limit theorem where the input sequence is the sum of two independent SSDEs of length \(\ell \) with the approximate equidistribution \(W_{\ell }\).
As the (exact) equidistribution \(\mathbb P_{\ell }\) satisfies \(\mathbb P_{\ell }=(1+\mathcal {O}(\xi ^{\ell }))W_{\ell }\), these results also hold for the (exact) equidistribution. \(\square \)
Remark 5.5
6 Von Neumann’s addition
As before, we choose an approximate equidistribution for all independent pairs of SSDEs of length \(\ell \) as our probabilistic input model. In contrast to the result in [7], we obtain more natural constants occurring in the main term of the expectation and the variance.
For von Neumann’s addition of two standard qary digit expansions, the number of iterations depends on the longest subsequence \((q1)\ldots (q1)j\) with \(j\ge q\) of the digitwise sum \(\varvec{s}\), see [8]. Such sequences can be found by an automaton with two classes of transitions (see Fig. 7 and [7, Figure 1]). One class corresponds to the digit \((q1)\) of a carry generating sequence and is depicted by solid lines. The other class corresponds to all other digits (including the digit j of a carry generating sequence) and is depicted by dotted lines. The longest consecutive run of solid edges in the automaton in Fig. 7 corresponds to the number of iterations of von Neumann’s addition minus 2. The asymptotic analysis of these longest runs can be performed using the probabilistic version of the automaton in Fig. 7. We will extend this approach to SSDEs with arbitrary even base using a larger probabilistic automaton in Sect. 7.
6.1 Algorithm
Example for von Neumann’s addition for SSDEs with \(q=4\)
Let \(\varvec{x}\) and \(\varvec{y}\) be two SSDEs. The idea of the algorithm is to construct the sequence of digitwise sums \(\varvec{s}=\varvec{x}+\varvec{y}\) and correct each position if the number at this position is not in the digit set or at the border of the digit set where we have to take into account the syntactical rule. In Table 5, an example for von Neumann’s addition for SSDEs with \(q=4\) is given.
6.2 Automaton
A description of all SSDEs \(\varvec{x}\) and \(\varvec{y}\) with \(t(\varvec{x},\varvec{y})=k\) is given in [7]. This description is in terms of an automaton and leads to the automaton in [7, Figure 5] reproduced here as Fig. 8. We use the sets \(L=\{0,\ldots ,q/21\}\), \(L_{0}=L\setminus \{0\}\), \(H=\{q/2+1,\ldots , q\}\) and \(H_{q}=H\setminus \{q\}\).
From [7, Theorem 3.4], we know that \(t(\varvec{x},\varvec{y}) \le k+2\) if and only if this automaton traverses at most k consecutive solid transitions when reading \(\varvec{s}\).
Remark 6.1
Strictly speaking, the automaton reads the sequence \((s_{j})_{j\ge 0}\) where \(s_{j}=x_{j}+y_{j}\) for \(j\le J\) and \(s_{j}=0\) for \(j>J\), for some J. However, most of the solid edges are visited while \(j\le J\). All transitions with label 0 lead to state 1. Those from states 2 and 7 are solid edges, all others are dotted. If the transition is in state 2 (or 7) after reading \(s_{J}\), an additional solid edge will be traversed. Thus, we have to specially treat the states 2 and 7.
7 Asymptotic analysis of von Neumann’s addition
For the asymptotic analysis, we combine the automaton in Fig. 8 with the probabilistic model for SSDEs from Sect. 4.2 in the same way as in Sect. 5.2.
All steps in this section, including the computation of the constants in Theorem 4, can be done in the mathematical software system SageMath [13] by using the included finite state machine package described in [3]. The corresponding SageMath file is available at [4].
We again use the automata \(\mathcal A\) and \(\mathcal A^{2}\) described in Sect. 5.2, recognizing SSDEs and the digitwise sum of two SSDEs, respectively. As before, the next step is to construct the Cartesian product \(\mathcal {N}_{\text {SSDE}}\) of the automaton \(\mathcal {B}\) in Fig. 8 and \(\mathcal A^{2}\).
The state (1, (0, 0)) is initial and all states are final.
The next theorem is an extension of Lemma 2.5 in [7] additionally including the variance and convergence in distribution.
Theorem 3
Proof
Parts of the proof of this theorem follow along the same lines as the proof of Lemma 2.5 in [7]. However, we include all steps of the proof for the sake of readability.
Without loss of generality, we can assume \(r_{0}(1)/s_{0}(1)=1\), as otherwise \(w_{\ell k}\) and \(w_{\ell }\) are multiplied by a constant. Let \(0\le k_1\le k_2\le k_3\) denote suitable constants.
Since \(G_{k}\) and G are rational functions, \(G_{k}\) and G can be continued analytically beyond their dominant singularities \(\zeta _{k}\) and 1, respectively. We have \(\lim _{k\rightarrow \infty }{{\mathrm{Res}}}_{z=\zeta _{k}}G_{k}(z)={{\mathrm{Res}}}_{z=1}G(z)=1\). Thus [11, Theorem 1] implies (12) and the limiting distribution.
Theorem 4
Remark 7.1
A similar result for \(q\ge 4\) was obtained in [7] using the same probabilistic model as in Remark 5.5. This changes the main term of the expected value. In [7], the logarithm of the main term was taken to the base \(\alpha ^{1}\) with \(\alpha =q^{1}q^{4}+\mathcal {O}(q^{5})\). In contrast, we here obtain the logarithm of the main term in (22) to the base q, which is a more natural constant appearing in this context.
For \(q=2\), this result is contained in [7].
Proof
Let \(\mathbb P_{\ell }\) be the (exact) equidistribution of all SSDE of length \(\ell \). For \(k>\ell +2\), we know that \(\mathbb P_{\ell }(t(\varvec{X}, \varvec{Y})\le k)=1\) because an input sequence of length \(\ell \) traverses at most \(\ell \) solid edges in the automaton in Fig. 8.
If we use the approximate equidistribution \(W_{\ell }=(1+\mathcal {O}(\xi ^{\ell }))\mathbb P_{\ell }\) of all SSDE of length \(\ell \), an exponentially small error term is introduced. Because of the finite support, this error term does not change the main term of the expectation, the variance and the distribution function. Thus, also the limiting distribution remains the same.
The generating function \(G_{k}(z)\) counts the weighted number of paths in the automaton \(\mathcal {N}_{\text {SSDE}}\) of the pattern \(\ldots \mathcal B^{+}\mathcal R^{\{1, k\}}\mathcal B^{+}\mathcal R^{\{1, k\}}\ldots \) where \(\mathcal B^{+}\) is an arbitrary nonempty sequence of dotted transitions and \(\mathcal R^{\{1, k\}}\) is a nonempty sequence of solid transitions of length at most k. The first transition can be a dotted or a solid transition. We stop with either arbitrarily many dotted transitions or at most k solid transitions, where we have to take into account the special situation in states 2 or 7 in the automaton in Fig. 8 (see also Remark 6.1): Because of the solid transition starting in 2 and 7 with label 0, we are not allowed to stop with k solid transitions in state 2 or 7 but only with at most \(k1\) ones.
To find the generating functions for \(\mathcal B^{+}\) and \(\mathcal R^{\{1, k\}}\), we use the transition matrices for the dotted and the solid parts of the automaton \(\mathcal {N}_{\text {SSDE}}\).
Let \(q\ge 6\). The transition matrix R for the solid transitions of automaton \(\mathcal {N}_{\text {SSDE}}\) is a \(12\times 12\) matrix given in Table 9 in the appendix (using Lemma 5.2). The transition matrix B for the dotted transitions of automaton \(\mathcal {N}_{\text {SSDE}}\) is given in Table 10 (using Lemma 5.2). The order of the states is given in (11) and also in Table 8 in the appendix.
For \(q\le 4\), the construction of the generating function \(G_{k}(z)\) is the same, only the matrices R and B and the vectors u and v are slightly different. Nevertheless, (27) including the definitions of all the occurring polynomials is still valid.
By Theorem 3, we obtain the expectation, the variance, the distribution function and the limiting distribution of the nonnegative truncation of \(t(\varvec{x},\varvec{y})2\). From (18) and the monotonicity of \(w_{\ell k}\), we know that \(w_{\ell 2}=w_{\ell 1}=\mathcal {O}(\ell ^{2})\). Therefore, the results transfer to the random variable \(t(\varvec{x}, \varvec{y})\) as stated in the theorem. \(\square \)
Footnotes
 1.
This can also be seen as the composition of a transducer performing digitwise addition (without considering any carries) and the Cartesian product of \(\mathcal {A}\) with itself. This corresponds to the SageMath methods transducers.add and Transducer.cartesian_product , respectively. The composition can be computed by the SageMath method Transducer.composition .
 2.
For the actual computation, it is more efficient to already simplify \(\mathcal {A}^{2}\) by the SageMath method FiniteStateMachine.markov_chain_simplification , such that it only has 6 states.
 3.
It is also possible to use \(R^{\{1,k\}}(z)=zR+\cdots +z^{k}R^{k}=(Iz^{k+1}R^{k+1})(IzR)^{1}I\). However, this involves a power of the symbolic matrix R with the symbolic exponent k. This would require a full symbolic eigenvalue decomposition of R. The approach chosen here avoids this by introducing the length restriction on each entry individually.
Notes
Acknowledgments
Open access funding provided by Austrian Science Fund (FWF).
References
 1.Diaconis, P., Fulman, J.: Combinatorics of balanced carries. Adv. Appl. Math. 59, 8–25 (2014)MathSciNetCrossRefzbMATHGoogle Scholar
 2.Flajolet, P., Gourdon, X., Dumas, P.: Mellin transforms and asymptotics: Harmonic sums. Theoret. Comput. Sci. 144, 3–58 (1995)MathSciNetCrossRefzbMATHGoogle Scholar
 3.Heuberger, C., Krenn, D., Kropf, S.: Automata in SageMath–combinatorics meets theoretical computer science. Discrete Math. Theor. Comput. Sci. 18(3), 1–21 (2016)MathSciNetGoogle Scholar
 4.Heuberger, C., Kropf, S., Prodinger, H.: Analysis of carries in signed digit expansions—ancillary files, http://arxiv.org/src/1503.08816/anc (2015)
 5.Heuberger, C., Kropf, S., Wagner, S.: Variances and covariances in the central limit theorem for the output of a transducer. European J. Combin. 49, 167–187 (2015)MathSciNetCrossRefzbMATHGoogle Scholar
 6.Heuberger, C., Prodinger, H.: On minimal expansions in redundant number systems: Algorithms and quantitative analysis. Computing 66, 377–393 (2001)MathSciNetCrossRefzbMATHGoogle Scholar
 7.Heuberger, C., Prodinger, H.: Carry propagation in signed digit representations. European J. Combin. 24, 293–320 (2003)MathSciNetCrossRefzbMATHGoogle Scholar
 8.Knuth, D.E.: The average time for carry propagation. Nederl. Akad. Wetensch. Indag. Math. 40, 238–242 (1978)MathSciNetCrossRefzbMATHGoogle Scholar
 9.Nakano, F., Sadahiro, T.: A generalization of carries processes and Eulerian numbers. Adv. in Appl. Math. 53, 28–43 (2014)MathSciNetCrossRefzbMATHGoogle Scholar
 10.Parry, W.: Intrinsic Markov chains. Trans. Amer. Math. Soc. 112, 55–66 (1964)MathSciNetCrossRefzbMATHGoogle Scholar
 11.Prodinger, H., Wagner, S.: Bootstrapping and doubleexponential limit laws. Discrete Math. Theor. Comput. Sci. 17(1), 123–144 (2015)MathSciNetzbMATHGoogle Scholar
 12.Reitwiesner, G.W.: Binary arithmetic, Advances in Computers, vol. 1, pp. 231–308. Academic Press, New York (1960)Google Scholar
 13.The SageMath Developers: SageMath Mathematics Software (Version 7.0), 2016, http://www.sagemath.org
 14.Shannon, C.E.: A mathematical theory of communication. Bell System Tech. J. 27, 379–423 (1948)MathSciNetCrossRefzbMATHGoogle Scholar
Copyright information
Open AccessThis article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.