Wednesday, July 15, 2015

An interesting sequence obtained from an orbits simulator

I have obtained an interesting sequence by making a simulation of a system with a total of k "orbits", system_k = {o_0,o_1..o_k-1} where the orbits are filled with natural numbers following the algorithm explained below. The orbit closer to the "nucleus" is o_0. Applying the rules below I can obtain a sequence that I suspected would be easy to find at OEIS, but it was not there.

The main rule to generate the sequence is: an orbit o_i can never have a set of numbers whose sum is greater than o_i-1 (in other words, the more internal orbit it is, the "heavier" it is) and the most external orbit only can have one number. The rules to settle numbers follow this algorithm:

1. number to settle n = 1.

2. current orbit = the most external orbit = o_k-1

3. If the current orbit is not o_0 and the sum of the numbers currently settled in the current orbit plus n are less or equal than the sum of the numbers currently settled in the immediately lower closer orbit then add n to the current orbit. If the current orbit is the most external one, finish.

4. In other case, if the current orbit is not o_0 then current orbit = immediately lower closer orbit and try again step (3). If the current orbit is o_0 directly settle n into it. If it was a system of total orbits = 1 then finish. If not, n=n+1 and go to step (2).

By doing this the algorithm finishes when a number n is settled for the first time the most external orbit of the system.

(Q) What I wanted to simulate is: for the interval of [1,T] orbits, how many numbers are necessary to settle until one number is finally settled in the outer orbit? 

E.g. this are the results applying the algorithm to some orbits:



It is easy to see that the system_i is a subset of the system_i+1. It means that finding the answer to the question (Q) is the same as generating a T orbits system (system_t) and checking which one was the first number n settled on each orbit of the system.

When the test is run this is the sequence S of numbers required to settle a number in the outer orbit for a number of [1..49] orbits:

S={1,3,7,11,16,25,32,40,49,59,73,85,98,112,127,147,164,182,201,221,242,272,295,319,344,370,397,425,454,484,515,553,586,620,655,691}

The sequence can not be found at OEIS, but the idea is simple so I suspect that probably there is this same sequence somewhere and can not find it.

I wonder if there is a reference about a similar sequence like this, applying a similar algorithm, and if the sequence S is somehow predictable (there is a closed-form expression).

Some extra information:

This is how system_31 loos like:


And this is the Python code in case somebody wanted to play with it:

def orbits():
    from sympy import totient,mobius
    from gmpy2 import is_prime,is_square
  
    orbits=[[],[]]
    total_orbits = 2
    current_orbit = total_orbits
    for n in range (1,100):
        while True:
            valn = n
            if (current_orbit>1) and (sum(orbits[current_orbit-1])+valn) <= (sum(orbits[current_orbit-2])):
                orbits[current_orbit-1].append(valn)
                break

            else:
                current_orbit = current_orbit -1
                if current_orbit == 1 or current_orbit==0:
                    orbits[0].append(valn)
                    break

        if (current_orbit == total_orbits) and current_orbit!=0:
            total_orbits = total_orbits + 1
            orbits.append([])
            current_orbit = total_orbits
        else:
            current_orbit = total_orbits

    for o in orbits:
        mystr=""
        for n in o:
            mystr = mystr + str(n) + "\t"
        print(mystr)
  
    mystr=""
    for o in orbits:
        for n in o:      
            mystr = mystr + str(n) + "\t"
            break
    print(mystr)
orbits()

No comments:

Post a Comment