Aug 18, 2012

Rage Faces and Math

Originally published on divergentblue.com in 2012, restored from backup. Some links to other sites may no longer work.

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 xx) and the result is used as the first two digits of the answer. This can be represented by the expression 100(x−25)100(x - 25). The last two digits come from simply subtracting the number to be squared from fifty, then squaring it, (50−x)2(50 - x)^{2}. So the algorithm is simply:

S=100(x−25)+(50−x)2S = 100(x - 25) + (50 - x)^{2}

where SS is the square of xx.

The first question, and the one posed in the email is, does this really work? That is, does S=x2S = x^{2}? A few steps of algebra get us:

100(x−25)+(50−x)2=100x−2500+2500−100x+x2=x2100(x - 25) + (50 - x)^{2} = 100x - 2500 + 2500 -100x + x^2 = x^{2}.

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 x=4x = 4. 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 100(4−25)+(50−4)2=100(−21)+462=−2100+2116=16=42100(4 - 25) + (50-4)^{2} = 100(-21) + 46^{2} = -2100 + 2116 = 16 = 4^{2}, so the formula version checks out, but how about the mechanical algorithm? Well, 4−25=−214 - 25 = -21, so our first two digits are −2-2 and 11. Of course, this is already problematic, and now consider that  46246^{2} has more than two digits. We might end up with something like −212116-212116.

This places a constraint on xx, 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. 51−25=2651 - 25 = 26, 50−51=−150 - 51 = -1, and −12=1(=01)-1^{2} = 1 (= 01), so the comic boyfriend would get the correct answer of 26012601, 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 100100, otherwise, we’d have more than two digits. Imposing this limit, we get (50−x)2<100⇒−10<(50−x)<10⇒−60<−x<−40⇒40<x<60(50 - x)^{2} < 100 \Rightarrow -10 < (50 - x) < 10 \Rightarrow -60 < -x < -40 \Rightarrow 40 < x < 60. This is actually a subset of the previous boundary, and thus represents the complete set of possible values for xx 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 aa and bb. Then we’d write x2=100(x−a)+(b−x)2=100x−100a+b2−2bx+x2x^{2} = 100(x - a) + (b - x)^2 = 100x -100a + b^{2} -2bx + x^{2}. Since we require the sum of all terms other than the x2x^{2} to be zero, it should be apparent that 100−2b=0⇒b=50100-2b = 0 \Rightarrow b = 50 and −100a+b2=0⇒100a=2500⇒a=25-100a + b^{2} = 0 \Rightarrow 100a = 2500 \Rightarrow a = 25. That is, the algorithm uniquely determines the choice of the constants aa and bb.

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. : ).