Strictly Diatonic Sequences
You are seated at a piano. You will focus on the white keys only. You will concentrate on pitch alone. Rhythm and other factors will come later.
Strike any key, preferrably one somewhere near the middle of the keyboard. This is the first note of your melody.
Next, continue the melody you have thus begun. Follow these rules:
Well-known melodies often obey these very rules, at least part of the time. Here are a few examples:
"What's it all about," follows the rules; "Alfie?" doesn't.
"Merrily, we" follows the rules; "roll along, roll along, roll along." doesn't.
"Row, row," doesn't follow the rules; "row your boat" does.
One feature of many good melodies, in fact, is precisely a contrast between following these rules and defying them. The three melodic fragments given above show this contrast.
Music to Mathematics
Think of a melody as a sequence of numbers. All aspects apart from pitch will be ignored, for the moment.
In numerical terms, the rules given above might be rewritten somewhat like this:
Full rigor would demand that we nail down a few more details. I like to work with positive numbers and zero, but negative numbers can be used.
Before we examine any interesting sequences, let us first look at a few boring ones. We do this mostly just to get comfortable with the rules we will be working with:
All those sequences are legal. The first one reminds us that the sequences can be of any length.
Strictly speaking, a sequence of length zero ought to be legal as well. As music, silence isn't very interesting but it is legal.
The second sequence is a reminder that we can begin anywhere.
The last three are limited to the numbers one and two. Not interesting, but fully legitimate.
Here are two somewhat more interesting examples:
Interesting? What makes those more interesting?
"Interesting" is always subjective, of course. But certainly these two examples reveal more interesting patterns than do anything labeled "boring," above.
Consider the upper one first, 1 2 1 2 3 2 1. The first three numbers provide a tiny cycle of their own, 1 2 1. Now look at the last five numbers out of the seven, 1 2 3 2 1. Note that the third number out of the seven functions both as the end of the earlier sequence and as the beginning of the later sequence.
In the lower sequence, it is natural, perhaps, to divide the eight numbers into two sets of four. The first one is 1 2 3 2, and the second one is 1 2 3 4. They differ from one another only in their final numbers.
At the same time, several sequences of a more symmetrical, even palindromic, nature can also be found. The first five numbers are 1 2 3 2 1. Numbers three through seven provide 3 2 1 2 3.
For me, "interesting" usually means providing diverse ways of analysis, breakdown, and interpretation.
Length of Run
One favorite mathematicians' trick is to figure out how to specify things compactly. That is what we will look into next.
How can we record, or specify, or nail down precisely, some given sequence? How can we achieve this in a minimum amount of space?
Mathematicians are famous for solving whatever problem they are working on at the moment by reducing that problem to some other problem—one that they've already solved. We can't quite do that here, for we haven't already solved any problems. But we can make use of another famous trick. We can examine everything that we have decided will be true for all of the sequences that we are trying to pin down, and we won't bother to include any of that agreed-upon information in our specifications.
We should begin by naming the number where our sequence begins. There's no way of getting around that.
Once the beginning point has been supplied, the very next member of the sequence (if, indeed, there is one!) can only be one number smaller or one number larger than the beginning point. Let's see if perhaps we can gain something by beginning with a number (the beginning point) and a direction (upward or downward).
We don't have to specify the fact that all adjacent numbers in our sequence differ from their neighbor or neighbors by one. That fact is built into all of the sequences that we are working with.
One thing that isn't built in, however, is the lengths of the various runs in one direction, then the other, then the other.
Suppose we examine a sequence and use it to figure out how these sequences can be specified succinctly.
1 2 3 4 3 4 3 4 3 2 3 4 5 6 5 4 3 4 3 4 3 2 1
That's a nice, juicy one. It ought to give us plenty of room.
First, we record that the beginning number is 1. Next, we note that the sequence takes off upwards from there.
One way of making these two facts succinct would be to say "1+" at the beginning of our specifications.
The first "run" is from 1 up to 4. The length of that run is the number of consecutive moves in the same direction. Here, that's three; the first from 1 to 2, the next from 2 to 3, and the last from 3 to 4. So our first run is of length 3. Our specification might begin: "1 + 3."
Next, the sequence moves from 4 down to 3, but it doesn't go any lower. The next number is another 4. So the second run is of length 1: "1 + 3 1."
The sequence seems to be wiggling back and forth between 3 and 4. Counting them all gives us a total of 5 ones in a row: "1 + 3 1 1 1 1 1."
The next run goes from 4 down to 2; that's of length 2. Next is a run from 2 up to 6, and that's of length 4: "1 + 3 1 1 1 1 1 2 4."
Continuing to the end of the given sequence, our shorthand specification reads: "1 + 3 1 1 1 1 1 2 4 3 1 1 1 1 2."
That covers the entire sequence. We've shortened our designation by a good bit, from 52 characters (including spaces) to 31 characters.
Diamonds in the Rough
The sequence examined just above was thrown together impromptu. But there are algorithms and other procedures that can also create these sequences. Let us examine one family of them.
Recall the two "interesting" sequences given above.
Each of them is the beginning of one of the sequences that we will examine next.
A "gray code" is any system that renders adjacent numbers similarly in a particular way. First, the representations of any two adjacent numbers must differ in only one position. Second, at that position, the two representations must differ only by one.
Now if those facts don't seem suggestive, I don't know what does.
Let us next examine a few numbers, with their regular bit-patterns and also with their rbgc bit-patterns.
|Number||Binary Pattern||RBGC Pattern|
Now try counting the number of ones in each four-bit pattern in the column in the middle. Notice something familiar? As you climb upward from 0 (or downward in the chart), the total-of-ones figure forms a sequence that obeys all our rules.
Here's the same table again, with that feature now made obvious:
|Number||RBGC Pattern||Number of Ones|
Reading down the rightmost column, you will see a sequence that obeys all our rules.
1 2 1 2 3 2 1 2 3 4 3 2 3 2 1
Here is the "run length" rendering for that sequence:
1 + 1 1 2 2 3 2 1 2
Finally, we will look at the numbers from 0 to 27 using base three:
|Number||Ternary Pattern||TRGC Pattern|
Finally, here are the same 27 patterns, this time with the sum of base-three digits shown as well:
|Number||TRGC pattern||Sum of Trits|
Reading down the rightmost column again, we have the following sequence:
0 1 2 3 2 1 2 3 4 5 4 3 2 3 4 3 2 1 2 3 4 5 4 3 4 5 6
Rendering this sequence into our "compacted" format, we end up with:
1 + 3 2 4 3 2 3 4 2 3
One of the prime applications for me is simple ponderment. I look at sequences. I play sequences on the keyboard.
In making abstract animations, long sequences of numbers can sometimes be used to dictate which still frames to insert into long stretches of individual frames.
In working with frieze patterns of integers, one often needs a zigzag pattern for a left border. Such zigzag patterns are easily created from sequences such as the ones we are working with here.