考拉兹的蚂蚁
Collatz's Ant

原始链接: https://gbragafibra.github.io/2025/01/08/collatz_ant2.html

这篇博文探讨了使用一种名为“Collatz蚂蚁”的朗顿蚂蚁变体对Collatz序列进行新颖的可视化方法。蚂蚁的移动由Collatz函数决定:偶数时顺时针旋转90°,奇数时逆时针旋转90°,翻转单元格状态并在每一步前进,直到到达1。 可视化方法并非翻转状态,而是统计蚂蚁访问每个坐标的次数,从而创建景观表示。对这些景观的分析揭示了相似景观与相似(或相同)停止时间之间的相关性,但反过来并不总是成立。收敛的子轨迹呈现出视觉上相似的景观,通常根据步数差异进行旋转。随着起点差异(以及Collatz函数应用次数)的增加,生成的景观的相似性降低,最终细节丢失。

一位Hacker News用户lapetitejort观察到关于考拉兹猜想的一个模式,该模式基于追踪一个数字到其下一个最小值的路径。他们用奇数步和偶数步(奇数步之后隐含一个偶数步)来表示该路径。他们注意到,遵循相似模式的数字通常符合5 + k(2^n)的形式,其中'n'是偶数步的个数。例如,5、9、13和17在归约到其下一个最小数字时具有此特性。 另一位用户kr99x回应说,这种方法已经被探索过了,但不幸的是它导致了一个“死胡同”。虽然可以生成覆盖一部分整数的无限“归约形式”,但由于3的幂的影响变化,实现完全覆盖变得很困难。即使接近完全覆盖,有限数量的非归约数的存在也可能允许出现其他循环,从而无法最终反驳无限增长的说法。尽管这种方法不太可能证明该猜想,但它仍然有用。 讨论涉及到一些策略,例如对偶数进行短路以及对较大数字使用bigint数据类型,并参考了相关的资源,例如考拉兹猜想的奇偶序列表示。
相关文章
  • (评论) 2024-01-05
  • (评论) 2024-05-25
  • BB(3, 4) > 确认(14) 2024-05-25
  • (评论) 2024-03-17
  • 使用哈希函数生成过程纹理 2025-04-18

  • 原文

    This is a brief continuation of a previous post (Repo), which introduced such visualization for collatz sequences based on Langton’s Ant.

    Collatz’s Ant is based on the collatz function:

    \[f(n) = \begin{cases} n/2 & \text{if} \quad n \equiv 0 \quad (\text{mod}\, 2) \\ 3n + 1 & \text{if} \quad n \equiv 1 \quad (\text{mod}\, 2) \\ \end{cases}\]

    and additionally, if $n \equiv 0 \, (\text{mod}\, 2)$ the ant turns 90º clockwise, else the ant turns 90º counter-clockwise. On both accounts, the state of the cell is flipped and the ant moves forward one unit. This is repeated until $n = 1$. An example of such is present in the following animation:

    Example of consecutive trajectories from $n = 10^{40}$ to $n = 10^{40} + 20$.

    And although this representation is interesting, the flipping of state can eventually lead to ambiguous scenarios where trajectories seem similar to each other through omission.

    Given that, the following picture corresponds to the ant’s landscape (final snapshot) without state flipping for the same trajectories, along with respective stopping times. This is done by merely adding a $+1$ count to each coordinate the ant has been through.

    Some other examples

    The first 100 numbers from $n = 2$ to $n = 102$.

    From $n = 10^{9}$ to $n = 10^{9} + 100$.

    From $n = 10^{20}$ to $n = 10^{20} + 100$.

    From $n = 10^{200}$ to $n = 10^{200} + 10$.

    Some interesting things

    If we check the similarity between both of these trajectories:

    import numpy as np
    import mpmath
    
    def collatz_seq(n):
        seq = []
        while n != 1:
            seq.append(n)
            if n % 2 == 0:
            	n /= 2
            else:
            	n = 3*n + 1
        return seq
    
    mpmath.mp.dps = 22
    n1 = mpmath.mpf("1e20") + 1
    n2 = mpmath.mpf("1e20") + 16
    len(np.intersect1d(collatz_seq(n1), collatz_seq(n2)))
    

    If the same is done between $n = 10^{20} + 16$ and $n = 10^{20} + 20$, which have similar landscapes and the same stopping time, we get:

    • Furthermore, if we now look at an example of sub-trajectories converging, in this case with a difference of 5 steps between each, we can see that the landscapes are pretty similar to each other, but for the rotation (which seems to overall be of 90º). This is of course the product of the early re-orientation of the ant given those 5 extra steps.

    Example with $n = 18750000000000000004$ and $n = 10^{20} + 16$, the former being found after 5 reduction steps of the latter.

    Now with a difference of 100 steps, the landscapes still seem very similar but for a rotation of 180º.

    With a difference of 200 steps, the landscapes start losing some detail relative to each other.

    And with 300 steps, only a few larger-scale characteristics are now common between the two landscapes.

    Back

    联系我们 contact @ memedata.com