Music And Mathematics Of Fractal-Like Sloth Canon Number Sequences

The Danish composer Per Nørgård uses an endless self similar (fractal like) strict sloth canon structure in some of his compositions such as his Symphony number 2. He first discovered his sequence in 1959.

I came across the idea of a sloth canon number sequence independently, as a mathematician, when I wondered if there is any way to use the Koch Snowflake fractal construction in music. Here it is, starts with a star, adds smaller and smaller triangles to the sides to get the snowflake shape:

I wrote the Tune Smithy program to explore the same sort of construction in music. Surprisingly it turns out to create satisfying music, although it makes no use of normal compositional methods. This reminds one of the visually satisfying fractals which make no use of standard artistic techniques. It may point to a deep connection between fractals and the way we appreciate art and music. For instance fractal patterns have been found in musical compositions, and fractals are prevalent in nature.

Interestingly,  Per Nørgård‘s sequence is constructed in a different way from the Tune Smithy sloth canons. It is a strict sloth canon, but a different sloth canon from the ones I got from the Koch snowflake construction

Construction of Per Nørgård’s sloth canon sequences

This is his sequence on the on-line encyclopedia of integer sequences The Danish composer Per Nørgård’s “infinity sequence”, invented in an attempt to unify in a perfect way repetition and variation 0, 1, -1, 2, 1, 0, -2, 3, -1, 2, 0, 1, 2, -1, -3, 4, 1, 0, -2, 3, 0, 1, -1, 2, -2, 3, 1, ..

It uses two interweaved sequences and the differences between the numbers in the two sequences are used alternately inverted and non inverted to extend the sequences. It has a special type of similarity with its own inversion (i.e. with the signs of the numbers changed).

For a detailed explanation of how it is constructed and exploration of properties of his series it’s best to visit his website: the infinity series

A youtube video of his second symphony: Per Nørgård’s Second Symphony

Construction of the Tune Smithy sloth canon sequences

The Tune Smithy sloth canon sequences are constructed using the idea of a “seed”,

You start with a short sequence of numbers, the seed, for instance 0  1 0.

Now to each of those numbers you add a copy of the entire seed again so add the entire seed to 0 as 0+0, 0+1, 0+0,  add it to 1 as, 1+0, 1+1, 1+0, and finally add it to the final 0 as 0+0, 0+1, 0+0. This is a similar idea to adding triangles on each of the sides of the Koch snowflake.

This gives the new sequence 0, 1, 0, 1, 2, 1, 0, 1, 0.

Now to each of those numbers you add a copy of the entire seed again and keep going to get an infinite sequence.

You then use those numbers for the number of steps to go up or down in your tuning system. So for instance when it says 2, you play the 2nd number in your tune, arpeggio, or whatever it is you use as the basis for your piece of music.

Here it is visually (shows it for A minor pentatonic – any tuning system can be used).

What does it mean to say that these sequences make a sloth canon?

It means that if you take every nth number from the original sequence for suitable n, you get the same sequence again.

So for instance with the fractal tune generated from the 0 1 0 seed in Tune Smithy, if you take every third number in the sequence you get the original sequence again:

This is the Tune Smithy 0 1 0 generated sequence

Number of 1’s in ternary (base 3) expansion of n. 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2,…

So if we underline every third number we get the original sequence again. Numbers highlighted in bold: 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0,….

All the Tune Smithy sloth canon type fractal tunes work that way. This is what makes it possible to use them to make sloth canons.

Here is the same sequence played as a sloth canon in Tune Smithy

Musical sloth canon for number of 1’s in the base 3 expansion of n. 

All five parts in that video are playing the same melody line, at different speeds, so the first violin plays it at the fastest tempo, the second violin (pizzicato) plays it a third of that tempo, the viola, a third again (ninth of original tempo), the ‘cello a third slower again (1/27th), and the double bass, a third slower again, so 1/81th of the tempo of the first violin all playing the same melody line.

There are several more sequences in the database that can be made as Tune Smithy seeds in the same way. So:
number of 1’s in binary expansion of n (or the binary weight of n) 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, …

Musical sloth canon for number of 1’s in the binary expansion of n

– that’s the Tune Smithy sloth canon for the seed 0, 1.

Sum of digits of (n written in base 3) 0, 1, 2, 1, 2, 3, 2, 3, 4, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 1, 2, …

Musical sloth canon for: sum of digits in base 3 expansion of n 

– that’s the Tune Smithy sloth canon for the seed 0, 1, 2

Sum of squares of digits of ternary representation of n 0, 1, 4, 1, 2, 5, 4, 5, 8, 1, 2, 5, 2, 3, 6, 5, 6, 9, 4, 5, 8, 5, 6, 9, 8, 9, 12, 1, 2, …

Musical sloth canon for: sum of squares of digits in base 3 expansion of n

– that’s the Tune Smithy sloth canon for the seed 0 1 4 (played on the minimoog “strawberry flute”)

However there are many self similar, “sloth canon” sequences in the On-Line Encyclopedia of Integer Sequences that can’t be made using the Tune Smithy method. For a list of some of them see Some Self-Similar Integer Sequences

License for these audio and video realizations of number sequences

88x31.png These video and audio realizations of number sequences by Robert Walker are licensed under a Creative Commons Attribution 3.0 Unported License.

No need to attribute if you create your own audio or video realizations of the fractal tune demos provided in Tune Smithy. Attribution required only if you use the particular realizations to audio presented here.

These sloth canon sequences are not the same as “fractal sequences” as mathematicians define them

Confusingly, “fractal sequence” has already been defined in mathematics to mean something different.

An example of a “fractal sequence” is 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, which counts up the number sequence 1, then 1 2, then 1 2 3, then 1 2 3 4, further and further each time and then string all those together to get the result. If you remove the first 1, the first 2, the first 3, and so on you remove the last number of each of those fragments, and so end up with the same sequence again. So it has a self similarity, but this sequence doesn’t play a musical sloth canon, so it is a different type of self similarity.

You can find out more about them here:Fractal Sequence.

So, not sure what to call our “sloth canon sequences”. You can call them self similar sequences, but that doesn’t distinguish them from the fractal sequences as they are also self similar in a different way.

For now, let’s just call them “sloth canon sequences” because when you turn them into music, you get sloth canons if you add extra instruments to play every nth note, and every n2th note and so on.

Another way of looking at the Tune Smithy sloth canon sequences

The idea here is to generalize the result above that the 0 1 0 seed gives you the sequence of the number of 1’s in ternary (base 3) expansion of n, Can this construction using number bases be generalized?

It turns out that we can find a similar definition for any of the Tune Smithy sequences if we use weighted digit sums – the same idea as a Checksum

We can turn any Tune Smithy seed into a suitable weighted sum such that the weighted sum of the digits of n to an appropriate base gives the nth number in the sloth canon sequence for that seed.

Example to show how it works

So given any Tune Smithy seed, beginning with 0, say 0 2 -1.

The idea is – first you set the base for your number system to the length of the seed, here 3

We now need to find a weight to use for each of the digits in our number system – here the digits are 0, 1 and 2…

For the first digit 0, it doesn’t matter what weight you give it as it always multiplies out to give 0 (that is why the seed has to start with 0 for this to work).

We want to evaluate 1 as 2, (to get the second number in the seed), so set the second weight 2.

Then we want to evaluate 2 as -1, so set the third weight to -0.5.

So our weights for the digits are

1, weight = 2
2, weight = -0.5

Now if we find the weighted sum of the digits of n expressed to base 3, we will get the endless tune smithy sloth canon sequence
0, 2, -1, 2, 4, 1, -1, 1, -2,…

So for instance the number 7 (decimal) is 21 (base 3).

The weighted sum of the digits for its digits is 2*-0.5 + 1*2 = 1.

Since we are counting starting from 0, then this is the 8th number in the sloth canon sequence, and as we can confirm, the 8th number in this sequence is 1.

Generalization of the Tune Smithy construction

You can make all the Tune Smithy sloth canons using weighted digit sums in this way, because you just need to choose an appropriate base and a weight for each digit. It is easy to see that the sloth canon construction method for Tune Smithy gives exactly the same result as this weighted sum approach.

Doing it this way though shows that the result isn’t limited to integer sequences. You can also use the same method to create sloth canon number sequences of rationals (fractions) and reals (allowing infinite decimal expansions like PI) and even complex numbers (using square root of -1) by different choices for the weights.

Indeed, for mathematicians, you can also generalize the construction to use any field or ring for the weights,

More digit sum sloth canon sequences in the OEIS

A007953: Digital sum (i.e. sum of digits) of n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10,

A003132: Sum of squares of digits of n 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 1, 2, 5, 10, 17, 26, 37, 50, 65, 82, 4, 5, 8, 13, 20, 29, 40, 53, 68, 85, 9, 10, 13, 18, 25, 34, 45, 58, 73, 90, 16,…

A053737 Sum of digits of (n written in base 4) 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4,

similarly: A053824 Sum of digits of n written in base 5A053827 Sum of digits of n written in base 6A053828 Sum of digits of n written in base 7A053829 Sum of digits of n written in base 8A053830 Sum of digits of n written in base 9 , A053831 Sum of digits of n written in base 11A053832 Sum of digits of n written in base 12,A053833 Sum of digits of n written in base 13A053834 Sum of digits of n written in base 14A053835 Sum of digits of n written in base 15A053836 Sum of digits of n written in base 16,

A173528 a(n) = 1 + sum of digits of n-1 written in base 8A173525 1+A053824(n-1), where A053824 = sum of digits in base 5,

Sums of digits modulo the base

Note, because you need to take the modulus, these can’t yet be played in Tune Smithy directly (though would be easy to add an option to take the modulus).

However you can get the same musical effect if you use an “arpeggio” that wraps around. So for instance with the modulo 5 example, you could choose any of the penatonic arpeggios. To make it wrap around, just add an extra 0 at the end. You can alternatively make a scale wrap around by adding a 1/1 at the end.

Of course it makes no difference to the sloth canon property if you take the modulus:

A053838 (Sum of digits of n written in base 3) modulo 3. 0, 1, 2, 1, 2, 0, 2, 0, 1, 1, 2, 0, 2, 0, 1, 0, 1, 2, 2, 0, 1, 0, 1, 2, 1, 2, 0, 1, 2, … A053839 (Sum of digits of n written in base 4) modulo 4A053840 (Sum of digits of n written in base 5) modulo 5A053841 (Sum of digits of n written in base 6) modulo 6A053842 (Sum of digits of n written in base 7) modulo 7A053843 (Sum of digits of n written in base 8) modulo 8A053844 (Sum of digits of n written in base 9) modulo 9,

What about the other sloth canon integer sequences

The Danish composer Per Nørgård’s “infinity sequence” is an example sloth canon integer sequences which can’t be constructed in this way as weighted digit sums. In fact there are many others.

Another simple example is this one: Write n in ternary, sort digits into increasing order 0, 1, 2, 1, 4, 5, 2, 5, 8, 1, 4, 5, 4, 13, 14, 5, 14, 17, 2, 5, 8, 5, 14, 17, 8, 17, 26, …
It’s a sloth canon sequence with each melody line in the sloth canon slower by a factor of 3 – if you take every third number you get the original sequence again 0, 1, 2, 1, 4, 5, 2, 5, 8, 1, 4, 5, 4, 13, 14, 5, 14, 17, 2, 5, 8, 5, 14, 17, 8, 17, 26,…

When you create a sloth canon sequence as a weighted sum of digits, and with 3 as the scaling factor of the canon, and starting 0 1 2, you get this one:

Sum of digits of (n written in base 3) 0, 1, 2, 1, 2, 3, 2, 3, 4, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 1, 2, …
As you can see it is a different sequence, just the first four numbers are the same (as they have to be of course). It’s also obviously not the same as any weighted sum of numbers in ternary because the first three numbers determine all the rest.

So, it seems that our weighted sum construction hasn’t created all the sloth canon number sequences (though we would need to do a rigorous proof to show for sure that this sequence is not the same as any weighted sum sequence, to show that it is not the same as a sloth canon sequence using some much longer seed)..

There are lots of particular examples of that type on this page: Some Self-Similar Integer Sequences

That then leads into a more general question. Are there any other methods of constructing infinitely many sloth canon sequences? Is there any way to classify all the sloth canon sequences?

General way to make any infinite sloth canon sequence

The observation that makes it possible to generalize this construction is that a sloth canon sequence is under determined, and it doesn’t matter what you put in the gaps.

So suppose the first three numbers are 0 1 2, and you want it to be the same when you take every 3rd number. Then so far these numbers are fixed:

0, 1, 2, 1, *, *, 2, *, *, 1, *, *, *, *, *, *, *, *, 2, *, *, *, *, *, *, *, *, 1, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *

So – in fact infinitely many numbers are already fixed, but they get sparser as you go along the sequence.

We can proceed now by putting anything we like in the next available gap, and fill in any of the numbers that are implied by the sloth canon structure – just two more 15’s are needed in this short fragment but there are of course infinitely many of them in the complete sequence:

0, 1, 2, 1, 15, *, 2, *, *, 1, *, *, 15, *, *, *, *, *, 2, *, *, *, *, *, *, *, * 1, *, *, *, *, *, *, *, *, 15, *, *, *, *, *, *, *, *, *, *, *, *

Then can put anything in the next gap and so continue the process.

0, 1, 2, 1, 15, -22, 2, *, *, 1, *, *, 15, *, *, -22, *, *, 2, *, *, *, *, *, *, *, * 1, *, *, *, *, *, *, *, *, 15, *, *, *, *, *, *, *, *, -22, *, *, *

Obviously you can keep going like that and the result will be a sloth canon sequence, no matter what you do.

Also the other way around, any sloth canon sequence can be constructed in this way because we are just using the rules that define the sloth canon to construct it.

Could this be a useful construction for fractal music for the future?

As described so far, the construction is so general you have to keep making choices as you go along the sequence, so it is a bit to general to be useful for algo comp as it stands.

However, you could use it with a randomizing element – randomly choose the under-determined numbers as you go along.

Or, another idea, you could start with a weighted sum sloth canon, or any other sloth canon such as the infinity sequence – then have some way for the user to adjust any of the numbers that can be adjusted without disturbing the sloth canon property of the sequence. Then automatically adjust all the other numbers in the sequence to match your change.

It is a fair amount of work to do that, and I have many commitments so don’t know if I’ll be able to do it in Tune Smithy in the near future. But perhaps some other fractal music programmers might be interested in the idea?

A consequence of this construction of interest to mathematicians – there are uncountably many sloth canon integer sequences of any similarity period n

First let’s see why this is with a “hand waving” argument.

With the Tune Smithy (i.e. weighted sum) construction method, you can make only countably many sloth canon integer sequences, because you can enumerate all the possible Tune Smithy strict sloth canons by enumerating all possible finite seeds.

But the sequence generated by this more general process can’t be enumerated, because you have infinitely many choices you can make while constructing the sequence using the method just described. You can choose any number you like at each stage in the process.

So there are uncountably many such sequences. Indeed, there are uncountably many for any repetition length n >= 2 as well.

A rigorous proof of uncountability for the general construction

A more rigorous way to show this, we use proof by contradiction as with Cantor’s original uncountability argument for the reals.

So, suppose you had an enumeration of all  sloth canon sequences with self similarity period n = 2 and with first number 0, which we hope will enumerate them all.

We will see if there are any sequences left out of our enumeration.

So far, the first number  has to be 0. But so far the other numbers might be anything.

Now set the 2nd number to any number different from the second number in the 1st sequence in our enumeration. For sake of example, suppose that the second number in the first sequence is different from 3, so we can use 3 here, getting:

0, 3, *, *, *, …

This then determines some more of the numbers like this:

0, 3, 3, *, 3, *, *, *, 3, *, *, *, *, *,

Now set the 4th number in our sequence to anything that differs from the 4th number in the 2nd sequence in our enumeration, again for sake of illustration, suppose that 5 is okay

0, 3, 3, 5, 3, *, 5, *, 3, *, *, *, 5, *,

Similarly, set the 6th number in our sequence to anything that differs from the 6th number in the 4th sequence in our enumeration:

0, 3, 3, 5, 3, 7, 5, *, 3, *, 7, *, 5, *,

and so on.

In this way we get a new sequence which is nowhere in our enumeration. So the enumeration is incomplete.

So usual diagonalization argument, we have shown it is impossible to do it, no such enumeration can exist, so there are uncountably many of these sequences – even in this simplest case of n = 2 and first number set to 0.

Of course you can use the same argument for any n.

If you look at the proof again, then you can see that we could have kept to 0s and 1s all the way through the construction of the missing sequence. So the enumeration always misses out some of those sequences too, So even when you restrict to 0s and 1s for all the numbers, then you can’t enumerate all the possible sloth canon sequences.

Note for mathematicians: I have given definitions and proofs of all this in standard mathematical notation here: The mathematics of sloth canon number sequences It also includes rigorous mathematical proofs of the results discovered by Per Nørgård for his infinity series for anyone who wants to see what the proof looks like when you fill out all the details.

Musical Examples

You can play any of the sequences in the OEIS database using their Music page and enter in the sequence name

OEIS Music page

You can find recordings of Per Nørgård’s symphony number 2, which makes use of his “infinity sequence”, on youtube such as this recording: Per Nørgård’s Second Symphony

For some midi examples of the Tune Smithy type sequences, worked up as actual sloth canons, Tune Smithy Sloth Canons

Here are some of the Tune Smithy fractal tunes using various sloth canon sequences applied to various tuning systems:

Play&Create Tunes as intricate as snowflakes – Videos

For instance the first one uses a sloth canon sequence constructed from the seed 0, 1, 2, 0, 6, 0 using the tune smithy construction method.

This means you can think of the numbers as the weighed sum of the digits in a base 6 expansion with weight
1, weight 1
2, weight 1
3, weight 0
4, weight 1.5 (so the ‘4’ is counted as 6 after weighting(
5, weight 0

and here is the result (it is somewhat “obfuscated” as it is played on a non linearly ordered, microtonal tuning that repeats at the fourth, 4/3, but that makes no difference to the sloth canon properties, it is still a sloth canon type melody, if you take every sixth note in the tune you get the original tune again.):

Tune Smithy Fractal tune for flute played on the Arturia MiniMoog “Strawberry Flute”

Combining these musical fractals with 3D visual fractals

I have recently become interested in the idea of drawing out the parallels between musical and visual fractals by using the Tune Smithy tunes as audio tracks to accompany 3D visual fractals.

Here is a compilation of some of these Mandelbulb 3D fractals with sloth canon sequences.

The first video is the fractal video “Follow Me” by Torsten Stier, winner of the 2012 competition at fractalforums.com As with the other videos used here, he released under the creative share alike license so others are free to remix it and add their own audio so long as they attribute him.
Mandelbulb 3D animated Fractals, with Tune Smithy fractal music 

This is Torsten Stier’s video again, this time with the Golden Ratio Cello tune.
Mandelbulb 3D fractal by Torsten Stier with Golden Ratio ‘cello tune from Tune Smithy 

As usual, the entire tune is generated fractal fashion from the short musical phrase you hear at the start of the video played on the harp.

The Golden Ratio ‘Cello tune shows the capability to play Fibonacci rhythms – these are rhythms that are highly structured on many levels, yet never repeat exactly, so there is no fixed measure size at all at any level.

Fibonacci rhythms are related to David Canright’s “Fibonacci Gamelan Patterns” and to the Penrose non periodic tilings, indeed if you take a row of tiles in a Penrose tiling of narrow and wide rhombs, and turn the sequence of widths into a rhythm, the result is a fibonacci rhythm. I will go into this in detail in a separate article.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s