I was reading this question on this site and I saw that the following pairing function was mentioned (a modified version of Cantor function):

$$\langle x, y\rangle = x * y + \operatorname{trunc}\left(\frac{(|x - y| - 1)^2}{4}\right) = \langle y, x\rangle$$

(also expanded here)

I was wondering if, given the result, one can get back $x$ and $y$ (inversion), as normally one can do with similar functions (e.g., Cantor pairing function).

If, say, $f(x,y) = u$, where $f$ is the above function, given $u$ what would $x$ and $y$ (order unimportant) be ?

  • $\begingroup$ Please not proper MathJax usage: I changed $<x,y>=x*y+trunc(\frac{(|x−y|−1)^2}{4})=<y,x>$ to $\displaystyle\langle x, y\rangle = x * y + \operatorname{trunc}\left(\frac{(|x - y| - 1)^2}{4}\right) = \langle y, x\rangle$. ${}\qquad{}$ $\endgroup$ – Michael Hardy Apr 23 '15 at 22:55
  • $\begingroup$ Thank you for the edit Michael. I can attempt a justification ;-) by saying that I just copied and pasted the original code without modifying it. Thanks again: it looks much better now. $\endgroup$ – Pam Apr 23 '15 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.