Sounds of the Collatz Conjecture: Generating Music from the 3x + 1 Problem

118,537
0
Published 2024-04-15
Using sequences from the famous unsolved Collatz conjecture to generate musical passages as MIDI notes.

The Collatz conjecture is also known as the 3n + 1 problem, the 3x + 1 problem, the Ulam conjecture, Kakutani's problem, the Thwaites conjecture, Hasse's algorithm, or the Syracuse problem.

Different strategies are used to map the "hailstone sequences" into sequences of MIDI note numbers, including a straightforward "additive" numerical mapping, "directional" mappings using fixed jump sizes, and mappings based on pitch class.

These visualizations were written in Java using a graphical library called Processing (processing.org/), and Java's built-in MIDI library for generating MIDI data (package javax.sound.midi).

0:00 The Collatz Conjecture
1:27 Mapping to MIDI Notes
2:07 Strategy No. 1
4:03 Strategy No. 2
4:45 Strategy No. 3
5:21 Strategy No. 4
5:54 Strategy No. 5
7:18 Strategy No. 6
8:04 Strategy No. 7
9:12 Extra Long Example

________

Interested in learning more about algorithms, math, and how to program? Here are some useful and/or classic textbooks that I recommend (these are affiliate links, if you buy one, I get a small commission):

▶ "The Ultimate Challenge: The 3x+1 Problem" by Jeffrey C. Lagarias: amzn.to/4aVejxH
▶ “Algorithms” (4th Edition) by Robert Sedgewick & Kevin Wayne: amzn.to/3uo25xR
▶ “Effective Java” (3rd Edition) by Joshua Bloch: amzn.to/3HOnYJL
▶ “Design Patterns: Elements of Reusable Object-Oriented Software” by Erich Gamma, Richard Helm, Ralph Johnson, & John Vlissides: amzn.to/49fpr7R
▶ “Discrete Algorithmic Mathematics” by Stephen B. Maurer & Anthony Ralston: amzn.to/4bmsOvG

#math #music #musictheory #unsolved #patterns #code #java #software #computerscience #visualization #algorithmicmusic #algorithmiccomposition

All Comments (21)
  • @LuckyLootCrate
    I love that 8421 ‘motif’ for all the strategy 1s, it sounds kinda like the game over theme for all the failed attempts to disprove the Collatz Conjecture
  • @HollywoodF1
    I can see why proving this is so enticing for mathematicians— the patterns start to jump out, which is red meat to a mathematician.
  • @trulyunknowable
    I love how the sequence starting on 27 using pitch classes has those funny little runs of little trills, particularly the modulo 12 system
  • @kinghotcoc0
    I love the use of a marimba for the first few sequences.
  • @Caesq_r
    everybody gangsta until a node hits 16
  • I'm both a computer programmer and a musician so I find this very interesting. It's remarkably musical. I think your choice of sound is great. These sequences would make wonderful percussion solos in a large ensemble (orchestra, brass band, concert band etc) piece. I wish that I could compose. Thanks very much for this.
  • @MabInstruments
    I'm interested in what it sounds like if you just use the number as a frequency with the units chosen so that 1 is the lowest pitch that can be heard (usually about 20Hz). This makes halving the number musically meaningful because you go down exactly one octave. Multiplying by 3 and adding 1 is slightly more complicated. Multiplying by three is going up an octave plus a perfect fifth. Adding one makes it more than that, exactly how much depending on how high the number was. For example, 3→10 is going up an octave plus a major sixth. 5→16 is going up an octave plus a minor sixth. This system would allow numbers up to about 1,000 for someone with good hearing.
  • @Antikas1989
    Nice. It would be cool to try something like mod 144. Limits the range but uses more of the keyboard than just the pitch class.
  • I think the main reason it sounds more musical than a random sequence of notes is that every time it goes up it must go down on the next step, since if n is odd then 3n+1 is even. I'm guessing if you removed that regularity and used f(n) = n/2 if n is even, (3n+1)/2 if n is odd it would just sound random.
  • @DendrummerMC
    I once did an experiment where I used the Collatz conjecture to determine the length of a section in 8th notes. It came out rather decent, rendered an accompanying animation with blender and sent that in for my composing class "exam" in music school a couple of years ago. Edit: had to look it up to be sure but... I started from 25, which gave a nice balance of number of numbers and not going absurdly high
  • @FetchTheCow
    You should try this with a pentatonic scale. It would probably sound more sonorous and pleasant.
  • When I was in college I made a little box where you hit a button a certain number of times and it would play a MIDI sequence based on the hailstone sequence generated from the total number of button presses, then challenged my classmates to make the longest sequence they could as my midterm project. They hated it
  • Amazing video. I really really like your channel content! Keep it up.A few days ago I asked chatgpt about possible analogs of circle of fifths in 3 dimensions, 4 dimensions or higher. And I got interesting resultings every time I asked. It would be amazing if you do an video about it. I will paste some interesting results here: Sure, here are a few potential higher-dimensional analogs of the circle of fifths: 1. *Sphere of Harmonic Relationships:* Imagine a three-dimensional sphere where each point represents a musical key, and the distance between points indicates the harmonic relationship between those keys. This model could incorporate not only fifths but also other intervals and harmonic concepts. 2. *Hypergraph of Musical Elements:* Visualize a hypergraph where each node represents a musical element (such as keys, chords, modes, etc.), and hyperedges represent relationships between multiple elements. This could capture complex relationships beyond just linear progressions. 3. *Tensor Representation:* Utilize a tensor framework where each dimension represents a different musical element (e.g., keys, chords, time signatures), allowing for a multidimensional representation of musical relationships. 4. *Topological Map:* Create a topological map where musical elements are represented as points on a surface, and the topology of the surface captures relationships between elements. This could provide a geometrically intuitive way to explore complex musical structures. Ok other results from chatgpt with slightly different question about hyperdimensional circle of fifths: : 1. **Multi-dimensional Pitch Space**: Some music theorists and composers have conceptualized pitch relationships in multi-dimensional spaces beyond the traditional linear or circular representations. These spaces can include dimensions for pitch height, duration, timbre, and other musical parameters. 2. **Spectral Analysis**: In the field of spectral music, composers like Gérard Grisey and Tristan Murail have explored the use of multi-dimensional pitch spaces based on the analysis of sound spectra. These spaces represent complex relationships between harmonic partials and timbral characteristics. 3. **Mathematical Models**: Mathematically inclined composers and theorists have investigated higher-dimensional spaces using concepts from topology, group theory, and other mathematical frameworks. These models aim to represent the intricate relationships between musical elements in more abstract and complex ways. 4. **Interactive Visualization Tools**: With advancements in digital technology, there have been efforts to develop interactive visualization tools for exploring hypertonal analogs and multi-dimensional pitch spaces. These tools often allow users to navigate through complex musical structures and relationships in real-time.
  • Perhaps limit it to a particular key scale, major or minor instead of chromatic?
  • @davidzaydullin
    another idea i came up with: using microtonal scale with logarythmic frequencies. difference between big numbers in your examples are much bigger than between small ones, so log scale can help with it. we already percieve freqeuncies logarithmically, so this scale will basically be smth like "next note is 10hz higher than the previous one" instead of 12EDO "next note is twelfth root of two times higher than the previous one"