Monday 2 November 2020

Van Eck's Sequence

 Today's diurnal number of 26146 turned up the following entry in the OEIS:


A308782



Index of first occurrence of n appearing twice in succession in Van Eck's sequence (A181391), or 0 if it never occurs.


I was naturally curious about how Van Eck's sequence was generated and I found this helpful Numberphile video narrated by Mr. Sloane himself:


The value of \(n\) that occurs twice in succession, for the first time, is 29 and so 26146 refers to the the index position (counting the first zero of the sequence as term 1) of the second 2 in the digit sequence 2929 (marked in bold red). Here are the early terms of the Van Eck sequence showing the situation for 0, 2 and 3 (11 doesn't appear in the sequence):

0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, 2, 9, 0, 4, 9, 3, 
6, 14, 0, 6, 3, 5, 15, 0, 5, 3, 5, 2, 17, 0, 6, 11, 0, 3, 8, 0, 3, 3, 1, 42, ... 

The first four terms of the A308782 sequence are 2, 0, 8, 50 corresponding to \(n\) = 0, 1, 2, 3. I was interested in generating the Van Eck sequence using SageMath and below is the code that I came up with (permalink):

L=[0]
for i in [1..100]:
    if L.count(L[i-1])==1:
        L.append(0)
    else:
        m=0
        for x in [0..(i-2)]:
            if L[x]==L[i-1]:
                m=(i-1)-x
        L.append(m)
print(L)

[0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, 2, 9, 0, 4, 9, 3, 6, 14, 0, 6, 3, 5, 15, 0, 5, 3, 5, 2, 17, 0, 6, 11, 0, 3, 8, 0, 3, 3, 1, 42, 0, 5, 15, 20, 0, 4, 32, 0, 3, 11, 18, 0, 4, 7, 0, 3, 7, 3, 2, 31, 0, 6, 31, 3, 6, 3, 2, 8, 33, 0, 9, 56, 0, 3, 8, 7, 19, 0, 5, 37, 0, 3, 8, 8, 1, 46, 0, 6, 23]

Here is a link to two different Python 3 algorithms that generate the Van Enk sequence. Figure 1 shows the plot for these first 100 values:

Figure 1

Here is the Van Eck sequence represented as a melody:


Of course, as with the Fibonacci sequence, a starting value other than 0 will produce a different but similar sequence to the Van Eck. My SageMath algorithm is easily modified to investigate such sequences. For example, let's make the first term 1 (permalink):

L=[1]
for i in [1..100]:
    if L.count(L[i-1])==1:
        L.append(0)
    else:
        m=0
        for x in [0..(i-2)]:
            if L[x]==L[i-1]:
                m=(i-1)-x
        L.append(m)
print(L)

[1, 0, 0, 1, 3, 0, 3, 2, 0, 3, 3, 1, 8, 0, 5, 0, 2, 9, 0, 3, 9, 3, 2, 6, 0, 6, 2, 4, 0, 4, 2, 4, 2, 2, 1, 23, 0, 8, 25, 0, 3, 19, 0, 3, 3, 1, 11, 0, 5, 34, 0, 3, 7, 0, 3, 3, 1, 11, 11, 1, 3, 5, 13, 0, 10, 0, 2, 33, 0, 3, 9, 50, 0, 4, 42, 0, 3, 7, 25, 40, 0, 5, 20, 0, 3, 8, 48, 0, 4, 15, 0, 3, 7, 15, 4, 6, 70, 0, 7, 6, 4]

Note that 11 occurs twice quite early on in this sequence whereas in the Van Eck it occurs in the 7224th position. 

No comments:

Post a Comment