More Positive

Here’s a numerical curiosity I came across.  I checked out a book from the library, and while the librarian correctly recorded the due date as “6/10/22”, the latter “2” looked like a 0 from a distance, so I read it as “6/10/20”.  I wondered if there was a clever way to relate the three numbers together.

There are probably many ways, but what I came up with was “If you add 6 and 10, and then add the difference between those two, you’ll get 20”.  Then I started playing with other pairs of numbers – 3 and 5, 1 and 4, and so on.  All of the results came out even.  Was that a general rule?  Given 2 integers a and b, will this always produce an even result?

Let a and b be positive integers, and r the result of our arithmetic machinations.  Our formula becomes:

r = a + b + |a – b|

Now, let’s consider the possibilities:

  • If a is larger, then the absolute value portion reduces to simply “a – b”, the b’s cancel, and what’s left is 2a
  • If b is larger, then the absolute value portion reduces to simply “b – a”, the a’s cancel, and what’s left is 2b
  • If a and b are the same, then the absolute value portion is 0, leaving 2a (or alternatively, 2b)

Interestingly, not only will this always produce a positive result, it will always be twice the larger integer.

That works if we start with positive integers.  What happens if we introduce other combinations?

  • Two negative integers: the result ends up being twice the smaller of the two negatives.  For example –6 and –10 produce a result of –12.  You can also define “the result will be twice the more positive value”.
  • One positive and one negative: The result is still twice the more positive.
  • One positive and 0?  Still twice the more positive number.

What about one negative and 0?  That interestingly follows the same rule – the result will continue to be the more positive of the two, which is 0 in this case.  If we let a be the negative number and b be 0, the formula reduces to

r = a + |a|

With a being negative, this will always cancel out, leaving 0.

Is there a name for any of this?

* Edited to correct the origin story of this proof.