Monday, May 3, 2010

Irrational Number Storage

Once upon a time, I really thought that programs could one day be represented with the starting position in an irrational number. Since Irrational numbers don't repeat, given enough time we could calculate pi or any irrational number far out enough to get anyone's SSN, or phone number, or the binary code that makes up Adobe Creative Suite 3.

Of course I later realized that it would take more data to store the starting position than it would to actually store the program. In the spirit of the idea, I decided to make a little example.

Binary Pattern to Find:




When I originally thought of this method as a child I imagined finding the pattern for a program in PI, but for the sake of speed, this example uses Fibonacci sequences to generate a string of binary data that doesn't repeat. It's way faster since all you need to do is a simple addition to find the next number, and as you can tell from the pattern finding below, speed is quite important.


I turn each digit of the Fibonacci numbers generated into binary with the following conversion:


DigitBinary
0000
1001
2010
3011
4100
5101
6110
7111
80
91


For example, the begining of the sequence 1,2,3 gives us the binary string 001010011 so searching for: "100" would give us starint position 5. The idea to is have the same possibilities for "0" as I do for "1", hence 8 and 9. My theory is already off since Fibonacci number sequences have more odds than evens.

After 1400 and some fibonacci numbers, the next Fibonacci number becomes too large to be stored as a double(3.something times e raised to the 308th power is the last in javascript), so I restart the equation with the next seeds. For example, if the first series was 1,1,2,3,5... then I start the next series with 1,3,4,7,11... and then after that gets too large, 1,4,5,9...

4 comments:

  1. Could you clarify the last paragraph?

    ReplyDelete
  2. After 1400 and some fibonacci numbers, the next Fibonacci number becomes too large to be stored as a double(3.something times e raised to the 308th power is the last), so i restart the equation with the next seeds. For example, if the first series was 1,1,2,3,5... then i start the next series with 1,3,4,7,11... and then after that gets too large, 1,4,5,9...

    ReplyDelete
  3. Nice post! for binary representation, you could also have used something like "0, 1, 00, 01, 10, 11, 000, 010, 101, 111" instead, correct?

    ReplyDelete
  4. Right, I just wanted an easy way to make a binary string with a relatively normal distribution of 1s and 0s. Any series such as the one you mentioned would work. Thanks for the comment.

    ReplyDelete