Steve Whealton








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:

  • Do not repeat notes.
  • Move stepwise only.
  • Stop any time.

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:

  • Do not repeat a number.

  • Move to a number one larger or one smaller than the previous number.

  • Stop any time.

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.

 

Examples

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:

 

  1. 1

  2. 67

  3. 1 2

  4. 1 2 1

  5. 1 2 1 2 1 2 1 2 1 2 1

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:

 

  1. 1 2 1 2 3 2 1

  2. 1 2 3 2 1 2 3 4

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).

What next?

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.

 

Example

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.

 

Gray Codes

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
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000

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
0 0000 0
1 0001 1
2 0011 2
3 0010 1
4 0110 2
5 0111 3
6 0101 2
7 0100 1
8 1100 2
9 1101 3
10 1111 4
11 1110 3
12 1010 2
13 1011 3
14 1001 2
15 1000 1

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
0 000 000
1 001 001
2 002 002
3 010 012
4 011 011
5 012 010
6 022 020
7 021 021
8 020 022
9 100 122
10 101 121
11 102 120
12 110 110
13 111 111
14 112 112
15 120 102
16 121 101
17 122 100
18 200 200
19 201 201
20 202 202
21 210 212
22 211 211
23 212 210
24 220 220
25 221 221
26 222 222

 

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
0 000 0
1 001 1
2 002 2
3 012 3
4 011 2
5 010 1
6 020 2
7 021 3
8 022 4
9 122 5
10 121 4
11 120 3
12 110 2
13 111 3
14 112 4
15 102 3
16 101 2
17 100 1
18 200 2
19 201 3
20 202 4
21 212 5
22 211 4
23 210 3
24 220 4
25 221 5
26 222 6

 

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

 

Applications

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.

 








Internal Links:

washingtonart.net

HOME

TALK

LINKS

IMAGES

PÆAN

TECH

PHOTO

MATH

Programming

Algebra

Sequences

Goo

Turtle

Patterns

Squeeze

Ternary

Bio

Raster

FPOI

Disguise

Number Wars

Glass

Fibword

Gray

Geometry

Paint

Banding

GBT

greep

Misc

pfcpn