I'm looking for a bijection from $\mathbb N$ to $\mathbb N\times\mathbb N\times\mathbb N$.
- I know it exists
- I know an informal way to define one, ordering the triplets of natural numbers in a 3D array an counting them diagonally as they do here with 2D array.
- And I know a bijection from $\mathbb N\times\mathbb N\times\mathbb N$ to $\mathbb N$ from this answer which uses factorization
But how to write it explicitly?
Thank you very much.
Answer
Use Cantor's pairing function $\langle \cdot, \cdot \rangle: \mathbb{N} \times \mathbb{N} \to \mathbb{N}$ twice: $(a,b,c) \mapsto \langle \langle a,b \rangle, c \rangle$. Cantor's pairing function has an inverse which is easily-stated if a bit fiddly (see the proof of bijectivity on the linked Wikipedia page).
No comments:
Post a Comment