# Math Help - Ordeerd Pairs

1. ## Ordeerd Pairs

for an Ordered Pair (m,n) I use the Encoding Method = ((m+n)(m+n+1)/2)+n for encoding this ordered pair into a single number, this helps me to find an enumeration for functions , so if I have a function that takes 2 arguments an an Input I encode them using this Mathmatical method , But my Question if I want to decode any number in an Ordered Pair , how to do this?

I appreciate your help, I am a master of science in computer science student , and I attend the course of Computability theory.

thanks for all

Caio

2. Originally Posted by Fahed
for an Ordered Pair (m,n) I use the Encoding Method = ((m+n)(m+n+1)/2)+n for encoding this ordered pair into a single number, this helps me to find an enumeration for functions , so if I have a function that takes 2 arguments an an Input I encode them using this Mathmatical method , But my Question if I want to decode any number in an Ordered Pair , how to do this?
My computations show that, if you are given the encoding $Z$, then, letting $S=\left\lfloor \frac{\sqrt{8Z+1}-1}{2}\right\rfloor$ (integer part of (...)), you have $n=Z-\frac{S(S+1)}{2}$ and you deduce $m=S-n$.

A hint about the origin of my formula: the number inside the integer part is the positive solution to the equation $\frac{x(x+1)}{2}=Z$. And you must have $\frac{S(S+1)}{2}\leq Z <\frac{(S+1)(S+2)}{2}$ (if you know where your formula comes from, this should be clear)

3. ## Thanks a lot

Thanks A lot Man I appreciate your help.
Again thanks a lot .

Regards
Fahed