4

Let us take
$$ \mathbb{N} := \{ 1, 2, 3, \ldots \}, $$ and let the function $f \colon \mathbb{N} \longrightarrow \mathbb{N} \times \mathbb{N}$ have the following values: $$ \begin{align} & f(1) := (1, 1), \\ & f(2) := (1, 2), f(3) := (2, 1), \\ & f(4) := (1, 3), f(5) := (2, 2), f(6) := (3, 1), \\ & f(7) := (1, 4), f(8) := (2, 3), f(9) := (3, 2), f(10) := (4, 1), \\ & f(11) := (1, 5), f(12) := (2, 4), f(13) := (3, 3), f(14) := (4, 2), f(15) := (5, 1), \\ & \ldots. \end{align} $$

Apparently, this function $f$ is bijective.

How to find an explicit formula for this function? How to rigorously show that this function is bijective?

I know that the inverse function $f^{-1} \colon \mathbb{N} \times \mathbb{N} \longrightarrow \mathbb{N}$ is given by the formula $$ f^{-1} (m, n) := \frac{ (m+n -2 ) (m + n -1 ) }{2} + m. $$

1 Answers1

2

We can write $$f(n)=(m-k,\,k+1)\ ,$$ where $m$ is the smallest integer for which $1+2+\cdots+m\ge n$, and $k=1+2+\cdots+m-n$.

Since $m$ and $k$ are uniquely determined by $n$, this expresses $f(n)$ in terms of $n$. If you want to take it further, you could note that for $m\in\Bbb N$ we have $$\eqalign{1+2+\cdots+m\ge n &\quad\Leftrightarrow\quad m(m+1)\ge2n\cr &\quad\Leftrightarrow\quad \Bigl(m+\frac12\Bigr)^2\ge2n+\frac14\cr &\quad\Leftrightarrow\quad m\ge\sqrt{2n+\frac14}-\frac12\cr}$$ and we require the smallest $m$ satisfying this inequality, which is $$m=\left\lceil\sqrt{2n+\frac14}-\frac12\right\rceil\ .$$ Substituting back above will give $k$ and hence $f(n)$ "directly" in terms of $n$.

David
  • 82,662