Symmetric injective mapping from N² to N

Click For Summary

Discussion Overview

The discussion revolves around finding a symmetric injective mapping from the set of ordered pairs of natural numbers (N²) to the set of natural numbers (N). Participants explore the properties of such a function, particularly focusing on the requirement that the function must yield the same result for interchangeable arguments while ensuring that no other combinations produce the same output.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses difficulty in finding a symmetric injective function from N² to N, emphasizing the need for the function to treat arguments interchangeably.
  • Another participant suggests transforming the arguments (a, b) into a symmetric pair (x, y) to retain the original information while disregarding which is greater, proposing transformations like (min(a, b), max(a, b)) or (|a-b|, a+b).
  • Some participants discuss the implications of mapping to subsets of N and express concerns about the rapid growth of outputs, particularly when trying to keep results manageable within certain limits.
  • A proposal is made to use a triangular number pattern for mapping, where the larger input selects the row and the smaller selects the column, with a known formula for the first element in each row.
  • There is a mathematical exploration of the formula for the mapping, with one participant deriving a specific equation for the mapping based on the row and column selection.
  • Concerns are raised about the efficiency of the proposed mappings and whether they meet the requirements of being injective and not growing too quickly.

Areas of Agreement / Disagreement

Participants express various viewpoints on the feasibility and efficiency of different mapping strategies, with no consensus reached on a definitive solution. Some agree on the need for symmetry and injectiveness, while others challenge the practicality of proposed methods.

Contextual Notes

Participants note the infinite and countable nature of the sets involved, and there are discussions about the limitations of certain mappings in terms of output size and computational efficiency.

Who May Find This Useful

This discussion may be of interest to mathematicians, computer scientists, and anyone exploring combinatorial mappings or injective functions in theoretical contexts.

Estanho
Messages
14
Reaction score
2
Hi,

I've been trying to find one symmetric "injective" N²->N function, but could not find any. The quotes are there because the function I'm trying to find is not really injective, as I need that the two arguments be interchangeable and the value remains the same.
In other words, the tuple (a, b) yields the same result as (b, a), which defines simmetry, but the result of (a,b) and (b,a) should not be obtained by any other combination of arguments.

I'm also not sure how to prove if one such given function obeys this property, and this is one of the main problems, as I was able to find some that works for small numbers, but then fail with bigger ones (which makes it very hard for me to check).

If anyone could help me with this, it would be better if the output would not grow too fast.

Sorry if there any obvious candidates.

Thanks
 
Mathematics news on Phys.org
Not sure how obvious it is, but an easy first step would be to transform the original arguments (a,b) to a different pair (x,y) that contains all of the original information about (a,b) except for the question of which is greater than the other. This transformation is symmetric by design.

For instance:
(a,b) => (min(a,b), max(a,b)).
or
(a,b) => (|a-b|, a+b)

Now define your function from (x,y) into N.
 
Estanho said:
Hi,

I've been trying to find one symmetric "injective" N²->N function, but could not find any. The quotes are there because the function I'm trying to find is not really injective, as I need that the two arguments be interchangeable and the value remains the same.
In other words, the tuple (a, b) yields the same result as (b, a), which defines simmetry, but the result of (a,b) and (b,a) should not be obtained by any other combination of arguments.

I'm also not sure how to prove if one such given function obeys this property, and this is one of the main problems, as I was able to find some that works for small numbers, but then fail with bigger ones (which makes it very hard for me to check).

If anyone could help me with this, it would be better if the output would not grow too fast.

Sorry if there any obvious candidates.

Thanks
One idea is to map to a subset of N with integers composed of just the digits 1 and 2, for example.
 
jbriggs444 said:
Not sure how obvious it is, but an easy first step would be to transform the original arguments (a,b) to a different pair (x,y) that contains all of the original information about (a,b) except for the question of which is greater than the other. This transformation is symmetric by design.

For instance:
(a,b) => (min(a,b), max(a,b)).
or
(a,b) => (|a-b|, a+b)

Now define your function from (x,y) into N.
That's an interesting one. I will try something on this.

PeroK said:
One idea is to map to a subset of N with integers composed of just the digits 1 and 2, for example.
Well, that's a classical way to map infinite sets, but it breaks the need for the numbers to stay relatively small. In fact, any of mapping of this nature would grow very fast I think.
I'd like to be able to represent numbers up to the order of 50.000, but still be able to fit the correspondent number in a int64.
 
Estanho said:
That's an interesting one. I will try something on this.Well, that's a classical way to map infinite sets, but it breaks the need for the numbers to stay relatively small. In fact, any of mapping of this nature would grow very fast I think.
I'd like to be able to represent numbers up to the order of 50.000, but still be able to fit the correspondent number in a int64.
Well, you posted under Maths not computer science. Mapping a finite set is trivial.
 
Estanho said:
I'd like to be able to represent numbers up to the order of 50.000, but still be able to fit the correspondent number in a int64.
For efficient coding, you do not just want an injection. You want a bijection. Write down all the numbers from 0 up to the maximum positive integer you can support in a triangle pattern:

Code:
0
1  2
3  4  5
6  7  8  9
10 11 12 13 14
15 ...

The larger of your two inputs selects the row. The smaller selects the column. The formula for the first element in each row is well known.

That's an efficient use of [the positive half of] the code space. It may not be the most CPU-efficient coding scheme.
 
PeroK said:
Well, you posted under Maths not computer science. Mapping a finite set is trivial.
I see your point, and I appreciate your help. It's just that I will not be able to use a solution like this. I should have made it clear on the first post.
Also, I believe that the set of N² tuples and N are both infinite, but countable.

jbriggs444 said:
For efficient coding, you do not just want an injection. You want a bijection. Write down all the numbers from 0 up to the maximum positive integer you can support in a triangle pattern:

Code:
0
1  2
3  4  5
6  7  8  9
10 11 12 13 14
15 ...

The larger of your two inputs selects the row. The smaller selects the column. The formula for the first element in each row is well known.

That's an efficient use of [the positive half of] the code space. It may not be the most CPU-efficient coding scheme.
I can easily see that the formula for the first element of each row is given by the difference equation and boundary condition
<br /> x_n - x_{n-1} - n = 0,<br /> x_0 = 0<br />

which yields
<br /> x_n = \frac{n^2 + n}{2}<br />

As I understand, the column c will simply be summed with the value of the row, starting from 0. So, the final equation looks like:
<br /> x(r, c) = \frac{r^2 + r}{2} + c<br />
where r is greater than c. So, there's just the need to order the two arguments, by doing as your first tip, in this case (a, b) => (max(a,b), min(a,b))

Is that correct? It seems to map to your sketch (I'm lazy and haven't spread it any further, as it seems not to be necessary).

With this solution, as an int64 can go up to 9223372036854775807, we can find a good limit value for both r and c like this:
<br /> 9223372036854775807 = \frac{max^2 + max}{2} + max<br />
which yields max = 4294967295. This is much more than I expect to use.

If this is right, it is an excellent mapping in O(1).
 
Last edited:
Estanho said:
As I understand, the column c will simply be summed with the value of the row, starting from 0. So, the final equation looks like:
##x(r,c)=\frac{r^2+r}{2}+c##​
where r is greater than c. So, there's just the need to order the two arguments, by doing as your first tip, in this case (a, b) => (max(a,b), min(a,b))
Yep. That is what I had in mind.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
Replies
4
Views
4K
  • · Replies 19 ·
Replies
19
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 36 ·
2
Replies
36
Views
3K
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K