Explicit enumerations of n-tuples of naturals $f:\mathbb{N}^n \to \mathbb{N}$?

87 Views Asked by At

For $n=2$ there is a simple and nice enumeration:

$$(i,j) \mapsto f(i,j)=\frac{(i+j)(i+j+1)}{2}+j$$

Obviously, we can use this formula to obtain a general enumeration, for $n=3$, we have:

$$(i,j,k) \mapsto (f(i,j),k) \mapsto f(f(i,j),k)$$

defining $F_n:\mathbb{N}^2\times\mathbb{N}^{n-1} \to \mathbb{N}^n$ as $(a,b,\boldsymbol{p})\mapsto (f(a,b),\boldsymbol{p})$, we obtain enumerations as:

$$H^{(n)}:\mathbb{N}^n\to \mathbb{N}, \qquad H^{(n)}(i_1,\dots,i_n) = (F_{n-1}\circ\dots\circ F_1)(i_1,\dots,i_n)$$

Then, some things came up that surprised me a bit:

  • In terms of 3-tuple boxes, $\mathbb{N}^3$ would have a "volume" so I would have expected there to be enumeration that was a cubic polynomial (the volume of a cone and the volume of a pyramid is a cubic polynomial of their maximum dimensions). However, the result is a rather lackluster quartic polynomial. Does this fact have an intuitive explanation?
  • What other more elegant ways are there to give enumerations, at least for $\mathbb{N}^3$?
1

There are 1 best solutions below

0
On

Here's an approach that "fills $n$-dimensional space in layers" so that the tuples in $\Bbb N^n$ are enumerated in order of their component sum (and each layer is enumerated in sublayers corresponding to values of the sum of the first $n-1$ components, etc.).

The desired function $f_n:\Bbb N^n\to\Bbb N$ (where $\Bbb N$ includes $0$) is:

$$ \begin{align} f_n(x_1,\dots,x_n)&=\sum_{k=1}^n\binom{x_1+\dots+x_k+k-1}k\\ &=x_1+\binom{x_1+x_2+1}2+\binom{x_1+x_2+x_3+2}3+\dots \end{align} $$

The idea here is that the index of a tuple is just the number of tuples that should precede it in the enumeration, and $\binom{s+k-1}k$ is the number of tuples $(y_1,\dots,y_k)$ with sum less than $s$, by a stars and bars argument.