Variants of "3n + 1 problem" that fall into a 1-node cycle

173 Views Asked by At

Background

Motivation

Based on a previous question, I became interested in "3n + 1 problem" variants using $n \mod 4$ instead of even/odd (i.e. $n \mod 2$).

One particular concept is based on bifurcation theory from the logistic map.

Logistic Map

Logistic Map with range [-2, +4].

For some time, I have wondered if there's a relationship between the logistic map and prime numbers: both have a range of 6 and interesting points at $-1 \mod 6$ and $+1 \mod 6$.

I have also qualitatively compared the logistic map's $+4 \mod 6$ (and $-2 \mod 6$) to the reverse formulation of the "3n + 1 problem" as a tree.

Variant "3n + 1 problem"

Consider a mapping between integers inspired by $+4/-2$ and $+1/-1$ from the logistic map:

  • $n → n/2 + 4$ when n is congruent to $0 \mod 4$
  • $n → n*3 + 1$ when n is congruent to $1 \mod 4$
  • $n → n/2 - 2$ when n is congruent to $2 \mod 4$
  • $n → n*3 - 1$ when n is congruent to $3 \mod 4$

This is one of four possible mappings allowing swaps between $+4/-2$ and $+1/-1$: two of the others diverge and the last doesn't always converge to a 1-cycle.

Python Code

def hailstone_cycle(n):
    sequence = []
    while n not in sequence:
        sequence.append(n)
        residue = n % 4
        if residue == 0:
            n = n//2 + 4
        elif residue == 1:
            n = n*3 + 1
        elif residue == 2:
            n = n//2 - 2
        elif residue == 3:
            n = n*3 - 1
    cycle_start_index = sequence.index(n)
    cycle = deque(sequence[cycle_start_index:])
    index_of_min = cycle.index(min(cycle))
    cycle.rotate(-index_of_min)
    return {cycle[0]: list(cycle)}

Cycles

The cycles in this variant are pretty simple:

  • A 1-cycle $8$.
  • A 3-cycle $1, 4, 6$.
  • A 3-cycle $-1, -4, 2$.

Inputs $n ≥ 7$ always seem to fall to $8$.

Question

Can a "3n + 1 problem" variant be made such that it reaches a 1-cycle for all numbers greater than a constant $c$ and:

  1. using only $n \mod 2$?
  2. using only $n \mod 3$?
  3. using a "simpler" version of $n \mod 4$? (subjective)

Edit

I found another variant that seems like it's tied to the y-coordinates in the logistic map.

    residue = n % 4
    if residue == 0:
        n = (n+1+3)//2 # y=+3/2
    elif residue == 1:
        n = (n+1+2)*3 # y=1 (or 2/2)
    elif residue == 2:
        n = (n+1-1)//2 # y=-1/2
    elif residue == 3:
        n = (n+1+0)*3 # y=0
  • A 4-cycle $3, 12, 8, 6$.
  • A trivial cycle $4$.
  • A 3-cycle $7, 24, 14$.
  • A 3-cycle $13, 48, 26$.