Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Ackermann function

created by ariels

(thing) by ariels (1.4 d) (print)   ?   1 C! I like it! Mon Mar 13 2000 at 23:25:48

(Recursively) defined as follows,

A(0,n) = n+1
A(m+1,0) = A(m,1)
A(m+1,n+1) = A(m, A(m+1,n)),
Ackermann's function grows very quickly. In fact,
A(1,n) = A(0, A(0, ..., A(0,n)...)) = 2n
A(2,n) = A(1, A(1, ..., A(1,n)...)) = 2^(n+1)
...
with each successive step proceeding along the hierarchy addition, multiplication, exponentiation, ...

Ackermann's function is recursive (equivalently, computable), but it is not primitive recursive. In fact, if we define f_k(n) = A(k,n) then for each k, f_k is primitive recursive. It is defined for all inputs; this shows that while every primitive recursive function is a total computable function, the converse is not true.


(thing) by anomie (6 y) (print)   ?   I like it! Wed Jun 21 2000 at 22:40:35

In Perl, using the Math::BigInt package so it can handle large numbers:
#!/usr/bin/perl

use Math::BigInt;  # mmm... bignums

# Yes, it's a bug that neither input value can be 0. A(0, n) is trivial,
# while A(m, 0) = A(m-1, 1)
($x=shift) && ($y=shift) || die "usage: $0 m n\n";
$m=Math::BigInt->new($x);
$n=Math::BigInt->new($y);

print Ack($m, $n), "\n";

sub Ack{
    my $m=shift;
    my $n=shift;
    return $n+1 if $m==0;            # Ack(0,n)=n+1
    # If $n==0, then $n+1==1 which is what we want
    return Ack($m-1, $n+1) if $n==0; # Ack(m,0)=Ack(m-1,1)
    return Ack($m-1, Ack($m, $n-1)); # Ack(m,n)=Ack(m-1, Ack(m, n-1))
}

However, A(1, n) = A(0, A(1n-1)) = A(1, n-1)+1 = ... = A(1, n-n)+n = A(1, 0)+n = A(0, 1)+n = 1+1+n = n+2, not 2n as claimed above. (Note that A(1, n) = A(0, A(0, ... A(0, 1)...)), again not as above).

Since we know A(1, n), A(2, n) = A(1, A(2, n-1)) = A(2, n-1)+2 = ... = A(2, n-n)+2n = A(2, 0)+2n = A(1, 1)+2n = 1+2+2n = 2n+3.

Similarly, A(3, n) = 2n+3-3 (that's 2**(n+3)-3), and A(4, n) = 2^^(n+3)-3 (where ^^ is the iterated power operation). You can greatly speed up the program above by adding cases for these.

My favorite number is A(4, 2).


printable version
chaos

primitive recursive Wilhelm Ackermann Getting free pizza Greengrocer's apostrophe
iterated power Odd numbered Star Trek movies suck ^ notation The set of decimal representations of numbers divisible by 17 is regular
chi square log* Graham's Number Ackermann number
Vaguely erotic encounters on the number 8 bus zig number Kruskal's algorithm Ackermann steering
On computable numbers, with an application to the Entscheidungsproblem Turing complete recursive Social Security number
well-founded induction Biot Number Why the Pentagon has twice the number of bathrooms it needs strobogrammatic number
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Look at this mess the Death Borg made!
I can't live without you
Isaac Newton
Hammer Films
The Everything credibility problem
How to improve your chances of having sex
Why the world is more beautiful with a creator
Lateral Inhibition
Claude Debussy
love conquers all *
Ten reasons why creation scientists don't believe in evolution
Dorothy Parker
We Were Soldiers
Overcoming arachnophobia, or how I learned to love the spiders with HUMAN HEADS!
New Writeups
Dreamvirus
the kingdom of now(poetry)
Gryffon
balls out(idea)
originalzin
The Healing Place(place)
TheLady
Why I love Everything2(essay)
jjen
Why I love Everything2(personal)
AspieDad
Fighting someone else's battle(idea)
santo
Rock Band vs. Guitar Hero III(essay)
impishlaugh
Threshold(idea)
maxClimb
May 21, 2008(log)
Rancid_Pickle
I Wish Momma Sang the Blues(fiction)
dannye
Lars and the Real Girl(review)
Glowing Fish
Educational gender gap(idea)
Venkman
Persimmon pudding(recipe)
aneurin
Hilary Armstrong(person)
giantcactus
The Power of Electricity(personal)
This page courtesy of The Everything Development Company