Ackermann Function — Definition, Formula & Example
The Ackermann function is a two-input function on whole numbers, defined by three short recursive rules. Every value can be computed in finitely many steps, but the outputs grow faster than any function you can build from ordinary bounded loops.
The Ackermann (Ackermann–Péter) function is defined by , for , and for . It is total and computable, because each call reduces the pair in lexicographic order. It is not primitive recursive: for every primitive recursive there is an with for all .
Key Formula
Where:
- = First argument, a natural number. It controls the growth level, so from row 3 on, each row grows far faster than the one before (rows 0 to 2 are linear: , , ).
- = Second argument, a natural number. It sets the position within row m.
- = The natural-number output.
Worked Example
Problem: Use only the three defining rules to compute .
Step 1: Work out row first. Rule 2 gives the starting value. Rule 3 gives , so each step adds 1.
Step 2: Find the inner value with rule 2, then use the row-1 pattern.
Step 3: Apply rule 3. The inner call is evaluated first, and its output becomes the second input of the outer call. This nesting is what makes the function grow so fast.
Answer: . Continuing this way gives the row patterns , , and , so . Row 4 is a tower of 2s: , and has 19,729 digits.
Why It Matters
In a theory of computation or logic course, the Ackermann function is the standard proof that primitive recursion, meaning programs with only bounded for-loops, does not capture every computable function. Its inverse appears in algorithms courses. The union-find data structure used in Kruskal's minimum spanning tree algorithm runs in time, where is the number of operations on elements, and for any input size you could ever store.
Common Mistakes
Mistake: Concluding that the Ackermann function is not computable because it outgrows every primitive recursive function.
Correction: It is computable. A simple recursive program, or a loop with a stack, finds any value in finitely many steps. 'Not primitive recursive' only means you cannot compute it with bounded loops alone. Computable and primitive recursive are different classes, and the first is strictly larger.
