Knuth's Up-Arrow Notation: Why ^ is Used for Exponentiation in Programming
Definition
Knuth’s up-arrow notation is a notation devised to represent large integers.
Addition, Multiplication, and Exponentiation
Addition is defined as follows:
Multiplication is defined as follows:
Exponentiation is defined as follows:
Tetration and Pentation
Tetration is defined as follows:
Pentation is defined as follows:
General Definition
is defined as follows1:
Explanation
The renowned Donald E. Knuth, a mathematician and computer scientist, made an absolute and unique contribution to the expression of mathematical formulas for humanity by developing . In 1976, he also proposed the up-arrow notation in his paper. While the definition itself may be difficult to understand due to its handling of extremely large numbers, when , i.e., , it is within the comprehension of ordinary humans. In particular, the up-arrow matches exactly with , which uses the caret symbol ^
in the style of x^n
, making this style widespread due to the difficulty of directly inputting the up-arrow on most keyboards.
It is quite interesting to look at some programming languages and their timelines:
- In 1957, Fortran was introduced, using
**
for exponentiation. - In 1972, the C language was introduced, without an exponentiation operator and instead using the
pow
function from themath.h
library. - In 1976, Knuth published his paper on the up-arrow notation.
- In 1978, Knuth developed , which used
^
for exponentiation. - In 1984, MATLAB was released, using
^
for exponentiation. - In 1991, Python was introduced, using
**
for exponentiation. - In 1992, R was introduced, using
^
for exponentiation. - In 1995, Ruby was introduced, using
**
for exponentiation. - In 1995, Java was introduced, using the
pow
method from theMath
library. - In 2009, Go was introduced, using the
pow
function from themath
library. - In 2012, Julia was introduced, using
^
for exponentiation.
The history of exponentiation operators in programming is divided into before and after Knuth. General-purpose languages like Fortran used **
or provided a function in a separate standard library like C, while languages for scientific computing or statistical analysis chose ^
. Python is an exception, being a general-purpose language but also widely used in scientific computing.
Donald E. Knuth ,Mathematics and Computer Science: Coping with Finiteness.Science194,1235-1242(1976).DOI: https://doi.org/10.1126/science.194.4271.1235 ↩︎