Collatz algorithm generalization try-out (Collatz k-algorithm)

214 Views Asked by At

(Text Updated 2015/09/16, please see edit comments for changes) Recently I have been reading about the Collatz conjecture here in Mathematics Stack Exchange, and also found the fantastic paper of professor Lagarias about it. Everything was so interesting (and I admit I did not know anything about the topic before) that I read all the questions about the conjecture in MSE, and the reasons stated by other users about why it is supposed that the algorithm is based on $3x+1$ and not other possible combinations.

Just to learn more about it, I tried to generalize the algorithm as follows, defining a Collatz 'k-algorithm', where $k \ge 2$ is the integer used to perform the division step in the iteration process:

$$x_{n+1} = \begin{cases} x_n/k & \text{if $x_n \equiv 0\ (mod\ k)$} \\ \\ ((k+1)*x_n) + ((k-1)*(x_n\ mod\ k)) & \text{if $x_n \not\equiv 0\ (mod\ k) $} \end{cases}$$

Being the stopping condition: $0 \lt x_n \lt k$

This approach to a generalization is able to provide a following number of the sequence:

$x_{n+1}\ \ /\ \ k\mid x_{n+1}$ when $k \not\mid x_n$.

e.g., $k=2$ would be the classic Collatz conjecture algorithm:

$$x_{n+1} = \begin{cases} x_n/2 & \text{if $x_n \equiv 0\ (mod\ 2)$} \\ \\ ((2+1)*x_n + ((2-1)*(x_n\ mod\ 2)) & \text{if $x_n \not\equiv 0\ (mod\ 2) $} \end{cases}$$

...because $((2+1)*x_n + ((2-1)*(x_n\ mod\ 2)) = 3x_n+1$ and the stopping condition is $0 \lt x_n \lt 2$, which is $x_n=1$.

I did a Python test for $k\ge3$ and these are the results:

  1. The odd-k-algorithms are trivial, only those $x_0=k^i$ are able to reach the stopping condition (finite stopping time).

  2. The even-k-algorithms are interesting, I have verified the pattern of the $x_0$'s whose stopping time is finite (no loops) and for a given $k$, those $x_0=k/2^i\in \Bbb N, i\ge0 $ are able to arrive to the stopping condition, and randomly some other $x_0 \gt k$ values are able to have finite stopping time as well.

It is just a guessing but while the classic Collatz algorithm ($k=2$) $3x+1$ (if the above proposed definition is valid to define the algorithm) would depend on a (mod 2) operation, generating two groups of $x_{n+1}$, one divisible by $2$ and the other non-divisible, due to the use of the (mod k) operation in the algorithm for $k \gt 2$, it would generate $k$ different groups of $x_{n+1}$ (one divisible by $k$ and the others non-divisible).

Regarding that point, what I have seen so far is that for instance for the 3-algorithm ($k=3$), if the next element $x_{n+1} \equiv 2 \pmod 3$ and the previous last element whose congruence was $\not \equiv 0 \pmod 3$ was $\equiv 1 \pmod 3$, then a loop occurs later in the sequence, but on the contrary if the sequence is composed by elements whose (mod 3) value, not including those that are $\equiv 0 \pmod 3$, is ordered in decrease order the sequence arrive to the stopping condition.

e.g.(3-Collatz):

$24,8 \equiv \color{blue}2 \pmod 3,36,4 \equiv \color{blue}1 \pmod 3,18,6,2$ ($\color{blue}{End}$)

$\color{red}{14} \equiv 2 \pmod 3,60,20 \equiv 2 \pmod 3,84,28 \equiv \color{red}1 \pmod 3,114,38 \equiv \color{red}2 \pmod 3,156,52 \equiv 1 \pmod 3,210,70 \equiv 1 \pmod 3 ,282,94 \equiv 1 \pmod 3 ,378,126,42,\color{red}{14} \equiv 2 \pmod 3$ ($\color{red}{Loop}$)

I would like to ask the following questions:

  1. Would it make sense a generalization based on a modular arithmetic formula?

  2. Is defining the stopping condition of a k-Collatz algorithm as $0 \lt x_n \lt k$ a correct approach, or should it be always $1$ as in the original algorithm?

  3. What type of tests could I do over that algorithm to understand how it works much better?

Any hint about anyone of the points is very welcomed. Thank you!