3

I am looking for a integer-valued one-to-one function that maps coordinates $(x,y,z)$ in space $\mathbb{Z^+}$ to intergers in $\mathbb{Z^+}$?

adi
  • 133

1 Answers1

1

Let $\{x_i\}_0^\infty$ the decimal representation of $x$, that is $$ x = \sum_0^\infty x_i\cdot 10^i $$ Now to obtain an injective function $f$, you can take as image of $(x, y, z)$ the number whose decimal representation is $$ (x_0, y_0, z_0, x_1, y_1, z_1,x_2, y_2, z_2,\dots) $$ Finally, if you want a function which is also onto, you can use the following one $$ (x, y, z) \to f(x - 1, y - 1, z - 1) + 1 $$

AlbertH
  • 5,338
  • I was also wondering , if I have $n$ such tuples ${(x,y,z)}$ , is it possible to come up with a mapping that maps these to ${1..n}$ ? – adi Oct 10 '12 at 10:30
  • Of course. You can arbitrarily link each one of those $n$ tuples, $(x, y, z)$, to one number in ${1,\dots, n}$, so there are $n!$ different such maps. – AlbertH Oct 10 '12 at 10:41
  • Note however, AlbertH's solution provides a unique integer for every unique tuple. To ensure the same for a function mapping to integers in the range of one to n requires knowledge of all tuples that are yet to be mapped. – Marcks Thomas Oct 10 '12 at 10:51