Monday, 26 December 2011

Growing Numbers on the Double

Police officer standing guard at the main doorway of Number 10

Coming days I show you how to build a system to express some extremely Big numbers.
Moving from the bottom up the system's rules are expanded under way, while guarding a general sense of simplicity. Soon these functions increase at record speed and our numbers travel far into the mathematical universe!

We just begin with one unit 1 (raise a finger).

Natural numbers are repetitions 1..  §1.1

Define number variables a,b,c,.. to be filled with ones. A constant t with ten units 1.
Continue counting with fingers 1 (or hands t).

2 = 11
a = 1.. {1:a a>0} = 0+1.. {+1:a}
t = 1111111111 = 10

All variables add naturally, with direct precedence. The addition operator + can be used if you need a lower precedence.
Units minus - (counting down) share this direct affinity with unit 1.

ab = 1..1.. {1:a 1:b} = a+b = ba
1- =   = 0 = -1
ab-.. {-:b} = a

We implied the repetition of characters using a special RepExp.A notation.

{ RepExp } notation

A. Here W:n signifies a word repetition (Rep), to substitute n times the word W in place of W.. in the preceding expression (Exp). We call this a RepExp, a simple form of Regular Expressions (RegExp), ideal for working out recursive functions.

Instead of grouping words with brackets like in RegExp or rehashing words in the Rep as above, we can use dots to delimit and select specific character sequences.
Arbitrary words (fitting for the Exp) are represented by wildcards in capital letters.
Count down the Rep factor to turn a RepExp step by step into a normal expression.

W.. {:n2} = W.W.. {:n1} = WW.W.. {:n}
== A.W.. {:1} = AW
A.W..M.X.Z {:1:} = AWMXZ
A.W..M.X.Z {:n1:} = AW.W..M.X.XZ {:n:}

Option B. when W in the Exp holds a single sign, just write the factor n in the Rep.
C. When W.. starts at the left end or from .W.. dot selection, put :n in the Rep.
D. With words repeated both to the left and right end (or dot), write :n: in the Rep.

With multiple repetitions, the words to target in the Exp correspond to factors in the Rep in the same order. To avoid confusion there's the canonical option:
E. The Rep clause can also be put inside the Exp, right after a word selected by a free left dot .W{:n} or after a single character w{n} as usual in RegExp.

As we venture to accomplish great things, the fun is to maintain the utmost frugality. The turf records (Dutch: turven = to count) defined in each chapter are strings of length ten – ten character places to store a larger number than before. Starting with the sign 1 we've now turved t=10.

One separator , to function as a redoubling operator  §1.2

Introduce a single comma , to separate two variables within an expression. Then reduce them by rules ♥.1 to repeatedly double the left value (starting with a) while the right iteration counter (initially b+1) is decremented.

  • 1.0 a,1 = aa = a*2
  • 1.1 a,b1 = aa,b == a..,1 {:2^b}

An alternative way to define rule ♥.1 of the operation of redoubling.

  • 0.0 a, = a = ♥(a,0)
  • 1.2 a,b = aa,b- ==0. a.. {:2^b} = a*2^b

Here a countdown is written by appending the unit minus - to parameter b so that it is reduced 1- step by step == until the final zero falls away gracefully (a zero gap must not subvert the algorithm).
Also on every iteration step each unit in first entry a is copied and added next to it. Working with integers this puts the output 1.. on a scale a*2^b of binary powers.

t1 = 11,1111111 = ♥(2,7) = 2^8
   = ttttttttttttttttttttttttt111111 {t=1111111111}

Your ten-o-maniac has managed to squeeze a byte 256 in ten places in the above two parameter notation. This restriction on expression size requires that b=t-1-a.
You may improve on his number by taking the 1.. not as characters but as real sizes, so that for all restricted ab the maximum is reached when e^(1/a)=2 so a~1.44.
In the redoubling graph [plot in Sage] for the length t-1=9 you see the real maximum at 271.7 pushing just a teeny 60% higher than our present discrete turf t1=256.

No comments:

Post a Comment