Simplistic Odd Collatz formulas

191 Views Asked by At

I've been experimenting with the Collatz for a couple of months. I just want to give you some formulas and show tables that give the same results for odd inputs. I have also several new functions, but ill only provide a few of them here. I tweaked the formulas. It seems very strange that all of them give the same outputs. My notes are a bit messy, so bear with me if I didnt provide all the details.

\begin{array}{|c|c|c|c|}\hline n & 3n & 3n+1 & \frac{3n+1}{2} \\ \hline 1 & 3 & 4 & 2 \\ \hline 3 & 9 & 10 & 5 \\ \hline 5 & 15 & 16 & 8 \\ \hline 7 & 21 & 22 & 11 \\ \hline 9 & 27 & 28 & 14 \\ \hline 11 & 33 & 34 & 17 \\ \hline 13 & 39 & 40 & 20 \\ \hline \end{array} orginal collatz formula, dividing by two.

\begin{array}{|c|c|c|c|}\hline n & 2n & \lfloor\frac{n}{2}\rfloor & 2n-\lfloor\frac{n}{2}\rfloor \\ \hline 1 & 2 & 0 & 2 \\ \hline 3 & 6 & 1 & 5 \\ \hline 5 & 10 & 2 & 8 \\ \hline 7 & 14 & 3 & 11 \\ \hline 9 & 18 & 4 & 14 \\ \hline 11 & 22 & 5 & 17 \\ \hline 13 & 26 & 6 & 20 \\ \hline \end{array} a new(?) formula.

\begin{array}{|c|c|c|c|}\hline n & \lfloor\frac{n}{2}\rfloor & n+1 & \lfloor\frac{n}{2}\rfloor + n+1 \\ \hline 1 & 0 & 2 & 2 \\ \hline 3 & 1 & 4 & 5 \\ \hline 5 & 2 & 6 & 8 \\ \hline 7 & 3 & 8 & 11 \\ \hline 9 & 4 & 10 & 14 \\ \hline 11 & 5 & 12 & 17 \\ \hline 13 & 6 & 14 & 20 \\ \hline \end{array} yet another.

Here $n$ is a positive integer. The floor function omits the fractional part if the result is real.

The functions from the tables above:

$f(n) = \frac{3n+1}{2}$

$f(n) = 2n-\lfloor\frac{n}{2}\rfloor$

$f(n) = \lfloor\frac{n}{2}\rfloor + n+1$

The latter formula is the one i've been working on lately. We can change it again, $\lfloor\frac{n}{2}\rfloor+n+1 = \frac{n}{2}+\frac{2n}{2}+\frac{2}{2} = \frac{3n+2}{2}=\lfloor\frac{3n}{2}\rfloor+1$.

That gets us back to the formula in the first table. They look quite similar.

The function $f(n) = 2n-\lfloor\frac{n}{2}\rfloor$ is also quite interesting. In a "geometric" standpoint we can look at it like doubling the $n$ and then removing the half of the total, here's a simple figure showing this:

enter image description here

I have never seen this formula before, and wonder if I can use this notation:

$f(n)=\lfloor\frac{n}{2}\rfloor+\begin{cases} n+1 & n\equiv 1\pmod2 \\ 0 & n\equiv 0\pmod2 \end{cases}$

See, for odd and even we can halve the input in one go. And then add the result of the cases.

2

There are 2 best solutions below

8
On BEST ANSWER

There is nothing wrong with using an alternate form of the original Collatz ($3x+1$) rule, as long as you have a reason for the modification.

Without using a floor function, it is much easier to show that your method is equivalent to the $\frac{(3n+1)}{2}$ rule. The floor function truncates 0.5 after dividing an odd integer in half, therefore removing 1 from the odd integer in the first place and then dividing by 2 will provide the same effect. (ex. $\lfloor$9/2$\rfloor$ = 4.5 - 0.5 = 4, and (9-1)/2 = 4.)

With that in mind, here is a proof to validate your method:

$\frac{n-1}{2}$ + $n$ + $1$

= $\frac{n-1}{2}$ + $2n\over2$ + $2\over2$

= $\frac{n - 1 + 2n + 2}{2}$

= $\frac{n + 2n + (-1) + 2}{2}$

= $\frac{3n+1}{2}$

The expressions $\frac{3n+1}{2}$ and $\frac{n-1}{2}$ + $n$ + $1$ are equivalent.

9
On

Sure, there's nothing strange going on here: these formulas are all equivalent. (Can you prove it?) Hint: if $n$ is odd then $\lfloor \frac{n}{2} \rfloor = \frac{n}{2} - \frac{1}{2}$.