# The Fascinating World of Recamán's Sequence: Music from Math
Written on
Chapter 1: The Musicality of Mathematics
For an extended period, I have been captivated by the convergence of music and mathematics. This intrigue sparked after I encountered the 1985 Scientific American cover story on the Mandelbrot set, leading me to explore how mathematical concepts can be translated into musical forms. I now instinctively perceive mathematical patterns as music, envisioning the sounds that emerge from numerical sequences.
Recently, while browsing through Numberphile videos, I came across one featuring Neil Sloane, a renowned British-American mathematician recognized for establishing the Online Encyclopedia of Integer Sequences (OEIS). Although I can't recall the video's specific focus, Sloane mentioned that he considers Recamán's sequence to be one of the most musically appealing sequences in the OEIS. Intrigued, I delved into understanding this sequence.
Understanding Recamán's Sequence
The method for generating Recamán's sequence is straightforward:
- If the result of subtracting the index ( n ) from the previous term is negative or already exists in the sequence, we add ( n ) instead.
Let's compute the initial terms:
- ( a_0 = 0 )
- ( a_1 = 0 + 1 = 1 ) (Since ( 1 - 1 = 0 ) is in the sequence, we add ( 1 ) to ( 0 ))
- ( a_2 = 1 + 2 = 3 ) (Since ( 1 - 2 = -1 ) is negative, we add ( 2 ) to ( 1 ))
- ( a_3 = 3 + 3 = 6 ) (Since ( 3 - 3 = 0 ) is already in the sequence, we add ( 3 ) to ( 3 ))
- ( a_4 = 6 - 4 = 2 )
- ( a_5 = 2 + 5 = 7 )
This results in the beginning of the sequence:
{0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, 63, 41, …}.
To visualize these terms, the following plots illustrate the first 100 and 1000 values:
The pattern becomes more apparent when we observe the first 24,000 terms, highlighting alternating sets of even and odd indices where adjacent elements shift by 1.
The sequence's behavior is a curious blend of unpredictable chaos and occasional order. The intrigue lies in its complexity, which mathematician Bernardo Recamán Santos shared with Neil Sloane in 1991, leading to its official recognition in the OEIS.
Visualizing Recamán's Sequence
Edmund Harriss, a mathematician and artist, devised a compelling method to visualize Recamán's sequence by connecting adjacent terms with semicircles. Below is a colorful representation of the first 100 terms:
For those interested in creating similar visualizations, here is a simplified pseudo-code to achieve the above effect:
#For a recamanSequence of length n:
# Define plot range
plotRange = {{-5, 235}, {-60, 60}}
# Calculate aspect ratio
aspRat = The y range divided by the x range
# Define frame function
function frame(i):
# Initialize an empty list to hold arcs
arcs = []
# Loop through the Recamán sequence up to the index i
for j from 1 to i:
# Calculate center and radius of the arc
center = (recamanSequence[j + 1] + recamanSequence[j]) / 2
radius = Absolute difference of recamanSequence[j + 1] and recamanSequence[j] / 2
# Determine start and end angles based on whether j is even or odd
if j is even:
startAngle = 0
endAngle = Pi
else:
startAngle = Pi
endAngle = 2 * Pi
# Add the arc to the list with a specific color
arcs.append({Hue of j divided by n, Circle with center, radius, startAngle, and endAngle})
# Generate and return the graphical representation
return Graphics of arcs with background black, aspect ratio->aspRat, axes off, plot range->plotRange, and image size->800
# Call frame function with n - 1
frame(n - 1)
For those using Mathematica, a ready-to-go notebook is available, along with various visualization approaches online.
Sonifying the Sequence
Now that we understand the sequence's behavior, let’s explore its auditory representation. Below is the audio for the first 2048 terms, derived directly from the OEIS "Listen" page. Musical instruments have limitations, so the terms are converted modulo 88 (the MIDI value corresponds to the remainder when divided by 88).
Here is a piano roll view illustrating the first 60 measures:
In an effort to make the sound more accessible, I decided to use a pitch modulus of 96, allowing for a full 8 octaves. I utilized the hexatonic blues scale, which incorporates the flatted fifth degree. Additionally, I added a bass line to outline a variation on the 12-bar blues, complemented by African drumming to enhance the rhythmic experience.
The resulting composition, titled Recamán's Blues, exemplifies the dialogue between the sequence and itself, echoing a compositional technique known as "call and response."
For a visual representation, the final animation combines generated frames and audio, synchronizing them for an engaging display.
Recamán's sequence remains a captivating mystery, inspiring variations and applications in diverse fields, including steganography. This sequence, much like the logistic map, Mandelbrot set, and cellular automata, serves as a stunning example of how simple mathematical principles can yield unexpectedly intricate and beautiful patterns.
If you found this exploration of Recamán's sequence enlightening, consider clicking the "Applause" icon and subscribing for more intriguing content on mathematics and science.
Further Resources
- Alternative visualization techniques
- David Eppstein's exploration of the sequence's growth
- Python code by Luke Polson for direct audio conversion of the sequence
- An interactive app for sequence exploration by Kelley van Evert
- A popular Numberphile video featuring Alex Bellos discussing the sequence
The second video provides an insightful take on Recamán's sequence, enhancing our understanding of its unique properties and musical qualities.