Is the Sum and Absolute Difference of two positive Integers Unique?

264 Views Asked by At

Question:

Is the combination of Sum and Absolute Difference of 2 positive integers unique to that combination of integers?

Assume $X$ and $Y$ are positive integers AND $X \neq Y$.

I think that we all agree that: $X + Y = Y + X$ AND $|X - Y| = |Y - X|$

However I don't think there is any other positive integers ($A$ and $B$, $A \neq B$) where $A + B = X + Y$ AND $|A - B| = |X - Y|$ AND ($A \neq X$ OR $A \neq Y$) AND ($B \neq X$ OR $B \neq Y$) )

Background

Over on the DBA Stack Exchange there is a question asking for ensuring the uniqueness of a relationship. In the specific implementation it is really a comparison of 2 positive integers that represent objects in a relationship.

Lets say for example that we are modeling that Kirk and Victoria are friends. If Kirk = 1 and Victoria = 2 in this table, then I need on instance of either [1,2] or [2,1] but I don't need both. (Since it can be inferred that if Kirk is friends with Victoria, that Victoria is also friends with Kirk)

Another avenue for testing I was attempting is to use some basic arithmetic to create a summary of the 2 integers (which computers can calculate and compare quickly). I ran a test of all combinations of positive integers from 1 - 10,000 and logged the Sum, Product and Absolute Difference of the 2 integers.

It appeared from my testing that the Combination of Sum and Absolute Difference was unique for the combination. EX: The Sum and Absolute Difference of [1,2] and [2,1] were the same, but was not shared with any other pair of [x,y] and [y,x].

In my head this makes sense, because you can make changes to the two integers in question to create the same Sum or Absolute Difference but that would change the value for the other attribute. EX: [2,5] as a Sum of 7 and an Absolute Difference of 3. [1,6] has the same Sum but a different Absolute Difference, and [3,6] has the same Absolute Difference but a different Sum.

I am assuming I am not the first person to see this relationship and this has either been proven to be true or this has been proven to be false, and I either did not find the cases where it is false or my comparison methods were wrong.

2

There are 2 best solutions below

0
On BEST ANSWER

Welcome to Mathematics Stack Exchange.

Assume without loss of generality that $X\ge Y$, so $|X-Y|=X-Y$.

(If not, switch $X$ and $Y$.)

If $X+Y=S$ and $X-Y=D$, then $X=\dfrac{S+D}2$ and $Y=\dfrac{S-D}2$,

so $X$ and $Y$ are indeed uniquely determined by $S$ and $D$.

4
On

Let us solve $s=x+y,d=|x-y|$ for $x,y$. We eliminate $y$ and get

$$d=|2x-s|$$ or $$2x-s=\pm d.$$

So

$$x=\frac{s+d}2,y=\frac{s-d}2$$ or$$x=\frac{s-d}2,y=\frac{s+d}2.$$

This shows that there are exactly two solutions.


Let us play the same game with sum and product: $s=x+y,p=xy$.

Multiplying by $x$,

$$sx=x^2+xy$$ or

$$x^2-sx+p=0.$$

By solving the quadratic equation,

$$x=\frac{s\pm\sqrt{s^2-4p}}2,y=\frac{s\mp\sqrt{s^2-4p}}2.$$


In both cases, the two solutions are deduced from each other by exchanging $x$ and $y$. This is due to the symmetry of the equations (commutativity).