Numbat

Numbat has long established itself as a premier high-precision scientific calculator, celebrated for its robust, first-class support for physical units. Whether you are converting light-years to parsecs or validating the dimensional integrity of fluid dynamics equations, Numbat ensures your calculations remain anchored in physical reality.

However, scientific computation often pulls us into abstract mathematical territories where operations scale at terrifying velocities. Today, we are exploring one such frontier: tetration.

Understanding Tetration: The Fourth Hyperoperation

To appreciate tetration, we must look at the sequence of hyperoperations. Arithmetic begins with addition. Iterated addition yields multiplication. Iterated multiplication yields exponentiation. The logical next step in this progression—iterated exponentiation—is tetration.

While an exponent tells you how many times to multiply a number by itself, tetration tells you how many times to raise a number to its own power, creating a "power tower".

Mathematically, the tetration of a base a to the height n is written using Knuth's up-arrow notation as auparrowuparrown, or as a pre-superscript na. It can be formally defined via the following recurrence relation:

0a=1na=a(n1a)

Because each step builds an exponential stack, numbers generated by tetration grow at an astronomical rate. For instance, while 24=16, a power tower of 2 with a height of 4 (42) equals 2222, which evaluates to 216=65,536.

If you increase the height to just 5, the resulting number has 19,729 digits—far exceeding the capacity of standard standard 64-bit floating-point variables, but perfectly suited for Numbat's high-precision architecture.

Implementing Tetration in Numbat

Numbat's elegant, functional syntax makes expressing recursive mathematical concepts exceptionally natural. By utilizing Numbat's structural type annotations and conditional expressions, we can implement a clean, high-precision tetration function in just a few lines of code.

Here is how we can native-code the tetration function using Numbat's syntax:

fn tetrate(a: Scalar, n: Scalar) -> Scalar =
    if n <= 0 then 1
    else a ^ tetrate(a, n - 1)
>>> tetrate(2, 4)
      = 65536