by FartyMcFarter · 3y ago · 0 comments
> The length of a non-trivial cycle is known to be at least 186265759595.
This probably makes it very hard to find a cycle unless we know of some properties of the numbers involved in the cycle.
The algorithm alternates between 2 steps: multiplication by 3 +1 followed by division by a power of 2 (equal to the number of trailing 0 bits; on average it divides by 4), etc. (So on average you multiply by 3, but divide by 4.)
This argument simultanesouly 1) motivates the claim of the conjecture 2) predicts that the cycle length is unlimited (but always finite).
So on average, we multiply a "random" odd number by 3, but divide it by 4.
So yes, it is "mathematically correct" in a very real sense. It's a bit weird that you felt the need to claim it's incorrect, without explaining why.
[1] Think of grouping the integers based on how many bits they take up. We're looking at patterns like [1----1] where each "-" has a 50/50 chance of being 0 or 1. For any given window size, this analysis holds, except for a small number of very pathological edge cases that become vanishingly unlikely for even modest window sizes.
[2] It's common to consider each step only applying to odd numbers, and always dividing until the result is odd again. It's clear that any analysis on this "simplified" version trivially extends to the evens as well.
[3] This shouldn't actually be taken as a given, since we've modified our original bit distribution by multiplying by 3, but it is true, which you'd probably agree with if you played around for a bit with multiplying random bits by 3. You can figure out the distributions of the resulting bits (include the carry bit as well). The highest bit can be wonky, but the probability that the run of zeroes reaches the highest bit vanishes as the window size grows.
Sorry for being terse in my original comment. I should have elaborated.
Neither of these are rigorous demonstrations but without some kind of evidence to indicate the contrary, or a proof, I think OP was right to state that this claim is neither common sense or mathematically correct.
Below is a script you can use to empirically test the bias for yourself (or identify a mistake that I've made):
def count_bits(n):
count = 0
while n:
count += n & 1
n >>= 1
return count
def experiment(count):
count_0_bits = 0
count_1_bits = 0
for i in range(1, count, 2):
num = 3 * i
num >>= 1 # Remove the least significant bit
count_1_bits += count_bits(num)
count_0_bits += num.bit_length() - count_bits(num)
print(f"count: {count}")
print(f"0 bits: {count_0_bits} {count_0_bits / (count_0_bits + count_1_bits)}")
print(f"1 bits: {count_1_bits} {count_1_bits / (count_0_bits + count_1_bits)}")
print("")Edit: The cycle length seems to have gotten longer since I last checked.
Given a number N with prime factors (p1, p2, …pn) And N+1 with prime factors (q1, q2, …qm)
What is the relation between (p1, p2, …pn) and (q1, q2, …qm)