Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre...

21
Multidimensional Fibonacci Coding Perathorn Pooksombat, Patanee Udomkavanich, and Wittawat Kositwattanarerk * July 2, 2020 Abstract Fibonacci codes are self-synchronizing variable-length codes that are proven useful for their robustness and compression capability. Asymptotically, these codes provide better compression efficiency as the order of the underlying Fibonacci se- quence increases, but at the price of the increased suffix length. We propose a circumvention to this problem by introducing higher-dimensional Fibonacci codes for integer vectors. In the process, we provide extensive theoretical background and generalize the theorem of Zeckendorf to higher order. As thus, our work unify several variations of Zeckendorf’s theorem while also providing new grounds for its legitimacy. Keywords: Fibonacci code, Zeckendorf’s theorem, prefix code, data compression, Z- module, Gaussian integers 1 Introduction A fundamental idea in data compression is to assign shorter codes to symbols or groups of symbols that appear more often in the source data. This results in what is called variable-length code, and one of the earliest practical compression code is the Huffman codes [20]. This code approaches theoretical compression limit under certain scenarios, and has recently been amended to create Tagged Huffman Codes [27] and End-Tagged Dense Codes [6] to accommodate database search. Popular alternatives to these codes are codes with suffix delimiters, with the most well-known ones being Fibonacci codes. The scheme was introduced by [14] and gener- alized to higher order in [2]. In terms of data compression, Fibonacci codes are optimal under some distributions and can be used as an alternative to Huffman codes [15, 29]. * P. Pooksombat and W. Kositwattanarerk are with the Department of Mathematics, Fac- ulty of Science, Mahidol University, Bangkok 10400, Thailand and the Centre of Excel- lence in Mathematics, the Commission on Higher Education, Bangkok 10400, Thailand (e-mail: [email protected] and [email protected]). P. Udomkavanich is with the De- partment of Mathematics and Computer Science, Faculty of Science, Chulalongkorn University, Bangkok 10330, Thailand (email: [email protected]). The research of W. Kositwattanarerk for this work is supported by the Thailand Research Fund under Research Grant MRG6180192. 1 arXiv:1706.06655v2 [cs.IT] 30 Jun 2020

Transcript of Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre...

Page 1: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Multidimensional Fibonacci Coding

Perathorn Pooksombat, Patanee Udomkavanich, and Wittawat Kositwattanarerk ∗

July 2, 2020

Abstract

Fibonacci codes are self-synchronizing variable-length codes that are provenuseful for their robustness and compression capability. Asymptotically, these codesprovide better compression efficiency as the order of the underlying Fibonacci se-quence increases, but at the price of the increased suffix length. We propose acircumvention to this problem by introducing higher-dimensional Fibonacci codesfor integer vectors. In the process, we provide extensive theoretical backgroundand generalize the theorem of Zeckendorf to higher order. As thus, our work unifyseveral variations of Zeckendorf’s theorem while also providing new grounds for itslegitimacy.

Keywords: Fibonacci code, Zeckendorf’s theorem, prefix code, data compression, Z-module, Gaussian integers

1 Introduction

A fundamental idea in data compression is to assign shorter codes to symbols or groupsof symbols that appear more often in the source data. This results in what is calledvariable-length code, and one of the earliest practical compression code is the Huffmancodes [20]. This code approaches theoretical compression limit under certain scenarios,and has recently been amended to create Tagged Huffman Codes [27] and End-TaggedDense Codes [6] to accommodate database search.

Popular alternatives to these codes are codes with suffix delimiters, with the mostwell-known ones being Fibonacci codes. The scheme was introduced by [14] and gener-alized to higher order in [2]. In terms of data compression, Fibonacci codes are optimalunder some distributions and can be used as an alternative to Huffman codes [15, 29].

∗P. Pooksombat and W. Kositwattanarerk are with the Department of Mathematics, Fac-ulty of Science, Mahidol University, Bangkok 10400, Thailand and the Centre of Excel-lence in Mathematics, the Commission on Higher Education, Bangkok 10400, Thailand (e-mail:[email protected] and [email protected]). P. Udomkavanich is with the De-partment of Mathematics and Computer Science, Faculty of Science, Chulalongkorn University, Bangkok10330, Thailand (email: [email protected]). The research of W. Kositwattanarerk for this work issupported by the Thailand Research Fund under Research Grant MRG6180192.

1

arX

iv:1

706.

0665

5v2

[cs

.IT

] 3

0 Ju

n 20

20

Page 2: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Fibonacci coding is a result of binary numeration system for the integers known as Zeck-endorf representation. This makes Fibonacci codes suitable for integer data, and equipsthem with fast encoding and decoding algorithms [32, 33]. In addition, compared withother variable-length codes for the integers such as logarithmic ramp [13] and Elias codes[12], Fibonacci codes provide much better resistance against insertion and deletion er-rors. Other applications of Fibonacci sequence in information science include the studyof Morse code as a monoid [9, 30] and Wavelet trees [22].

While suffix codes have been shown to offer adjustability to some extent [1], a greatburden for codes with suffix delimiters to bear is its own suffix. Longer suffix gives moreflexibility in the coded data, hence yielding denser codes, but obviously the codewordsnow have to carry longer appendage. In this paper, we introduce Fibonacci coding for asequential string of integers. In the proposed scheme, a constituent of integers is encodedtogether with a single delimiter, thus making Fibonacci codes of higher order more prac-tical.

To generalize Fibonacci codes to the full extent, we reexamine their origin, whichis the theorem of Zeckendorf. This much-celebrated theorem states that every positiveinteger can be written uniquely as

Fi1 + Fi2 + . . .+ Fij

where Fi’s are Fibonacci numbers and i1, i2−i1, . . . , ij−ij−1 ≥ 2. In other words, one mayrepresent a positive integer as sum of nonconsecutive Fibonacci numbers. This theoremhas been generalized and investigated in many directions; similar results can be statedfor negaFibonacci sequence [7, 23], generalized Fibonacci sequence of order k [8, 31], andlinear recurrence sequences [11, 17]. The distribution of the number of terms in a Zeck-endorf decomposition is studied in [5, 24, 26] where a probabilistic approach has recentlybeen applied [3].

Noninteger Fibonacci sequences have been studied mostly on complex numbers [4, 16].In particular, Jordan [21] and Harman [19] consider Fibonacci sequences whose initialterms and indices are Gaussian integers. Other generalizations usually involve an iden-tity whose integer terms yield the classical Fibonacci numbers. For example, Binet’sformula is exploited in [18, 28] where a Fibonacci function is defined over the real andcomplex numbers.

In this paper, we are interested in a generalization of Zeckendorf’s theorem in itspurest form: we consider any mathematical sequences that satisfy the generalized Fi-bonacci recurrence relation and examine elements that can be written as a sum of termsfrom the sequence. As a result, mathematical spaces with minimal structure that meetour requirement are the free Z-modules. Loosely speaking, they are spaces of vectorswith integer components. This choice of spaces allows our generalizations to encompass,for example, integer vectors, arrays, or blocks of integers of fixed length; Gaussian andEisenstein integers; lattices; and the ring Z[α] where α is algebraic.

We summarize the contributions of this paper as follows.

2

Page 3: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

• We introduce the notion of k-equivalent sequences. This approach technically treatselements that can be generated from a Fibonacci sequence as a number systemusing sequence elements as a basis. This key mechanism allows us to manipulatethe “digits” without an explicit knowledge of the underlying Fibonacci sequence.We prove that an element has a Zeckendorf decomposition if and only if it can bewritten as a finite sum (with multiplicities) of sequence elements.

• We provide a sufficient and necessary condition for Zeckendorf’s theorem to holdin a free Z-module. Obviously, the classical Zeckendorf’s theorem can be viewedas a case of our generalization. We also give a sufficient condition that makes therepresentation unique.

• We propose Fibonacci coding for free Z-modules. This is the first work that makespossible native Fibonacci coding for non-integers. Not only that the resulting codesinherit robustness property from the standard Fibonacci codes, they excel in termsof compression efficiency. Natural and explicit encoding and decoding algorithmare also given.

The remainder of this paper is organized as follows. Section 2 sets the definitionsthat will be used throughout the paper. In Section 3, we prove several useful resultsconcerning k-equivalent sequences. Generalizations of Zeckendorf’s theorem are given inSection 4. We establish multidimensional Fibonacci coding and discuss its efficiency inSection 5 and conclude in Section 6.

2 Definitions

We first give a definition for free modules and Fibonacci sequences of higher order. Afree Z-module is a module over Z with a basis. Namely, M is a free Z-module of rank lif it is a group under addition and

M = α1Z⊕ α2Z⊕ . . .⊕ αlZ

for some α1, α2, . . . , αl that are integrally independent, meaning that the only integersolution to the equation n1α1 + n2α2 + . . . + nlαl = 0 is n1 = n2 = . . . = nl = 0. Theelements α1, α2, . . . , αl are called a basis for M , and every element of M can be writtenuniquely as n1α1 +n2α2 + . . .+nlαl where n1, n2, . . . , nl ∈ Z. For n ∈ Z+ and m ∈M , wewrite nm to mean m+m+ . . .+m︸ ︷︷ ︸

n times

. Note that multiplication between module elements

may or may not to be defined.

We are interested in an extremely broad version of a Fibonacci sequence, so we adoptonly the fundamental recurrence relation and a corresponding generalization of a Zeck-endorf representation.

Definition 2.1 A Fibonacci sequence of order k is a doubly infinite sequence (Fr)r∈Z =(. . . , F−1, F0, F1, . . .) where

Fn−k + . . .+ Fn−2 + Fn−1 = Fn

for all integer n.

3

Page 4: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Here, a doubly infinite sequence (also called two-way infinite sequence) is a sequencethat goes in both directions.

Definition 2.2 Let (Fr)r∈Z be a Fibonacci sequence of order k. An element m is Zeck-endorf in (Fr) if it can be written as a finite sum of elements in (Fr) with no k consecutiveterms. A set M is Zeckendorf in (Fr) if every element of M is.

Note that we do not specify the initial condition for a Fibonacci sequence. In fact, wewill reverse engineer the theorem of Zeckendorf and identify all initial conditions that thetheorem holds. In other words, instead of proving a version of Zeckendorf’s theorem for aparticular sequence, we set forth to classify all sequences that are in favor of the theorem.

A Fibonacci sequence of order k has degree of freedom k; knowing any k consecu-tive terms is sufficient to generate the entire sequence. For k ≥ 2, the characteristicpolynomial of a Fibonacci sequence of order k is xk − xk−1 − xk−2 − . . . − x − 1. It isknown [25] that this polynomial has k distinct roots λk, λk,2, . . . , λk,k where λk ∈ (1, 2)and λk,2, . . . , λk,k lie in the unit circle. Note that the sequence (λrk)r∈Z is a Fibonaccisequence of order k. We call this sequence primitive.

Example 2.3 In this example we consider several Fibonacci sequences of order 3.

i.) The usual Tribonacci sequence is defined using F0 = F1 = 1, F2 = 2, and Fn−3 +Fn−2 + Fn−1 = Fn. The first few terms of this sequence are

1, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, . . . .

The two-way generalization of this sequence is given by

. . . , 5, −8, 4, 1, −3, 2, 0, −1, 1, 0, 0,

1, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, . . . .

ii.) The three roots of a polynomial x3−x2−x−1 are λ3 ≈ 1.839, λ3,2 ≈ −0.42−0.606i,and λ3,3 ≈ −0.42 + 0.606i. The primitive Fibonacci sequence of order 3 is thesequence (λr3)r∈Z, which is approximately

. . . , 0.161, 0.296, 0.544, 1, 1.839, 3.383, 6.222, 11.445, 21.05, . . . .

iii.) A Fibonacci sequence of order 3 where F0 = 0, F1 = 1 + i, and F2 = 2 + i is givenby

. . . , 5 + i, −2− 3i, −1 + 2i, 2, −1− i, i, 1,0, 1 + i, 2 + i, 3 + 2i, 6 + 4i, 11 + 7i, 20 + 13i, . . . .

Here, the element of this sequence are Gaussian integers, i.e., complex numbers ofthe form a + bi where a, b ∈ Z. The element 9 + 5i, for example, is Zeckendorf inthis sequence since 9 + 5i = (5 + i) + (−1 + 2i) + (2) + (3 + 2i).

4

Page 5: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

In order to study elements that are Zeckendorf in (Fr), it is natural to considerelements of the form (xr) · (Fr) where (xr) is a doubly infinite sequence of integers and ·is an infinite dot product, i.e.

(xr) · (Fr) =∑r∈Z

xrFr.

Roughly speaking, a collection of all elements of the form (xr) · (Fr) is a number systemwith the base (Fr) with the digit set Z. Here, (xr) acts like digits or coefficients for thebasis (Fr). These so-called coefficients can be manipulated using the following methods.

Definition 2.4 Doubly infinite sequences (xr) and (yr) are k-equivalent, denoted (xr) ∼k(yr), if (yr) can be obtained from (xr) using finite applications of the following two oper-ations.Operation 1: For some n ∈ Z, subtract 1 from xn and add 1 to all of xn−k . . . , xn−2, xn−1.Operation 2: For some n ∈ Z, add 1 to xn and subtract 1 from all of xn−k . . . , xn−2, xn−1.

It is not hard to see that Operations 1 and 2 “cancel out”, and ∼k is an equivalencerelation. These operations also preserve the value of the dot product: if (Fr) is a Fibonaccisequence of order k and (xr) ∼k (yr), then (xr)·(Fr) = (yr)·(Fr). As we will see later, thisobservation is an important ingredient of our results. Finally, we give a lexicographicalorder � to the doubly infinite sequences that are zero almost everywhere, i.e., (xr)r∈Z �(yr)r∈Z if the entry of (xr) is larger than that of (yr) at the rightmost index where theyare not equal.

3 k-equivalent Sequences

In a way, our approach in proving a generalized theorem of Zeckendorf is in asking thefollowing converse question: given a Fibonacci sequence (Fr) of order k, which elementscan be written as a finite sum of elements from (Fr) using no k consecutive terms? Itis not hard to see that they are elements of the form (yr) · (Fr) where (yr) is binary, is0 almost everywhere, and has no k consecutive 1’s. Now, instead of characterizing theseelements directly, we will focus on manipulating the coefficients (yr) using Operations 1and 2 from Definition 2.4. These coefficient manipulations operate independently of theunderlying Fibonacci sequence (Fr), and so this approach frees us from having to worryabout the choice of (Fr). As we will see, our results hold in a broad sense and are notlimited to just any specific Fibonacci sequence. Propositions 3.1 and 3.2 given in thissection will provide an effective mechanism for identifying sequences that are k-equivalentto a binary sequence with the required properties.

Proposition 3.1 For any sequence (xr)r∈Z of integers that is 0 almost everywhere, thereexists a sequence (yr)r∈Z such that (xr) ∼k (yr), and (yr)r∈Z is either

• zero everywhere,

• positive at some k consecutive terms and zero elsewhere, or

5

Page 6: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

• negative at some k consecutive terms and zero elsewhere.

In addition, if (xr)r∈Z 6= (0)r∈Z is nonnegative, then the k consecutive nonzero terms of(yr)r∈Z are positive.

Proof We keep applying either Operation 1 or 2 from Definition 2.4 to eliminate therightmost nonzero term of (xr). Since (xr) is 0 almost everywhere, we will eventuallyobtain a sequence (yr)r∈Z which is 0 everywhere except for some k consecutive terms.If the k consecutive terms of (yr) are all positive, all negative, or all zero, then we aredone. Otherwise, we can keep eliminating the rightmost nonzero term of (yr) and obtainyet another sequence that is 0 everywhere except for some k consecutive terms. We willprove that this process will eventually yield a sequence with k consecutive terms that areeither all positive or all negative.

We initialize (y0,r) = (yr) and collect the k nonzero terms of (y0,r) into a 1 × kvector γ0 = (γ1, γ2, . . . , γk). The rightmost term of (y0,r) is γk. Using either Operation1 or 2, we eliminate this term an obtain (y1,r) whose nonzero entries are given by γ1 =(γk, γ1 + γk, γ2 + γk, . . . , γk−1 + γk). In other words, we have

γ>1 = Aγ>0

where

A =

0 0 0 · · · 0 11 0 0 · · · 0 10 1 0 · · · 0 1...

......

. . ....

...0 0 0 · · · 1 1

.

Note that this is independent of the value of γk. We repeat this process, and it is nothard to see that (y0,r) is k-equivalent to (yn,r) for all positive integer n. In addition, thenonzero terms of (yn,r) are given by the entries of γ>n = Anγ>0 . Thus, it remains to showthat there is an n for which Anγ>0 is either positive or negative.

It should not be surprising that A is the transpose of the usual Fibonacci matrix.Thus, A has characteristic equation xk − xk−1 − xk−2 − . . . − x − 1 and eigenvaluesλk ∈ (1, 2) and λk,2, . . . , λk,k whose complex norms are less than 1 [25]. We denote by vieigenvector corresponding to the eigenvalue λi. Note that

v1 =

λk−2k

λk−2k + λk−3k

λk−2k + λk−3k + λk−4k...

λk−2k + λk−3k + · · ·+ λk + 1λk−1k

is real and positive. Now, one may diagonalizeA as CDC−1 whereD = diag(λk, λk,2, . . . , λk,k)

6

Page 7: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

and C =(v1 · · · vk

). It follows that

γ>n = Anγ>0

= CDnC−1γ>0

=(λnkv1 λnk,2v1 · · · λnk,kvk

)C−1γ>0

= λnkc1v1 + λnk,2c2v2 + . . .+ λnk,kckvk

where (c1, . . . , ck)> = C−1γ>0 . Since |λk| > 1, |λk,2|, . . . , |λk,k| < 1, and v1 is real and

positive, for a sufficiently large n we will have γ>n ≈ λnkc1v1, and so the entries of γ>n willeither be all positive or all negative, depending on the sign of c1. If c1 = 0, then γ>n = 0,implying that γ>0 = 0.

For the last part of the proposition, if (xr)r∈Z 6= (0)r∈Z is nonnegative, then we onlyneed to use Operation 1, and so the k consecutive terms of (yr)r∈Z cannot be negative orzero.

Proposition 3.2 For any sequence (xr)r∈Z of nonnegative integers that is 0 almost ev-erywhere, there exists a sequence (yr)r∈Z of 0 and 1 with no k consecutive 1’s such that(xr) ∼k (yr).

Proof Consider all sequences of nonnegative integers that are k-equivalent to (xr)r∈Z.Recall that if (xr) ∼k (yr), then (xr) · (λrk) = (yr) · (λrk) where (λrk) is the primitive Fi-bonacci sequence. Let N be an integer such that (xr) · (λrk) < λNk . Now, if a sequenceof nonnegative integers (yr) is k-equivalent to (xr), then we must have (yr) · (λrk) < λNk .Since (λrk) is strictly positive, it follows that yr = 0 for all r ≥ N . This allows us toconclude that, among all the sequences of nonnegative integers that are k-equivalent to(xr), there must be one with the highest lexicographical order. We call this sequence(yr)r∈Z and claim that it satisfies the conditions required.

Suppose that ys ≥ 2 for some s ∈ Z. We perform Operation 1 at n = s and Operation2 at n = s + 1. This results in a sequence with higher lexicographical order than (yr),contradicting our choice of (yr). Suppose now that ys−k = . . . = ys−2 = ys−1 = 1 forsome s ∈ Z. Perform Operation 2 at n = s yields a sequence with higher lexicographicalorder, and once again that contradicts the choice of (yr). We conclude that (yr) consistsonly of 0 and 1 with no k consecutive 1’s.

We illustrate the transformations given in Propositions 3.1 and 3.2 in an examplebelow.

Example 3.3 We let k = 3 and consider a doubly infinite sequence (xr) that is zeroeverywhere except x−1 = −2, x1 = −1, x2 = −2, and x4 = 1, i.e.,

(xr) = (. . . , 0, 0, 0, 0,−2, 0,−1,−2, 0, 1, . . .).

7

Page 8: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Here and throughout the example, only indices −5,−4, . . . , 4 are shown. We now trans-form (xr) into a sequence that is positive at some 3 consecutive terms and zero elsewhere.

(. . . , 0, 0, 0, 0,−2, 0,−1,−2, 0, 1, . . .) ∼3 (. . . , 0, 0, 0, 0,−2, 0, 0,−1, 1, 0, . . .)

∼3 (. . . , 0, 0, 0, 0,−2, 1, 1, 0, 0, 0, . . .)

∼3 (. . . , 0, 0, 0, 1,−1, 2, 0, 0, 0, 0, . . .)

∼3 (. . . , 0, 0, 1, 2, 0, 1, 0, 0, 0, 0, . . .).

∼3 (. . . , 0, 0, 2, 3, 1, 0, 0, 0, 0, 0, . . .).

Here, Operation 1 is performed at indices 4,3,1,0,0 in order. Next, we transform (. . . , 0, 0, 2, 3, 1, 0, 0, 0, 0, 0, . . .)into a binary sequence with no 3 consecutive 1’s.

(. . . , 0, 0, 2, 3, 1, 0, 0, 0, 0, 0, . . .) ∼3 (. . . , 0, 0, 1, 2, 0, 1, 0, 0, 0, 0, . . .)

∼3 (. . . , 1, 1, 2, 1, 0, 1, 0, 0, 0, 0, . . .)

∼3 (. . . , 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, . . .).

Here, Operations 2,1,2 are performed in order at indices 1,−2,−1 respectively. Considernow a Fibonacci sequence of Gaussian integers

(Fr) = ( . . . , −1 + 2i, 2, −1− i, i, 1, 0, 1 + i, 2 + i, 3 + 2i, 6 + 4i, . . . . )

from Example 2.3. Note that all the above 3-equivalent sequences represent the samequantity when multiplied by (Fr). In particular, if (yr) = (. . . , 0, 0, 2, 3, 1, 0, 0, 0, 0, 0, . . .)and (zr) = (. . . , 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, . . .), then

(xr) · (Fr) = (yr) · (Fr) = (zr) · (Fr) = −1 + i.

This, in fact, would hold for any other Fibonacci sequences (Fr) of order 3.

The last example illustrates a major strength of our approach–each equivalency classrepresents the same quantity under a given Fibonacci sequence. If one can find a legiti-mate Zeckendorf representation in an equivalency class, then the element represented bythat class has a Zeckendorf decomposition. We finish this section with a powerful corol-lary to Proposition 3.2 and another example. The next result characterizes all elementsthat are Zeckendorf in a Fibonacci sequence (Fr).

Corollary 3.4 Let (Fr) be a Fibonacci sequence of order k. An element m is Zeckendorfin (Fr) if and only if m can be written as a finite sum (with multiplicities) of elementsfrom (Fr).

Proof An element m is a finite sum of elements from (Fr) if it is Zeckendorf in (Fr).The converse of this statement follows from Proposition 3.2.

Example 3.5 Consider the primitive Fibonacci sequence of order 2,

. . . , ϕ−3, ϕ−2, ϕ−1, 1, ϕ, ϕ2, ϕ3, . . . ,

where ϕ = 1+√5

2is the golden ratio. The elements that are Zeckendorf in this sequence

are precisely positive elements in the ring Z[ϕ], and this numeration system is known asgolden ratio base.

8

Page 9: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

4 Zeckendorf’s Theorem for Free Z-Modules

Intuitively, if an element m is Zeckendorf in a Fibonacci sequence (Fr) of order k, thenit is an integer combination of the initial terms (or, in fact, any k terms) of (Fr). Integerspan of these forms a module, so it is natural to attempt to represent every elementof a module using sequence elements. Subsection 4.1 below deals with doubly infiniteFibonacci sequences using tools developed in the previous section. The result is thenspecialized to one-way Fibonacci sequences in Subsection 4.2. This paves the way for theZeckendorf decomposition and Fibonacci coding for modules.

4.1 Two-sided Sequences

Corollary 3.4 lays a strong foundation for our work. While it characterizes elements thatare Zeckendorf in a sequence, it gives insufficient information on the algebraic structureof the set of all elements that have a legitimate representation. The following theoremnow reverses the process. It gives a sufficient and necessary condition for every elementof a free Z-module M to be Zeckendorf in a Fibonacci sequence (Fr).

Theorem 4.1 Let M be a free Z-module of rank l, and (Fr)r∈Z = (. . . , F−1, F0, F1, . . .)be a Fibonacci sequence of order k. Then, M is Zeckendorf in (Fr) if and only if both ofthe following conditions are satisfied.

1. Fi, . . . , Fi+k−1 span M for all i.

2. l < k.

Proof We first remark that the integral span of Fi, . . . , Fi+k−1 is the same as the integralspan of Fi+1, . . . , Fi+k since Fi + · · ·+Fi+k−1 = Fi+k. Thus, Fi, . . . , Fi+k−1 span M for alli if and only if Fi, . . . , Fi+k−1 span M for any i.

It is easy to see that the first condition is necessary. Since the elements of (Fr)r∈Zare integer combinations of Fi, . . . , Fi+k−1, so must be any sums of the elements fromthis sequence. It follows that Fi, . . . , Fi+k−1 span M . This readily implies l ≤ k. We willnow show that l cannot equal to k, thus establishing the necessity of the second condition.

Suppose that l = k, and let m be any nonzero element of M . Since both m and −mare Zeckendorf in (Fr), we have

m = (xr) · (Fr) and −m = (yr) · (Fr)

for some sequences (xr), (yr) of 0 and 1 with no k consecutive 1’s. Hence, 0 = (xr + yr) ·(Fr). By Proposition 3.1, (xr + yr) is k-equivalent to a sequence that is positive at somek consecutive terms and zero elsewhere. Thus, we have

0 = (xr + yr) · (Fr) = (zr) · (Fr) = ziFi + zi+1Fi+1 + . . .+ zi+k−1Fi+k−1

for some i in which zi, zi+1, . . . , zi+k−1 > 0. This, however, means that Fi, Fi+1, . . . , Fi+k−1are integrally dependent, and so they cannot span a module of rank l = k.

9

Page 10: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

We are left to show that the two conditions are sufficient. Since F0, . . . , Fk−1 span Mand l + 1 ≤ k, F1, . . . , Fk−1 must be integrally dependent. That is, we may write

0 = x0F0 + · · ·+ xk−1Fk−1

where x0, . . . , xk−1 are not all zeros. In other words, we have

0 = (xr) · (F1)

where (xr) is zero everywhere but some k consecutive terms. We apply Proposition 3.1and obtain a sequence (yr) that is k-equivalent to (xr) and contain k consecutive termsof the same sign and zero elsewhere. Note that (yr) cannot be zero everywhere since thatwould imply that x0 = . . . = xk−1 = 0.

Suppose now that (yr) is nonzero at the terms yi, . . . , yi+k−1. This means

0 = yiFi + · · ·+ yi+k−1Fi+k−1

where either yi, . . . , yi+k−1 > 0 or yi, . . . , yi+k−1 < 0. Since Fi, . . . , Fi+k−1 span M , we canwrite any element m ∈M as

m = ziFi + · · ·+ zi+k−1Fi+k−1

where zi, . . . , zi+k−1 are integers. Now, we have

m = m+ 0 ·N = (zi + yiN)Fi + · · ·+ (zi+k−1 + yi+k−1N)Fi+k−1

for all integer N . For a sufficiently large (and possibly negative) N , the terms zi +yiN, . . . , zi+k−1 + yi+k−1N will all be positive, and it follows from Corollary 3.4 that m isZeckendorf in (Fr). This completes the proof of the theorem.

Corollary 4.2 Let (Fr)r∈Z = (. . . , F−1, F0, F1, . . .) be a Fibonacci sequence of order k. IfF1, . . . , Fk are integrally dependent, then every element in the integral span of F1, . . . , Fkis Zeckendorf in (Fr).

In view of Theorem 4.1, every integer has a (classical) Zeckendorf representation sinceZ is a module over itself with rank 1, and the negaFibonacci sequence is of order 2 withF0 = 0 and F1 = 1. In fact, the same result would hold as long as F0 and F1 are relativelyprime (and hence span Z integrally). This is technically the case for the Lucas sequencewhere L0 = 2 and L1 = 1. Next, we give an example for the case of Gaussian integers.

Example 4.3 Consider a Fibonacci sequence

. . . , −4 + 4i, 5 + i, −2− 3i, −1 + 2i, 2, −1− i, i, 1,0, 1 + i, 2 + i, 3 + 2i, 6 + 4i, 11 + 7i, 20 + 13i, 37 + 24i, . . . .

10

Page 11: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

from Example 2.3. It follows from Theorem 4.1 that every Gaussian integer can be writtenas a sum of elements from this sequence with no 3 consecutive terms. For instance,

−2 = (−2− 3i) + (−1 + 2i) + (i) + (1) −2i = (−2− 3i) + (2) + (i)

−1 = (−1− i) + (i) −i = (−1− i) + (1)

2 = (2) 2i = (−1 + 2i) + (1)

3 = (2) + (1) 3i = (−1 + 2i) + (i) + (1)

1 + 2i = (−1 + 2i) + (2) 1− 2i = (−2− 3i) + (i) + (1)

−2 + i = (−1 + 2i) + (−1− i) −2− i = (−2− 3i) + (−1 + 2i) + (1).

One may observe that (i)+(1) = (1+i), and so Zeckendorf representation for a Gaussianinteger in this sequence is not unique. Nonetheless, we will see in the next subsection howcertain adjustments can make unique representation possible.

On the contrary, no Fibonacci sequence of order 2 can generate all Gaussian integers.For example, −1− i cannot be written as a sum of elements from the sequence

. . . , −21 + 13i, 13− 8i, −8 + 5i, 5− 3i, −3 + 2i, 2− i, −1 + i,1, i, 1 + i, 1 + 2i, 2 + 3i, 3 + 5i, 5 + 8i, . . . .

Note that Corollary 4.2 does not apply here since 1 and i are not integrally dependent.However, it follows from Corollary 3.4 that every element of the form a + bi, a, b ∈ Z+,is Zeckendorf in this sequence.

4.2 One-sided Sequences and Unique Representation

For dense code, we need a one-to-one mapping. However, we see in Example 4.3 that atwo-sided sequence do not provide such luxury. Note that this is observed in the classicalFibonacci sequence as well. It is only when the negaFibonacci sequence is extracted fromthe two-sided infinite sequence

. . . , 34,−21, 13,−8, 5,−3, 2,−1, 1, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . .

that every integer has a unique Zeckendorf representation. In this subsection, we establishanalogous results for Fibonacci sequences of higher order. The key ingredient of thisdevelopment is Corollary 4.5, which states that binary sequences with no k consecutive1’s cannot be k-equivalent.

Lemma 4.4 Let a be an integer, and let (λrk)r∈Z be the primitive Fibonacci sequence oforder k. Then, ∑

r<ak - a−r

λrk = λak.

11

Page 12: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Proof We have ∑r<ak-a−r

λrk =∑r<a

λrk −∑r<ak|a−r

λrk

=λak

λk − 1− λakλkk − 1

= λak

((λk−1k + λk−2k + . . .+ 1)− 1

λkk − 1

)= λak

(λkk − 1

λkk − 1

)= λak.

Corollary 4.5 Let (xr) and (yr) be doubly infinite binary sequences with no k consecutive1’s that are 0 almost everywhere.

1. If (xr) �k (yr), then (xr) · (λrk) > (yr) · (λrk).

2. If (xr) ∼k (yr), then (xr) = (yr).

Proof Suppose that (xr) �k (yr), and let a be the largest index where (xr) and (yr) arenot equal. It follows that (xa) = 1, (ya) = 0, and

(xr) · (λrk) ≥ λak +∑r>a

xrλrk

=∑r<ak-a−r

λrk +∑r>a

xrλrk

>∑r≤a

yrλrk +

∑r>a

yrλrk = (yr) · (λrk).

Now, if (xr) 6= (yr), then we may assume without loss of generality that (xr) �k (yr).This means (xr) · (λrk) > (yr) · (λrk), and so (xr) �k (yr). This readily establishes part ii.

Typically, (xr) ∼k (yr) means that (xr) ·(Fr) = (yr) ·(Fr), and so (xr) and (yr) are tworepresentations of the same element. Corollary 4.5 now allows us to identify Fibonaccisequences (or parts of) that permit unique Zeckendorf representation: if a sequence (Fr)has the property that (xr) ·(Fr) = (yr) ·(Fr) implies (xr) ∼k (yr), then any element that isZeckendorf in (Fr) will have a unique representation. Since we are interested in generatingevery element in a Z-module, we look into generalizing negaFibonacci sequence, which istechnically a one-sided Fibonacci sequence to the left whose first excluded term is 0. Itturns out that this observation generalizes well to modules.

Theorem 4.6 Let k ≥ 2 be an integer, and M be a free Z-module of rank k − 1. Let(Fr)r∈Z = (. . . , F−1, F0, F1, . . .) be a Fibonacci sequence of order k where F0 = 0 and

12

Page 13: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

F−k+1, . . . , F−1 span M . Then, every element m ∈M can be uniquely written as a finitesum of elements from the one-way sequence

. . . , F−3, F−2, F−1

with no k consecutive terms.

Proof We first prove the existence. Let m ∈M , and write

m = x−k+1F−k+1 + . . .+ x−2F−2 + x−1F−1

where x−k+1, . . . , x−2, x−1 are integers. We extend x−k+1, . . . , x−2, x−1 to a sequence(xr)r∈Z that is zero everywhere except r = −k+1, . . . ,−2,−1. Now, consider all sequencesof integers that are k-equivalent to (xr)r∈Z such that the terms with positive index are zeroand the terms with negative index are nonnegative. Such a sequence exists since one mayapply Operation 1 from Definition 2.4 to (xr) at n = 0 for max{|x−k+1|, . . . , |x−2|, |x−1|}times. Denote by (yr)r∈Z the sequence that has the aforementioned properties with high-est lexicographical order. We claim that (yr) gives a Zeckendorf representation for m in. . . , F−3, F−2, F−1.

We first note that yr = 0 for r ∈ Z+ and F0 = 0, and so (yr) · (Fr) =∑

r∈Z− yrFr.If ys ≥ 2 for some s ∈ Z−, then we perform Operation 1 at n = s and Operation2 at n = s + 1 to obtain a sequence with higher lexicographical order than (yr). Ifys−k+1 = . . . = ys−1 = ys = 1 for some s ∈ Z−, then performing Operation 2 at n = sresults in a sequence with higher lexicographical order. Thus, (yr) is binary with no kconsecutive 1’s, and

∑r∈Z− yrFr is a Zeckendorf representation for m in . . . , F−3, F−2, F−1.

Suppose now for the sake of contradiction that there exists an element m ∈M that hastwo representations as a finite sum of elements from the sequence . . . , F−3, F−2, F−1 withno k consecutive terms. That is, we have m = (xr) · (Fr) = (yr) · (Fr) where (xr) 6= (yr)are doubly infinite binary sequences which are zero for r ≥ 0. Now, we keep applyingeither Operation 1 or 2 to eliminate the leftmost nonzero term of (xr) and (yr) and obtainsequences (x′r) and (y′r) which are zero everywhere except for r = −k + 1, . . . ,−2,−1, 0.This means

(x′r) · (Fr) = x′−k+1F−k+1 + . . .+ x′−2F−2 + x′−1F−1 + x′0F0

and

(y′r) · (Fr) = y′−k+1F−k+1 + . . .+ y′−2F−2 + y′−1F−1 + y′0F0.

are both equal to m. Since F−k+1, . . . , F−1 span M of rank k − 1, we must have x′r = y′rfor r = −k + 1, . . . ,−2,−1. If x′0 = y′0, then (xr) ∼k (x′r) = (y′r) ∼k (yr), and so (xr)and (yr) must be the same from Corollary 4.5. Otherwise, we assume without loss ofgenerality that x′0 > y′0. We now have

(xr) · (λrk)− (yr) · (λrk) = (x′r) · (λrk)− (y′r) · (λrk)= (x′0 − y′0)λ0k≥ 1.

13

Page 14: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Since (yr) is binary, it follows that (xr) · (λrk) ≥ 1. However, we see from Lemma 4.4 that

(xr) · (λrk) <∑r<0k-−r

λrk = λ0k = 1,

which is a contradiction. This completes the proof of the theorem.

Obviously, the generalized Zeckendorf theorem over negaFibonacci sequence [7] servesas an instance of Theorem 4.6. We give another example using Gaussian integers.

Example 4.7 Consider a Fibonacci sequence

. . . , −4 + 4i, 5 + i, −2− 3i, −1 + 2i, 2, −1− i, i, 1,0, 1 + i, 2 + i, 3 + 2i, 6 + 4i, 11 + 7i, 20 + 13i, 37 + 24i, . . . .

from Example 2.3 and 4.3. One can see that every representation given in Example 4.3only involve terms from the sequence

. . . , −4 + 4i, 5 + i, −2− 3i, −1 + 2i, 2, −1− i, i, 1.

In fact, every Gaussian integer can be uniquely written as a sum of elements from thissequence with no 3 consecutive terms. This property will be exploited when we developFibonacci coding for Gaussian integers in Example 5.1 in the next section.

5 Multidimensional Fibonacci Coding

The classical Fibonacci code of order 2 is quite simple. By virtue of Zeckendorf’s the-orem, integers are written in base Fibonacci and encoded as a string of 0’s and 1’s inreverse order together with a suffix 1. For example, 11 is encoded as 001011 since it isthe sum of the third and the fifth Fibonacci numbers, which are 3 and 8 respectively.The widely-accepted Fibonacci code of higher order is not so straightforward. Note thatsimply adding a consecutive runs of 1 no longer makes the code uniquely decodable [2].The integers are instead mapped to a lexicographically ordered string of 0’s and 1’s with asingle k consecutive 1’s at the end. This encoding, though artificial, provides dense codes.

We see from Theorem 4.6 that it is possible to write any element of a module as a sumof entries from a sequence using no k consecutive terms. This suggests Fibonacci codingfor modules with the use of k consecutive 1’s as a separator. This intuition formalizesinto Algorithm 1. Here, we denote k consecutive 1’s, 11 . . . 1︸ ︷︷ ︸

k

, by 1k.

Note that the coefficients are encoded in reverse order, and we replace the last 1with 01k to make our code uniquely decodable. This frees us from having to keep thelookup table, but makes the code suboptimal in terms of density. In addition, note thatthe algorithm simply mimics the arguments given in the proof of Theorem 4.6. Thisguarantees that the algorithm terminates since the operations performed in Step 4 and 5increase the lexicographical order of the sequence. At every step, the value

∑r∈Z− xrFr

remains unchanged. This fact makes the decoding, which is outlined as Algorithm 2,straightforward.

To illustrate, we consider once again the Gaussian Fibonacci sequence used throughExamples 2.3, 4.3, and 4.7.

14

Page 15: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Algorithm 1 Fibonacci Encoding

Input: A Fibonacci sequence . . . , F−3, F−2, F−1 of order k where F−k + . . . + F−1 = 0and F−k+1, . . . , F−1 span a free Z-module M of rank k − 1, and an element m ∈M .Output: Fibonacci code for m.

1: If m = 0, output 1k. END.2: Write m as

x−k+1F−k+1 + . . .+ x−2F−2 + x−1F−1.

Set x0 = 0 and xr = 0 for r ≤ −k.3: If x = min{x−k+1, . . . , x−2, x−1} < 0, subtract x from x−k, x−k+1, . . . , x−2, x−1.4: Find the largest index s < 0 such that xs−k+1, . . . , xs ≥ 1. If there is none, go to Step

5. Otherwise, subtract 1 from xs−k+1, . . . , xs, add 1 to xs+1, and repeat this step.5: Find the largest index s < 0 such that xs ≥ 2. If there is none, go to Step 6.

Otherwise, subtract 2 from xs, add 1 to xs−k and xs+1, and go to Step 4.6: Find the smallest index s < 0 such that xs = 1. Output x−1x−2x−3 . . . xs+2xs+101k.

END.

Algorithm 2 Fibonacci Decoding

Input: A Fibonacci sequence . . . , F−3, F−2, F−1 of order k, and a binary stringx1x2x3 . . . xs−1xs1k.Output: An element m.

1: If x1x2x3 . . . xs−1xs is empty, output 0. END.2: Output x1F−1 + x2F−2 + . . .+ xs−1F−s+1 + F−s. END.

Example 5.1 Consider the Fibonacci sequence

. . . , −4 + 4i, 5 + i, −2− 3i, −1 + 2i, 2, −1− i, i, 1,

and let m = −2 + 3i. To encode, we initialize x−2 = 3, x−1 = −2 and obtain x−3 = 2,x−2 = 5, x−1 = 0 after Step 3. We shorthand this sequence as 2, 5, 0. Iterations of Step4 and 5 now yield

2, 5, 0→ 1, 0, 2, 3, 1→ 1, 0, 1, 2, 0→ 2, 0, 1, 0, 1→ 1, 0, 0, 0, 1, 1, 0, 1.

Thus, m = −2 + 3i is encoded as 10110000111. This string can then be decoded asF−1 + F−3 + F−4 + F−8 = 1 + (−1 − i) + 2 + (−4 + 4i) = −2 + 3i. Table 1 below givesthe Fibonacci code under this sequence for some Gaussian integers. The length of theencoded Gaussian integer a+ bi where −10 ≤ a, b ≤ 10 is illustrated in Figure 1. This isextended to −1000 ≤ a, b ≤ 1000 in Figure 2. Here, region of the same color representsGaussian integer of the same encoded length using basis given in this example.

15

Page 16: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Figure 1: The encoded length of a+ bi where −10 ≤ a, b ≤ 10

Table 1: Fibonacci code for some Gaussian integersa = −2 a = −1 a = 0 a = 1 a = 2

b = 2i 01100111 00000111 10000111 00010111 1001011b = i 00100111 10100111 00111 10111 0100111b = 0 110010111 010111 111 0111 0000111b = −i 100010111 000111 100111 0010111 1010111b = −2i 010000111 110000111 010100111 110000111 0110010111

Clearly, one may replace i in Example 5.1 by any other quadratic integer and obtaina Fibonacci coding for the corresponding ring of quadratic integers. Next, we give anexample of Fibonacci coding for a lattice.

Example 5.2 Consider the lattice E8 given by

E8 ={x ∈ Z8 ∪ (Z+ 1

2)8 |

∑xi ≡ 0 (mod 2)

}.

This lattice provides optimal sphere packing and kissing number in 8 dimensions and hasmany other interesting properties [10]. We set the basis for E8 as

v1 = (2, 0, 0, 0, 0, 0, 0, 0) v2 = (−1, 1, 0, 0, 0, 0, 0, 0)

v3 = (0,−1, 1, 0, 0, 0, 0, 0) v4 = (0, 0,−1, 1, 0, 0, 0, 0)

v5 = (0, 0, 0,−1, 1, 0, 0, 0) v6 = (0, 0, 0, 0,−1, 1, 0, 0)

v7 = (0, 0, 0, 0, 0,−1, 1, 0) v8 = (12, 12, 12, 12, 12, 12, 12, 12)

and consider a Fibonacci sequence of order 9 given by

. . . , 2v2 − v1, 2v1,−v1 − v2 − v3 − v4 − v5 − v6 − v7 − v8,v8,v7,v6,v5,v4,v3,v2,v1.

16

Page 17: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Figure 2: The encoded length of a+ bi where −1000 ≤ a, b ≤ 1000

It follows from Theorem 4.6 that every element of E8 can be written as a sum of el-ements from this sequence with no 9 consecutive terms. For an example, let m =(12, 11

2, 11

2, 12, 12, 12, 12, 12) ∈ E8. Then, m = v1+2v2+v3+v8 = (2v2−v1)+(2v1)+(v8)+(v3)

and can be encoded as 00100001010111111111.

5.1 Compression Efficiency

In this subsection, we give an overview for the compression efficiency of the proposedscheme, both theoretically and numerically. We refer interested readers to [29] for a com-prehensive survey on the topic.

Let λk be the dominating root of xk−xk−1−xk−2− . . .−x− 1 = 0, i.e., the kth-ordergolden ratio. It takes approximately

logλk(A) + k − 1

bits to encode a single integer A using the Fibonacci code of order k. Unfortunately,due to the erratic nature of higher-order number system, a simple formula cannot bemade to approximate the number of bits needed to encode the string A1, A2, . . . , Akusing our proposed algorithm (see also Figure 2). Here, we shall attempt to give a verycrude estimate. Theorem 4.6 guarantees a one-to-one correspondence between moduleselement and sequences of 0’s and 1’s with no k consecutive 1’s. Consider a k-dimensionalhypercube with sides parallel to the axes, and the origin and (A1, A2, . . . , Ak) are oppositevertices. It takes at least logλk(A1A2 . . . Ak) bits to assign each integer point in this

17

Page 18: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

hypercube a unique binary strings under Fibonacci coding. Thus, if A1, A2, . . . , Ak aresufficiently large, one may estimate the number of bits needed to encode them altogetheras

logλk(A1A2 . . . Ak) + k.

If A is the geometric mean of A1, A2, . . . , Ak, then the per-element average of the numberof bits used to write each of the Ai’s is

logλk(A) + 1.

This can be interpreted that the burden of the k-bit suffix is shared across the stringentries.

While there exist several modern compression techniques [1, 6, 27, 34], each withdifferent strengths and tradeoffs, we compare multidimensional Fibonacci code with theclassical one, using the well-established Huffman code as a benchmark.

We consider string of alphabets from the set {1, 2, . . . , n}. The per-element averagecodeword lengths when alphabets are from a uniform distribution are given in Table 2.Here, multidimensional Fibonacci codes outperform their classical counterpart in termsof compression across all range and order. This is not surprising since the burden of thesuffix is shared across several alphabets in the proposed scheme.

Table 2: Average codeword lengths under uniform distributionn 128 256 512 1024

Huffman (= binary encoding) 7 8 9 10

Fibonacci order 2 10.609 12.054 13.525 14.881Fibonacci order 3 10.485 11.61 12.72 13.827Fibonacci order 4 11.172 12.242 13.307 14.372

Multidimensional Fibonacci order 3 10.384 11.009 12.5 13.574Multidimensional Fibonacci order 4 9.828 11.555 12.224 13.310

Next, Table 3 consider the case when alphabets are drawn from Zipf distribution, andalso when Fibonacci codes are used to encode bigrams from the set of alphabets of size32. Here, the performance of multidimensional Fibonacci codes are slightly behind theirclassical counterpart. This is probably due to the fact that multidimensional encoder getsa hold-back when “frequent” and “infrequent” alphabets are in the same group. Finally,we see that the performance of multidimensional codes are comparable to the classicalones when applied to bigrams.

18

Page 19: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

Table 3: Average codeword lengths under Zipf distributionn 128 256 512 1024 32× 32 bigram

Huffman 5.598 6.258 6.901 7.537 8.33

Fibonacci order 2 5.92 6.604 7.299 7.991 9.223Fibonacci order 3 6.54 7.104 7.667 8.23 9.273Fibonacci order 4 7.449 7.985 8.519 9.052 10.046

Multidimensional Fibonacci order 3 6.617 7.203 7.807 8.409 9.494Multidimensional Fibonacci order 4 7.471 8.015 8.558 9.1 10.106

We remark here that while Huffman code outperform Fibonacci code numerically, itworks well only when there are finite alphabets and the distribution is known a priori.Fibonacci code is also advantageous in that it provides robustness against errors andworks naturally on the set of integers. In this sense, multidimensional Fibonacci codecould be of particular interest when integers of unknown sign and magnitude are to beencoded.

6 Conclusion

In this paper, we generalize Zeckendorf’s theorem to modules. The notion of equivalentsequences allows us to identify elements that can be represented as a sum of entries froma Fibonacci sequence of order k. This results in the necessary and sufficient conditionsfor a Fibonacci sequence of higher order to generate a module. In addition, under certaincircumstances the representation is unique, allowing us to establish Fibonacci coding formodules. Future work involves identifying other conditions to which the representationremains unique. Under such environments, one can view Zeckendorf representation as anumber system and develop generalized Zeckendorf arithmetic. It would also be inter-esting to study the proposed coding algorithm from the perspective of data compressionand computational complexity.

Acknowledgments

The authors wish to thank Eaksit Buathong-iem for his assistance. This work is supportedby the Thailand Research Fund under Grant MRG6180192 and the Centre of Excellencein Mathematics, the Commission on Higher Education, Thailand.

References

[1] A. V. Anisimov and I. O. Zavadskyi, Variable-Length Prefix Codes With MultipleDelimiters, IEEE Transactions on Information Theory 63 (2017), no. 5, 2885–2895.

[2] A. Apostolico, A. Fraenkel, Robust Transmission of Unbounded Strings Using Fi-bonacci Representations, IEEE Transactions on Information Theory 33 (1987), 238–245.

19

Page 20: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

[3] I. Ben-Ari and S. J. Miller, A Probabilistic Approach to Generalized ZeckendorfDecompositions, SIAM Journal on Discrete Mathematics 30 (2016), no. 2, 1302–1332.

[4] Berzsenyi, Gaussian Fibonacci Numbers, Fibonacci Quarterly 15 (1977), no. 3, 233–236.

[5] A. Best, P. Dynes, X. Edelsbrunner, B. McDonald, S. J. Miller, C. Turnage-Butterbaugh, and M. Weinstein, Gaussian Behavior of the Number of Summands inZeckendorf Decompositions in Small Intervals, Fibonacci Quarterly 52 (2014), no.5, 47–53.

[6] N. R. Brisaboa, E. L. Iglesias, G. Navarro, and J. R. Parama, An Efficient Compres-sion Code for Text Databases, Proceedings of European Conference on IR Research(2003), 468–481.

[7] M. W. Bunder, Zeckendorf Representations Using Negative Fibonacci Numbers, Fi-bonacci Quarterly 30 (1992), 111–115.

[8] L. Carlitz, V. E. Hoggatt, Jr., and R. Scoville, Fibonacci Representations of HigherOrder, Fibonacci Quarterly 10 (1972), no. 1, 43–69.

[9] J. Cigler, Some Algebraic Aspects of Morse Code Sequences, Discrete Mathematicsand Theoretical Computer Science 6 (2003), 55–68.

[10] J. Conway, and N.J.A. Sloane, Sphere Packings, Lattices and Groups, Springer.

[11] P. Demontigny, T. Do, A. Kulkarni, S. J. Miller, D. Moon, and U. Varma, Gener-alizing Zeckendorf’s Theorem to f -decompositions, Journal of Number Theory 141(2014), 136–158.

[12] P. Elias, Universal Codeword Sets and Representations of the Integers, IEEE Trans-actions on Information Theory 21 (1975), 194–203.

[13] S. Even and M. Rodeh, Economical Encoding of Commas Between Strings, Com-munications of the ACM 21 (1978), 315–317.

[14] A. Fraenkel and S. Klein, Robust Universal Complete Codes As Alternatives toHuffman Codes, Technical Report CS85-16, The Weizmann Institute of Science,Rehovot, 1985.

[15] A. Fraenkel and S. Klein, Robust Universal Complete Codes for Transmission andCompression, Discrete Applied Mathematics 64 (1996), 31–55.

[16] I. J. Good, Complex Fibonacci and Lucas Numbers, Continued Fractions, and theSquare Root of the Golden Ratio, Journal of the Operational Research Society 43(1992), no. 8, 837–842.

[17] P. J. Grabner, R. F. Tichy, I. Nemes, and A. Petho, Generalized Zeckendorf Expan-sions, Applied Mathematics Letters 7 (1994), no. 2, 25–28.

20

Page 21: Multidimensional Fibonacci Coding - arXiv · Keywords: Fibonacci code, Zeckendorf’s theorem, pre x code, data compression, Z-module, Gaussian integers 1 Introduction A fundamental

[18] E. Halsey, The Fibonacci Number Fu where u is not an Integer, Fibonacci Quarterly3 (1965), no. 2, 147–152.

[19] C. J. Harman, Complex Fibonacci Numbers, Fibonacci Quarterly 19 (1981), no. 1,82–86.

[20] D. Huffman, A Method for the Construction of Minimum Redundancy Codes, Pro-ceedings of the IRE (1952), 1098–1101.

[21] J. H. Jordan, Gaussian Fibonacci and Lucas Numbers, Fibonacci Quarterly 3 (1965),no. 4, 315–318.

[22] S. T. Klein and D. Shapira, Random Access to Fibonacci Encoded Files, DiscreteApplied Mathematics 212 (2016), 115–128.

[23] D. E. Knuth, Fibonacci Multiplication, Applied Mathematics Letters 1 (1988), no.1, 57–60.

[24] C. G. Lekkerkerker, Voorstelling van natuurlyke getallen door een som van getallenvan Fibonacci, Simon Stevin 29 (1951-1952), 190–195.

[25] E. P. Miles, Jr., Generalized Fibonacci Numbers and Associated Matrices, AmericanMath. Monthly, 67 (1960), 745–57.

[26] S. J. Miller and Y. Wang, From Fibonacci Numbers to Central Limit Type Theorems,Journal of Combinatorial Theory, Series A 119 (2012), no. 7, 1398–1413.

[27] E. S. de Moura, G. Navarro, N. Ziviani, and R. Baeza-Yates, Fast and FlexibleWord Searching on Compressed text, ACM Transactions on Information Systems18 (2000), no. 2, 113–139.

[28] F. D. Parker, A Fibonacci function, Fibonacci Quarterly 6 (1968), no. 1, 1–2.

[29] D. Salomon, Data Compression The Complete Reference, Third Edition, Springer–Verlag, New York, 2004.

[30] S. Sato, Fibonacci Sequence and its Generalizations Hidden in Algorithms for Gen-erating Morse Codes, Applications of Fibonacci Numbers, Proceedings of The FifthInternational Conference on Fibonacci Numbers and Their Applications (1993), 481–486.

[31] N. Utgoff, A generalization of Zeckendorf’s Theorem, preprint.

[32] J. Walder, M. Kratky, and J. Platos, Fast Fibonacci Encoding Algorithm, DATESO(2010).

[33] J. Walder, M. Kratky, R. Baca, J. Platos, and V. Snasel, Fast Decoding Algorithmsfor Variable-Lengths Codes, Information Sciences 183 (2012), 66–91.

[34] H. Yamamoto, M. Tsuchihashi, and J. Honda, Almost Instantaneous Fixed-to-Variable Length Codes, IEEE Transactions on Information Theory 61 (2015), 6432–6443.

21