[seqfan] Re: Can we write this definition in a better way?

Ali Sada pemd70 at yahoo.com
Thu Sep 26 21:12:50 CEST 2019


 
Hi David,

The OEIS isone of the greatest scientific labs in the world. It gives us the freedom tothink way beyond the traditional functions (polynomials, trigonometric, etc.)  I am fascinated by self-referencing sequences,especially the Van Eck sequence, because they force us to think outside thebox, and by doing so we could reach new understandings of numbers and mathoperations. 
Yourexamples about putting prime numbers in self-referencing sequences show mypoint here. The primes sequence is probably the ultimate self-referencingsequence. And by putting the primes in a different context, as you did, wemight be able to have better understanding of them.

As for thesequence I suggested, it’s now pending. I depended on the excellent advices from Jamie Morken and Chris Drost to re-write it: 

“a(1)=1;a(2)=2; a(n)=n-the largest index of the largest term if a(n-1) is odd;a(n)=n-the largest index of the second largest term if a(n-1) is even.”

I felt sohappy when I didn’t see any edits on this text from our friend Michel Marcus. That’sa good step forward for me. 

Best,

Ali 

    On Thursday, September 26, 2019, 5:00:15 AM EDT, David Sycamore via SeqFan <seqfan at list.seqfan.eu> wrote:  
 
 I’m coming to this conversation a bit late, so just two points to mention:

The original question was about the wording and how could it be done better. For me Ali’s definition produced the terms easily enough, which means it’s fit for purpose, though perhaps some compression could be possible? 

The self referencing idea behind this sequence is interesting. Seems to me that in general, all that’s needed is an initial term (or two, as in this case), and a rule based on a property which a(n-1) either has or has not. It’s a yes/no question followed by an unambiguous calculation of a(n) using the indices of prior terms according to the rule.  Ali’s problem uses parity on a(n-1), and differencing between n and the indices of previous parity related terms, in order to get a(n). 

It may be possible to derive many other self referencing (indices based) sequences using different number properties, for example: primality: 

a(1) =1; 
a(n-1) prime ->
a(n) = sum{i; a(i) prime; 1<=i<=n-1}.
a(n-1) not prime ->
a(n) = sum{j; a(j) not prime; 1<=j<=n-1}.

Unless I am mistaken this gives:

1,1,3,3,7,12,9,16,24,33,43,23,56......

(which does not appear to be in oeis).

If we change a(1) to 2, we get : 2,1,2,4,6,11,10,17....  (also not in oeis).

If we use a(1)=0 and “triangularity” with the above index rule, instead of primality, seems we get: 0,1,3,6,10,15,21,28..... which is both self referencing and self generating. (Qn: If a(1) is a non triangular number does the subsequent sequence contain any triangular numbers ?).

David. 




> On 24 Sep 2019, at 00:03, Ali Sada via SeqFan <seqfan at list.seqfan.eu> wrote:
> 
> Hi Chris,
> Thank you very much for your response. I really appreciate it. 
> 
> Maybe I like self-reference sequences because they are usually more difficult to be re-written as functions between a(n) and n. 
> Even if we manage to find a function, we will be missing the point if we don't explain why.
> For example, the definition "a(1)=1; a(2)=2; a(n)=n-m, where m is the smallest index of the second largest term"
> gives us:
> [1 ,2 ,2 ,3 ,3 ,4 ,3 ,4 ,5 ,4 ,5 ,6 ,4 ,5 ,6 ,7 ,5 ,6 ,7 ,8,5 ,6 ,7 ,8 ,9 ,6 ,7 ,8 ,9 ,10 ,6 ,7 ,8 ,9 ,10 ,11 ,7 ,8 ,9 ,10 ,11 ,12 ,7 ,8 ,9,10 ,11 ,12 ,13 ,8,…]
> 
> and that's A138099: Irregular triangle read by rows: T(n,k) = k + floor(n/2), 1 <= k <= ceiling(n/2)  
> 
> 
> Formula: a(n) = n - floor((1/4)*(floor(sqrt(4*n-3))-1)^2)
> The function here doesn't seem to have a direct link to the first definition. Trying to figure out "why" could add to our understanding of the sequence.
> 
> Best,
> Ali
> 
> 
> 
> 
>    On Monday, September 23, 2019, 4:37:34 PM EDT, C.R. Drost <c.r.drost at gmail.com> wrote:  
> 
> What a strange sequence... multiple layers of self-reference in there. Not
> sure if I see a better way to simplify it.
> 
> Quick and dirty Haskell implementation:
> 
> -- terms that contain an index and a value, equated/compared only over
> their value
> data IV = IV {index :: Int, value :: Int} deriving Show
> instance Eq IV where { IV _ v1 == IV _ v2 = v1 == v2}
> instance Ord IV where { compare (IV _ v1) (IV _ v2) = compare v1 v2 }
> 
> -- update a pair containing a second-largest and largest element with a new
> element
> update :: Ord x => (x, x) -> x -> x
> update old@(penultimate, ultimate) new
>  | ultimate < new    = (ultimate, new)
>  | ultimate == new    = (penultimate, new)
>  | penultimate <= new = (new, ultimate)
>  | otherwise          = old
> 
> mySequence = 1 : 2 : go (IV 1 1, IV 2 2) 2 3 where
>  go old last idx = val : go (update old newIV) val (idx + 1)
>    where
>      penultimateOrUltimate = if even last then fst old else snd old
>      val = idx - index penultimateOrUltimate
>      newIV = IV idx val
> 
> One interesting thing is that since the definition of `val` above is a
> difference of two indexes, this should be translation-invariant; if you
> instead defined a(0) = 1, a(1) = 2 you should get the same sequence shifted
> by 1 from that recurrence rule.
> 
> But yeah if you eliminate that stuff about choosing either the
> second-largest or the largest based on some parity, then you would only
> have the ultimate one and you would not need to start with two terms;
> choosing a(1) = 1 gives the sequence [1, 1, 1, 1, 1, ...] which is not very
> interesting. So you can't simplify away the need for choosing between the
> two. You can maybe simplify away that the choice depends recursively on the
> prior result, instead just choosing `if even idx` above to eliminate one
> part of the self-reference to get a simpler sequence, this leads to a
> sequence
> 
> 1,2,2,1,1,3,4,1,3,3,1,5,6,1,3,3,5,5,1,7,8,1,3,3,5,5,7,7,1,9,10,...
> 
> which indeed seems much simpler: the evens showing up here are 4, 6, 8, 10,
> ... and they are spaced by successive even spacings, a^{-1}(i) - a^{-1}(i -
> 1) = i eventually, suggesting that maybe you can tweak it so that those
> appear on square or triangular numbers or so. And the pattern seems to be
> pretty robust then of (1, 3, 3, 5,5, ... 2n-3, 2n-3, 1, 2n-1, 2n) repeated
> over and over.
> 
> With the extra self-reference I am not sure if I see a good way to simplify
> any of it any further though.
> 
> -- Chris
> 
> On Sun, Sep 22, 2019 at 12:30 PM Ali Sada via SeqFan <seqfan at list.seqfan.eu>
> wrote:
> 
>> 
>> Hi Everyone,
>> 
>> 
>> 
>> Please see the sequence below. I just want to see if thereis there is a
>> better way to write its definition. OEIS editors usually strugglewith my
>> language, and I would really appreciate it if you could help me maketheir
>> job easier.
>> 
>> The sequence:
>> 
>> 1 ,2 ,2 ,3 ,1 ,2 ,1 ,4 ,5 ,1 ,2 ,4 ,1 ,5 ,1 ,2 ,5 ,1 ,2 ,8 ,4,5 ,3 ,4 ,3
>> ,6 ,1 ,8 ,3 ,2 ,5 ,4 ,7 ,6 ,2 ,3 ,9 ,1 ,2 ,12 ,4 ,5 ,3 ,4 ,8 ,9 ,7,8 ,3 ,10
>> ,1 ,12 ,3 ,2 ,5 ,4 ,7 ,6 ,9 ,8 ,11 ,10 ,2 ,3 ,13 ,1 ,2 ,16 ,4 ,5 ,3 ,4,8 ,9
>> ,7 ,8 ,12 ,13 ,11 ,12 ,3 ,14 ,1 ,16 ,3 ,2 ,5 ,4 ,7 ,6 ,9 ,8 ,11 ,10 ,13
>> ,12,15 ,14 ,2 ,3,……
>> 
>> 
>> 
>> The definition:
>> 
>> “a(1)=1;
>> 
>> a(2)=2;
>> 
>> a(n)=n-m1, if a(n-1) is odd;
>> 
>> a(n)=n-m2, if a(n-1) is even;
>> 
>> m1 is the most recent position of the largest term up toa(n-1);
>> 
>> m2 is the most recent position of the second largest term upto a(n-1)”
>> 
>> 
>> 
>> Example 1: When n=10, a(9) is odd, the largest term up to thatpoint is 5.
>> The most recent position of 5 is 9. a(10)=10-9=1
>> 
>> Example 2: When n=17, a(16) is even. The second largest termup to that
>> point is 4. The most recent position of 4 is 12. a(17)=17-12=5
>> 
>> Thank you very much in advance.
>> 
>> 
>> 
>> Best,
>> 
>> 
>> 
>> Ali
>> 
>> 
>> --
>> Seqfan Mailing list - http://list.seqfan.eu/
>> 
> 
> --
> Seqfan Mailing list - http://list.seqfan.eu/
> 
> 
> --
> Seqfan Mailing list - http://list.seqfan.eu/


--
Seqfan Mailing list - http://list.seqfan.eu/
  



More information about the SeqFan mailing list