0

I was looking at the cantor pairing function here https://en.wikipedia.org/wiki/Pairing_function and am quite amazed as to how it works very well for pairing and unpairing natural numbers.

So far, my test on natural numbers π(47, 32) work flawlessly but I have another special use case where I would want to use real numbers instead, for exampleπ(6036.154879072251, 21288). Is there a way to modify the function to allow support for real numbers?

Asaf Karagila
  • 393,674

1 Answers1

0

The formula for the pairing function is given on that page.

$\pi(x,y)=\frac{1}{2}(x+y)(x+y+1) + y$

$\pi(0,1) =2$ and $\pi(-2,2) = 2$. So it already fails to be injective for $\mathbb{Z}^2$.

The are other ways to show that $\mathbb{R}$ and $\mathbb{R}^2$ are equipotent; it cannot be done by a simple algebraic formula like this..

Henno Brandsma
  • 242,131