Applying Collatz function iterations to large integers

373 Views Asked by At

Given the Collatz function and its iterates: $$ T(n) = \begin{cases} n/2, & \text{if $n$ is even} \\ (3n+1)/2, & \text{if $n$ is odd} \end{cases} $$ and $$ T^{k}(n) = T(T^{k-1}(n)).$$

Question. How does one apply iterates to large integers such as $$ n = \big(3756801695685 \; \times \;2^{666669}\big) – 1\: ?\label{1}\tag{1} $$

We can begin by observing that repeated application of the Collatz function to numbers of the form $$ m = (2^{k} \times p) – 1 $$

where p is an odd integer, results in the iterate:

$$ T^{k}(m) = ((3^{k} \times p) – 1), $$

Thus, the trajectory of m travels k steps to arrive at a step that is $(3/2)^{k}$ times greater than m.

Applying this to the example in \eqref{1} yields a trajectory that spans 666669 consecutive odd numbers to arrive at

$$ T^{666669}(n) = \big(3756801695685 \times 3^{666669}-1\big). \label{2}\tag{2} $$

NOTE:

$$ 3756801695685 = 3 \times 5 \times 43 \times 347 \times 16785299 $$

Rephrasing the question: Are there similar ways to shortcut the evaluation of remaining iterates?

3

There are 3 best solutions below

2
On

$\forall k, \forall \alpha \in \mathbb{N}:$

  • $T^k(\alpha\,2^k) = \alpha$
  • $T^k(\alpha\,2^k + 2^k - 1) = \alpha\,3^k + 3^k - 1\quad\equiv \alpha\ (\text{mod } 2)$

So $T^{k+1}(\alpha\,2^{k+1} + 2^k - 1) = \alpha\,3^k + \frac{3^k - 1}{2}\quad\equiv \alpha + k\ (\text{mod } 2)$

After that, I have some relations, but less general.

These formulas can be proved by induction. But with a mixed representation in base 2 and 3, these formulas become obvious. Because

  • $(1)_2:(1)_3 = 4 = (2)_3:(0)_2$
  • $(1)_2:(2)_3 = 5 = (2)_3:(1)_2$
  • $(0)_2:(2)_3 = 2 = (1)_3:(0)_2$

Where $(\dots)_2$ is a binary representation and $(\dots)_3$ a representation in base $3$. Something like $\alpha:(0101)_2:(2)_3$ represents $\alpha \times 2^4 \times 3 + (0101)_2 \times 3 + (2)_3 = \alpha \times 2^4 \times 3 + 5 \times 3 + 2 = \alpha \times 2^4 \times 3 + 17$. And it is possible to mix figures in base 2 and figures in base 3.

(A little online tool to manipulate this kind of mixed radix.)

$\forall k, \forall \alpha \in \mathbb{N}:$

  • $T\big(\alpha:(0)_2\big) = \alpha$
  • $T\big(\alpha:(1)_2\big) = \alpha:(2)_3$
  • $T^k\big(\alpha:(\underbrace{0\dots00}_{k\text{ times}})_2\big) = \alpha$
  • $T^k\big(\alpha:(\underbrace{1\dots11}_{k\text{ times}})_2\big) = \alpha:(\underbrace{2\dots22}_{k\text{ times}})_3\quad\equiv \alpha\ (\text{mod } 2)$

So $T^{k+1}\big(\alpha:(0\underbrace{1\dots11}_{k\text{ times}})_2\big) = \alpha:(\underbrace{1\dots11}_{k\text{ times}})_3\quad\equiv \alpha + k\ (\text{mod } 2)$

0
On

For people liking examples with big numbers...

Another general rule for numbers dumping down the greatest numbers ... $$ a_0 = 2^A \cdot 2k + {2^A-1\over 3} \to a_1 = 6k+1 \qquad \text{for even }A \\ a_0=2^A \cdot 2k + {5 \cdot 2^A-1\over 3} \to a_1=6k+5 \qquad \text{for odd }A \\ $$ and arbitrary integer $k$.

Example with a small number: let $A=2$ then

A=2
k=15

r = (2^A-1)/3
r:
  1
print(a0=2^A*2*k+r," -> ",a1=6*k+1)
a0:
 121
  -> 
a1:
 91

Example with a big number: let $A=2000$ then

A=2000
k=15

r = (2^A-1)/3 
r: 
38271023175808484141094440039256066134077256736289840015921424560858875379 \   
7456771285553162105502089972815321546329154257815706320287685110475310452055 \   
5510617970999638177076000022959304941334829047630899668782874826053848788212 \   
9454649105675346822117990301665519387466269648209868541103883178721407323444 \   
2271147229696614861685341264949359713529669782588334763342389022086101740027 \   
1074542709725375596110573553299846547270900725995280134738661772775051362981 \   
1300697306851652594529890679720027319072210194251793475194575338509449595473 \   
144018169638425261294208391811842933607614256939321817920728283716343125


print(a0=2^A*2*k+r,   " -> "  , a1=6*k+1)
a0: 
34826631089985720568395940435723020182010303630023754414488496350   \
381576595568566186985337751600690187526194260715953037461229275146  \
179345053253251137055146623536096707411391600208929674966146944333  \
441186985924160917090023972737803730686164565608127371174515622642  \
594305379870980372404533692636480664334246674397902391952413366055  \
110391733931199950215538463464157401009835258342466778338658500917  \
924606219335028603580165196606557049226121822132252967403128283634  \
549235003861022200518545224860355711276769132062427063558043599131  \
880561056534370966987777729636548777069582928973814782854307862738  \
18187224405
     -> 
a1: 91
0
On

For the general problem it seems to me the following is the most useful property when looking at big numbers of a certain structure.
Let $a_0 = r $ be an odd number, then $ a_1 = {3a_0+1 \over 2^A} $ where $A$ is the exponent of the primefactor $2$ in $3a_0+1$.

Now consider $b_0 = 2^M\cdot x + r $ where $M$ is large, at least larger than $A$. Then $$ b_1={3b_0+1 \over 2^A} ={ 3\cdot 2^M\cdot x + 3r+1 \over 2^A} = 3\cdot 2^{M-A}\cdot x +{ 3r+1 \over 2^A} = 3\cdot 2^{M-A}\cdot x + a_1 $$ That means, we can use any $b_0$ as large as we like and which is $a_0 + 2^Mx $ with $x$ odd and $M$ greater than $A$ and compute easily $b_1$ . Further iterations are identical to that of the iterations of $r$ alone - as long as $M$ is large anough.