Math::Arrow
NAME
Math::Arrow - Handle Knuth-style arrow notation
SYNOPSIS
In Knuth arrow notation, one arrow is simple exponentiation:
2 ā 3 # gives 8
Every additional arrow in the operator implies a layer of reduction of the form:
a ā{n number of ā's} b =
a ā{n-1 ā's} ( a ā{n-1 ā's (... a)...)
where there are b number of as in the second form.
But this module only implements up to five arrows (really, if you need more than five, I question what the hell you think Perl is going to do for you...)
More concretely:
4 āāāā 3 =
4 āāā ( 4 āāā 4 ) =
4 āāā ( 4 āā ( 4 āā ( 4 āā 4 ))) =
4 āāā ( 4 āā ( 4 āā ( 4 ā (4 ā (4 ā 4 ))))) =
4 āāā ( 4 āā ( 4 āā ( 4 ** 4 ** 4 ** 4))) = ...
As you can see, this quickly gets out of hand. In fact, there are very few arrow-notation expressions which can be evaluated in a practical period of time (the above example would take longer to fully evaluate than the universe has been around, even on the fastest computers available, today.
Probably the best-known arrow-notation example is Graham's Number (G) which is defined as:
$g1 = 3 āāāā 3;
$g2 = arrow(3, 3, $g1);
...
$g64 = arrow(3, 3, $g63);
use constant G = $g64;
operator ā
The ā operator is an infix operator which is equivalent
to arrow(left-hand-side, right-hand-side, 1) and **
and performs simple exponentiation. It is right-associative,
just like **.
operator āā
The āā operator is also a right-associative infix operator
and is equivalent to arrow(lhs, rhs, 2).
operator āāā
See āā for details. Equivalent to arrow(lhs, rhs, 3).
operator āāāā
See āā for details. Equivalent to arrow(lhs, rhs, 4).
operator āāāāā
See <āā> for details. Equivalent to arrow(lhs, rhs, 5).
arrow($a, $b, $arrows)
Returns the arrow-notation expansion for $a ā[$arrows] $b
where ā[$arrows] denotes $arrows many ā in the final
operator. Thus these two are equivalent:
arrow(3, 3, 4) == (3 āāāā 3)
term G
(only exported via the :constants tag)
The value G is defined as a more-or-less humorous element
of this module. It can never be used for anything practical,
as evaluating its value would take such a mind-bogglingly large
amount of time and memory that you might as well simply shoot your
computer. But... don't do that.
This value is Graham's number, defined as described above.