[seqfan] Re: Help with defining a sequence

Ali Sada pemd70 at yahoo.com
Fri Oct 23 23:01:22 CEST 2020


 Hi Marc,

Thank you very much for your response. I really appreciate it. I am sorry for my poor language, again!

What we want is to make the first element in each pair half of the second element. When can only add to one or two of the elements in the designated pair, but we cannot subtract from them. We take the “balance” we need from the first element of the next pair. 

The process goes like this: 
 
First we give the elements (a,b) in each pair initial values: a(n) = b(n)= n

After that, we change the pairs, one by one, so that a(n) = b(n)/2. We take the difference from a(n+1) : 

        1. If the first element is larger than half the second element, we make the second element twice the first element then we subtract the difference from the first element of the next pair.
        2. If the first element is smaller than half the second element, then we have two options:
                a.     If the second element is even we make the first element equal to half the second element, then we subtract the difference from the first element of the next pair.
                b.    If the second element is odd we add 1 to the second element, make the first element equal to half the modified second element, then we subtract the difference from the first element of the next pair.
 
Please see the “program” below.


For n=1 to 100
    a(n)= n
    b(n) = n
Next n 

[1]
For n=1 to 99
    h= b(n)/2 
    If a(n) > h Then
        b(n) = 2 * a(n)
        d = b(n) - n
        a(n+1) = a(n+1) - d
    [2] Else
        [2a] If h is an integer then 
                d = h - a(n)
                a(n) = h
                a(n+1) = a(n+1) - d
        [2b] Else
                b(n) = b(n) + 1
                d = b(n) / 2 – a(n) + 1
                a(n) = b(n) / 2
                a(n+1) = a(n+1) - s
    End If

End If


Next n

Best,
Ali

    On Friday, October 23, 2020, 12:59:31 PM EDT, Marc LeBrun <mlb at well.com> wrote:  
 
 > I would really appreciate your help defining the sequence below. 

Ali, sounds interesting but I found your verbal description hard to follow.  You apparently have implemented this as an algorithm;  consulting the code might have helped resolve questions, but you didn't include it.

May I suggest that you maybe start by doing something in-between: write out the algorithm, but express the steps in "pseudo code"?

For example I got confused right away by "we take the difference from the next pair".  Some ambiguities were in what you meant by "take" and what "difference" you were referring to (ie different between what and what?)

A start might go something like this:

0. For successive n: we modify both the n-th pair, say P[n]=(p,q), and the next pair, P[n+1]=(r,s).
1. We want P[n] to be (p,2p) so let's call the difference d = 2p - q
2. If d>0 we subtract d from first element of P[n+1], changing it to (r-d,s)... [*note]
3.  ...and add it to the second element of P[n], changing it to (p,q+d) = (p,2p)

[* note] Actually, I was also unclear if you must always subtract d from the first element of P[n+1] and add it to the second element of P[n], or if you could also subtract from s and/or add to p -- but that's at least what you did in the very first part of your description... 

Is that the right algorithm?  Make sure it's described very clearly, and it should greatly help describing the sequences it produces.
  



More information about the SeqFan mailing list