Sunday, December 28, 2008

Patterns in Binary Lists

When you list out the binary numbers that result from a function, patterns naturally develop vertically - within in place value column. It's more obvious than it sounds - look at a list of the binary results for f(x)=x from f(0) to f(7):

000
001
010
011
100
101
110
111

In the first column (2^0), the pattern is 0101010101 and so on. In the second column (2^1), the pattern is 00110011..., the third column is 00001111... Because these are so simple, you can see what the pattern is without really thinking about it. Naturally, as f(x) gets more complicated, so do the patterns. 

But the more complex patterns are pretty, so I needed a way to generate the pattern of any given column for a function f(n). This is really very simple - I wrote a function that produces the binary digit in a given place value (2^k) of a given number (n):

([n-n%(2^k)]%[2^(k+1)])/(2^k)

Make this into a series, and substitute f(n) for n, and I have the formula for the columnar pattern in a given f(n) and place value value. 

b
╬ú   [([f(n)-f(n)%(2^k)]%[2^(k+1)])/(2^k)]*(10^n) 
n=0

Using this formula, the pattern for the 2^4 column of f(x)=x^2 from 1 to 16 is: 

000110101011000

It's prettier when the trailing and leading zeros are removed:

110101011

That is my useless and probably not original (but pretty) contribution to mathematics for the day. Thank you.


EDIT: The equation will generate the proper digit, but as the series loops, the digits will not add together into a nice and tidy list. To remedy this, one must multiply the whole business by 10^n, as shown in red above, to put each one into its proper place value.

2 comments:

  1. If you pick a note for 0 and a harmonising one for 1 and sing them it sounds pretty too.

    ReplyDelete
  2. I am assuming this is what you were talking about the other day in the car ^.^

    ReplyDelete