I'm gonna take another look at this problem. That is, consider the fast growing total computable function I can describe in a few lines of Ruby code. It's pretty large. Let's start with this small appetizer:
def f(a,b)a.times{a*=b<0?a:f(a,b-1)}&&a end
Function alone: https://repl.it/Hvr5/63
Function with inputs: https://repl.it/Hvr5/62
This function grows pretty fast and only requires 43 characters to write (including spaces). It basically works as follows:
f(a,-1) = a^(2^a)
f(a,b) >/≈ f(f(f(...f(a,b-1),...,b-1),b-1),b-1), with a nestings of f(-,b-1)
In terms of the Ackermann function, f(a,b) ≈ A(b+4,a)
. An explicit expansion:
f(2,2) > f(f(2,1),1) > f(f(f(2,0),0),1) > f(f(f(f(2,-1),-1),0),1) = f(f(f(16,-1),0),1) = f(f(2^2^18,0),1) > ...
We can make a slightly larger function:
def f(a,b,c=a)c>0?a.times{a*=f a,b,c-1}&&a:b<0?a:f(a,b-1)end
Function alone: https://repl.it/Hvr5/67
Function with inputs: https://repl.it/Hvr5/66
Now we're at 60 characters (including spaces). Still pretty small. It basically works as follows:
f(a,-1,0) = a
f(a,-1,1) = a^(2^a)
f(a,b,c) >/≈ f(f(f(...f(a,b,c-1),...,b,c-1), with a nestings of f(-,b,c-1)
f(a,b,0) = f(a,b-1,a)
So f(a,-1,b+1) ≈ f(a,b)
from before, but we then can make much larger numbers. It quickly catches up to Graham's number, which is approximately f(64,0,1)
. Let's look at an expansion:
f(2,0,1) > f(f(2,0,0),0,0) = f(f(2,-1,2),0,0) > f(f(f(2,-1,1),-1,1),0,0) = f(f(16,-1,1),0,0) = f(2^2^18,0,0) = f(2^2^18,-1,2^2^18) ≈ A(2^2^18,2^2^18)
Okay, that wasn't so bad, but you'll quickly find that gets out of hand very fast...
We could try throwing in a few more arguments while we're at it:
def f(a,b=a,c=a,d=a,e=a,g=a,h=a,i=a,j=a,k=a,l=a,m=a,n=a,o=a,p=a,q=a)a.times{a**=q>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n,o,p,q-1):p>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n,o,p-1):o>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n,o-1):n>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n-1):m>0?f(a,b,c,d,e,g,h,i,j,k,l,m-1):l>0?f(a,b,c,d,e,g,h,i,j,k,l-1):k>0?f(a,b,c,d,e,g,h,i,j,k-1):j>0?f(a,b,c,d,e,g,h,i,j-1):i>0?f(a,b,c,d,e,g,h,i-1):h>0?f(a,b,c,d,e,g,h-1):g>0?f(a,b,c,d,e,g-1):e>0?f(a,b,c,d,e-1):d>0?f(a,b,c,d-1):c>0?f(a,b,c-1):b<0?a:f(a,b-1)}&&a end
Function alone: https://repl.it/Hvr5/58
Function with input: https://repl.it/Hvr5/59
This one's a whopping 494 characters (including spaces), but if you take a look at the code... its just... really repetitive... of nothing new compared to the above. This would be where one defines this function for arbitrarily many arguments... which gives way to a whole new scheme of what you can do...
And to save space, one can incorporate half a variable by taking advantage of negative numbers. For example, if the second argument is negative, replace it with the first argument. If the second argument is zero, do the normal base case. If the second argument is greater than zero, do the normal case.
def f(a,b=-a,c=a,d=a,e=a,g=a,h=a,i=a,j=a,k=a,l=a,m=a,n=a,o=a,p=a,q=a)a.times{a**=q>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n,o,p,q-1):p>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n,o,p-1):o>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n,o-1):n>0?f(a,b,c,d,e,g,h,i,j,k,l,m,n-1):m>0?f(a,b,c,d,e,g,h,i,j,k,l,m-1):l>0?f(a,b,c,d,e,g,h,i,j,k,l-1):k>0?f(a,b,c,d,e,g,h,i,j,k-1):j>0?f(a,b,c,d,e,g,h,i,j-1):i>0?f(a,b,c,d,e,g,h,i-1):h>0?f(a,b,c,d,e,g,h-1):g>0?f(a,b,c,d,e,g-1):e>0?f(a,b,c,d,e-1):d>0?f(a,b,c,d-1):c>0?f(a,b,c-1):b<0?f(a,a):b<1?a:f(a,b-1)}&&a end
Function alone: https://repl.it/Hvr5/72
Function with inputs: https://repl.it/Hvr5/74
Of course, all of the above can be drastically reduced down to a function that intakes arrays as arguments of arbitrary length:
def f(a,b=Array.new(a,a),c=a)d,*e=b;a.times{a+=(b.class==Fixnum)?a:b.size<2?f(a,d,c):d<0?f(a,e,c+1):c<0?a:f(a,[a,d-1,e],c-1)};a end
Function alone: https://repl.it/Jfgb/4
Function with inputs: https://repl.it/Jfgb/6
Function with handy dandy stuff on the side: https://repl.it/Jfgb/8
Lengthy explanations: https://repl.it/Jfcr/3
In terms of the fast growing hierarchy,
$$f(a,b)\approx f_{b+2}(a)$$
$$f(a,b,c)\approx f_{\omega b+c}(a)$$
$$f(a,b,c,d,e,g,h,i,j,k,l,m,n,o,p,q)\approx f_{\omega^{14}b+\omega^{13}c+\dots+\omega^2 o+\omega p+q}(a)$$
$$f(a,-b,c,d,e,g,h,i,j,k,l,m,n,o,p,q)\approx f_{\omega^{15}+\omega^{13}c+\dots+\omega^2 o+\omega p+q}(a)$$
Not really sure on the arbitrary length array yet.
Inspired by Largest printable number.