Collatz’s Ant

4 comments

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

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! :)

> 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`?

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.

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.

> 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.

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

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

Lovely.