Collatz’s Ant

(gbragafibra.github.io)

111 points | by Fibra 4 days ago ago

12 comments

  • thomascountz 2 days ago ago

    For those interested, see Daniel Shiffman's Nature of Code[1], a book in which you go from simple "ant" simulations to machine learning, neuroevolution, and NEAT using p5.js for graphics.

    [1]: natureofcode.com

  • keepamovin 2 days ago ago

    This is so interesting: not just this visual rep but the conjecture generally, and the iteration's production of 'pseudorandom' patterns.

    Hints at deep stuff between the two simplest prime divisors of integers: 2 and 3, you have this iterated function that branches based on divisibility by 2 and changes proportional to 3. The addition of plus one really throws a spanner in the works, ensuring it's no longer divisible by 3, but whether it's divisible by 2 or not after the addition seems almost 50-50.

    So cool - one day we will unravel all these patterns, see the higher order of which these are simpler cases glimpsed partially and it will all make sense! :)

    • JadeNB 2 days ago ago

      > Hints at deep stuff between the two simplest prime divisors of integers: 2 and 3, you have this iterated function that branches based on divisibility by 2 and changes proportional to 3. The addition of plus one really throws a spanner in the works, ensuring it's no longer divisible by 3, but whether it's divisible by 2 or not after the addition seems almost 50-50.

      Are you sure you said what you mean? If `n` (is an integer that) is not divisible by 2, then `3n + 1` always is. Maybe you were thinking of the model that incorporates this by replacing the iteration formula for `n` odd with `(3n + 1)/2`?

      • keepamovin 2 days ago ago

        Haha you are right! I might have been thinking of that, thanks for your charitable generous interpretation - or I might have been confused. I think I was just confused here, but good point.

        I guess it's the n/2 one whose divisibility by 2 becomes uncertain. I think I looked at the formula and thought 3n+ 1 if 3n + 1 ~ 1 (mod 2), not 'if n ~ 1' haha that was funny! :)

        Thanks again :)

        edit: Also what a lovely way to correct someone -- 'said what you mean' -- I am gonna use that! :)

  • wcerfgba 2 days ago ago

    I'd like to see this for smaller n, to see if there are motifs or patterns, which can be used to implement memoisation like Hashlife (https://en.m.wikipedia.org/wiki/Hashlife), or to reveal new formulas for exploring Collatz sequences with.

    • Fibra 2 days ago ago

      Good idea. Although, from the little exploration I did with examples for small n, given the low stopping times, the behaviour was very boring. Nothing necessarily interesting. But then again, I didn't explore it exhaustively.

      • wcerfgba 2 days ago ago

        Exactly, so I'm wondering if it's possible to detect those smaller patterns in the bigger ones?

        • Fibra 2 days ago ago

          I'm not sure. I'll explore it a bit. Feel free to fork it and explore it yourself!

          • johngossman 2 days ago ago

            Warning: huge amounts of compute time have been spent trying to find a counter example to this conjecture, which almost everyone believes is true. I kept my office warm this way one winter. It has been described as a way to turn pure Platonic mathematics into heat.

            Always interesting to try to visualize something though.

            Ps -- I implemented hashlife one time. Still amazed someone came up with that algorithm

      • JadeNB 2 days ago ago

        > Good idea. Although, from the little exploration I did with examples for small n, given the low stopping times, the behaviour was very boring. Nothing necessarily interesting. But then again, I didn't explore it exhaustively.

        Long and/or large excursions can happen even for small n! As mentioned at https://en.wikipedia.org/wiki/Collatz_conjecture#Empirical_d... , for example, 27 meanders for quite a while before reaching the inevitable cycle.

  • travisjungroth 2 days ago ago

    Color or grayscale changes on a cell for repeat visits would be cool.

  • easwee 2 days ago ago

    Lovely.