Basic Examples (1)
The dual Zeckendorf representation of first 20 integers (OEIS: A104326):
Scope (6)
By definition, one can directly find dual Zeckendorf representation by eliminating binary string with "00":
Recover a number from its dual representation:
In the dual representation, the largest index of Fibonacci number has the following property:
Thus input falls precisely the gap between the sum of Fi for i = 2 to 28 and from 2 to 29=28+1:
The second largest value, 26, is found in the similar way by definition:
For any input n, its dual Zeckendorf representation is {1,1, … ,1} or zero-free if and only if n= Fk-2, where Fk is the k-th item in regular Fibonacci sequence with k>=4:
For any input n, its dual Zeckendorf representation is {1,0,1,0 … ,0|1} or alternating pattern (the ending in 0 or 1 depends on the parity of bit length) if and only if n= Fk-1, where Fk is the k-th item in regular Fibonacci sequence with k>=4:
On modern computers, it takes around 3 seconds to finding the dual Zeckendorf representation for the first 100K numbers:
Applications (2)
Recover a Fibonacci number from the dual Zeckendorf representation by counting the number of k-bit vectors. For instance F(17)-2 = F(2)+F(3)+…+ F(15) where 15 = 17 -2:
Note that the numbers on the RHS of the rules are exactly the Fibonacci numbers:
This observation can be proved with a combinatorics argument.
Properties and Relations (3)
The dual Zeckendorf representation vs. Zeckendorf representation: the former does not allow consecutive zeros, meanwhile the latter does not allow consecutive ones. Check the fact with the first twenty numbers:
Fibonacci terms minus one:
The two representations for the numbers above 4, 7, 12, 20,… are identical:
Possible Issues (1)
The input must be a positive integer. Otherwise the function returns unevaluated:
Neat Examples (4)
The number of ones in the dual Zeckendorf representation for first 120 numbers:
Compare the ones in the Zeckendorf and the dual representation for Fibonacci numbers:
Visualize the number of ones in the dual representation for Fibonacci number:
The sequence is OEIS A065033:
Because no consecutive zeros are allowed, all dual Zeckendorf representations are compact Huffman code:
This function can handle very large input:
Visualize the binary code with ArrayPlot:
Find the closed form for the average density of 1's in k-bit dual Zeckendorf representations as k approaches infinity:
The sum on the RHS of these rules has the following closed form expression (OEIS A023610):
Shift indices and find the limit as the bit length approaches infinity:
The result is simply (ϕ+2)/5 where ϕ is the golden ratio (use Binet's formula and ϕ2=ϕ+1 for proof):