Many forms of Collatz conjecture
Computational art, at least my own, is very explicable. There is no mystery in the code itself nor in the way I arrived at it. The code is short. I only have a handful of algorithms behind my belt. My methods are even more finite. They are two:
- intend to do one thing, but make an error (while walking through a tutorial, mimicking nature, reproducing someone else's work)
- having something already working, ask "what if" ("what if each time the ant visits a cell I grow the line by 1px?")
The result to which those two paths lead is but one. It's always a combination of two algorithms invented by me or by people before me. The first of the two algorithms is a source of entropy: Perlin noise by a wide margin, a random number generator, or the real world (the value of pixels in a photo). I use the Collatz sequence as a source of uniqueness with a recognizable footprint. Unlike noise, the Collatz sequence is deterministic, but numbers never end, and you can cut a random slice from it.
The Collatz hypothesis is that you'll get 1 out of any positive number if you do this: an even number divide by 2, an odd number multiply by 3 and add 1, 3n + 1. Same thing with the result. Continue until you get 1. This hypothesis isn't proved, although in the LLM era it's not for long.
The Collatz sequence was depicted as a graph, but in 2016 the mathematician Edmund Harriss drew it as a coral in his coloring book Visions of the Universe. He made an adjustment to the Collatz rule: if a number is odd, not only multiply it by 3 and subtract 1, but also divide by 2: (3n - 1) / 2. This division by two shortens the branches. It's possible because 3n - 1 is obviously even. In the visualization itself an odd number turns the branch segment a bit (8°) to the left. If even, twice as small (4°) but to the right. To mimic actual growth, larger numbers get shorter segments. That is, segments get generally smaller towards the tips. Finally, only a finite sample is selected from the range, however long it is. Branches are rendered only for this sample. This sample is random, and it allows us to see the coral shape on an extremely wide range, e.g. 1-20000000000000.
I learned about the Collatz conjecture through Daniel Shiffman's tutorial, walking through it on my flight home. Watching my screen melted the heart of my neighbour, an elderly German engineer, who moments earlier had been throwing a tantrum about being seated in the wrong row. Certain two angles indeed produce a touching version of the coral: in it two cardiovascular knots extend their tendrils towards each other. They are connected with an "arteria" of 122-244-488-325-.... Having landed and gotten home, I handed the SVG over to the plotter. The document had one or two thousand curves. Predictably, the plotter soon dug a tranchée where the root 8-4-2-1 was. That's what happens with paper when you draw over the same line a few hundred times.
This shows the sequence as your regular graph and as a coral. Some branches contain numbers much bigger than the branch tip, because it's sometimes multiplied by 3. This is especially true for the branch with 27 at its tip. This branch is a distinct spine in most Collatz visualizations. This sketch shows what happens if our range is not all the way from 1 to 100, but is instead 80 to 100. The growth preserves its shape, but branches grow thin. Choosing a different root will keep just a part of the growth.
My artwork combines two algorithms: the spiral walks along the Collatz. The spiral is a modified noise loop from Daniel Shiffman's tutorial, again. The radius variation in a single loop is very slight compared to the tutorial, but it adds to the irregularity. The plot is done with a gel ballpoint. We doodle with a ballpoint when we are bored, in improper places. The plotter lifts this boredom to an inhuman level.
The Collatz sandbox has some more shapes besides the coral. If the formula for odd numbers is divided by 3, 4, 5 or 6, it's parsley or dill. Different angle combinations give a mesh, a sponge, paper clips, thorns.
In the coral, the angles are accumulated, but if they aren't, it gives an ever-changing fish-scale pattern. It moves endlessly in one direction and a bit sideways.
As always, there is an error. Having walked the coral far and wide, let's go back to the original Collatz binary tree. I took a tree with just a few branches and ran a bunch of lines along, splitting the bunch on every fork. The initial bunch has to be thick enough so that there are at least 20 lines per branch, enough to mimic a thick stroke while plotting with a 0.5mm ballpoint. So far so correct. The error is in calculating the "y" of the nodes where the numbers are. The positions are inadvertently sorted by node values. Additionally, they are compacted: in the row of nodes, if there is no node 0 (the branch ended), then node 1 takes its place. Because of the sorting the branches cross each other, and because of compacting they diverge. The "Error" toggle in the control panel fixes it. However, with an error the tree looks like vyaz. Without the error it's a boring binary tree, which does not benefit from the Collatz sequence.
I made a vyaz artwork ten years ago. I worked in Yandex back then, and they used to say «погрепай логи» a lot. I wrote this anglicism in Slavic vyaz. The contrast of the old Slavic writing and the modern slang was fun. My fellow programmer Lyosha says he still prints the t-shirts with this vyaz, and it made it to the paper of another yandexoid Alexey Tikhonov. That was a meaningful, semantic vyaz. Now I have asemic vyaz. The letter is a range from the Collatz sequence, a very short one, e.g. 400-403, so that there are 3-4 branches.
The last sketch is the same erroneous Collatz graph as in vyaz, but taken to the maximum to waste the plotter's time and a few pens.
All the sketches in the article use only the even / odd property of the numbers. At most, they sort the siblings in ascending order. None of the sketches explores the value of the numbers. And to plot a sketch repeating the same lines over and over until they dig a groove in soft paper could be a project on its own.
References
- Harriss, Edmund (2016). Collatz seaweed. Made for Visions of the Universe, with Alex Bellos.
- Lagarias, Jeffrey C. (1985). The 3x + 1 problem and its generalizations. The American Mathematical Monthly, 92 (1): 3–23. Quoting Paul Erdős: "Mathematics may not be ready for such problems."
- Lagarias, Jeffrey C., ed. (2010). The Ultimate Challenge: The 3x+1 Problem. American Mathematical Society. "An extraordinarily difficult problem, completely out of reach of present day mathematics."
- Shiffman, Daniel. Coding the Collatz Conjecture. The Coding Train.
- Shiffman, Daniel. Coding Challenge #136.1: Polar Perlin Noise Loops. The Coding Train.
- Tikhonov, Alexey (2024). AutoVyaz: Automating the Formation of Slavic Calligraphy Ligatures. Proceedings of the 19th International Conference on the Foundations of Digital Games.
- Wikipedia. Collatz conjecture. "The conjecture is that these sequences always reach 1, no matter which positive integer is chosen to start the sequence."