A co-worker of mine recently emailed me a link to a rage face comic with the following:

“Is this always true??? I mean the math part… Stephen???”

Knowing that I have an irrational love of rage faces as well as math, he knew I couldn’t resist trying to prove or disprove the algorithm presented in the comic, which I’ve displayed below (without permission) in case you didn’t follow the link.

So, here goes:

In both examples, twenty-five is subtracted from the number to be squared (let’s call it ) and the result is used as the first two digits of the answer. This can be represented by the expression . The last two digits come from simply subtracting the number to be squared from fifty, then squaring it, . So the algorithm is simply:

where is the square of .

The first question, and the one posed in the email is, does this really work? That is, does ? A few steps of algebra get us:

So, we can say that if the algorithm is performed according to the formula above, yes, this method always works, however, the comic does not directly use any formula, so let’s see where the two methods diverge, if anywhere.

Consider a concrete example by letting . Certainly, we wouldn’t want to resort to such a complicated algorithm for such a basic operation, but suppose we did use the formula, we’d get , so the formula version checks out, but how about the mechanical algorithm? Well, , so our first two digits are and . Of course, this is already problematic, and now consider that has more than two digits. We might end up with something like .

This places a constraint on , namely that it must be greater than or equal to twenty-five.

One might also suspect numbers larger than fifty to introduce the same sort of trouble, however, the parity of the square function saves us. For example, consider squaring the number fifty-one in this way. , , and , so the comic boyfriend would get the correct answer of , provided he padded the single digit answer with a leading zero.

The subtraction here does give us a constraint, however, because we need the square of the result to be less than , otherwise, we’d have more than two digits. Imposing this limit, we get . This is actually a subset of the previous boundary, and thus represents the complete set of possible values for for which this method will “work”.

I was curious about the choices of twenty-five and fifty, so I wanted to see what other combinations might work. As it turns out, there are none! Let’s see why. Suppose we could choose any two numbers to perform this trick, call them and . Then we’d write . Since we require the sum of all terms other than the to be zero, it should be apparent that and . That is, the algorithm uniquely determines the choice of the constants and .

Although its proof can be reduced to a simple algebra problem, the algorithm is non-obvious, but simple. Whoever designed it had a very nice insight. Feel free to post similar ones you may have found in your travels. Bonus points if your submission is in the form of a rage face comic. : ).