I ran into something interesting when working last night that wasn’t immediately obvious to me at first. It’s an alternate way to calculate the product of any two numbers.

I first noticed something was going on when I squared a number and then compared it to the product of numbers on either side of the original number:

5 * 5 = 25 6 * 4 = 24 (1 from 25) 7 * 3 = 21 (3 from 24) 8 * 2 = 16 (5 from 21) 9 * 1 = 9 (7 from 16)

If you subtract each result from the one before it, you see the series: 1, 3, 5, 7. “That’s interesting, I’m increasing the distance between the two numbers, and the result keeps changing by 2 also, I wonder if there’s something to that. Maybe I just got lucky, and this is something odd about 5*5 in particular. So I tried the same process, but started with 6*6, or 8*8 and got the same result.

Next, instead of looking at the difference in values from the product before it, I decided to check what the value would be compared to the original square of their average.

5 * 5 = 25 (the average, base case) 6 * 4 = 24 (1 from average) 7 * 3 = 21 (4 from average) 8 * 2 = 16 (9 from average) 9 * 1 = 9 (16 from average)

Now that’s interesting! The result of two seemingly unrelated numbers, 7 and 3 for instance, is a perfect square away from the square of the two numbers’ average.

So at this point, I have the theory that:

x * y = average(x,y)^2 - someOtherSquareRelatedTo(x,y)

Looking at the 8*2 example, i notice that they’re 9 away from 25, or 3^{2}. The average of 8 and 2 is 5, so both 8 and 2 are a distance of 3 away from 5. So that’d give the formula:

x * y = average(x,y)^2 - (average(x,y) - min(x,y))^2

If I expanded that out, then that’d result in:

x * y = average(x,y)^2 - (average(x,y)^2 - 2*average(x,y)*min(x,y) + min(x,y)^2)

which simplifies to:

x * y = 2*average(x,y)*min(x,y) - min(x,y)^2

That looks just crazy to me. Maybe I’m missing something, but that’s just not obvious to me at all when I think about arbitrary x and y. I set up a script here just to double check and run the numbers, and sure enough it works out. Even for fractions and negative x and/or y.

Did I miss this lesson in school? I feel proud that I’ve figured this out, and usually when I feel like this it means I’ve missed something super obvious :D.