I suppose since the advent of cheap calculators the task of working out the square root of a number has become simply a matter of pressing a few buttons and reading off the answer. But there was a time when we didn’t have calculators or slide rules or log tables – like these!
Before all of these we used one of several ways to calculate a square root. One technique, which I’ll describe, is a bit like long division and works like this…
First off group the numbers in pairs starting from the least significant digit before any decimal point and starting from the most significant digit if there is a decimal point. An odd number of digits allows a ‘pair’ of just one digit. So, for example, 561 would group as 5 and 61.
Then, taking the first pair, in this case 5, find the largest number whose square is <= 5. In this case, it is 2. So, put 2 into the result R. i.e. R=2
Then square R to give 4 and subtract this from the first pair (which is 5) and bring down the next pair next to the result of this subtraction. i.e.
Then double R to give 4 and work out the largest number N such that 4N x N <= 161. i.e forty something multiplied by ‘something’ <= 161.
Here N=3 and 43 x 3 = 129. Append 3 to the result R to give R=23 and subtract 129 from 161 and bring down the next pair, here there are no more pairs so we use ‘00’. This gives
Now double 23 to give 46 and find N such that
46N x N <= 3200. Here N=6. Append 6 to the result.
466 x 6 = 2796. Subtract 2796 from 3200 and bring down the next pair ‘00’. i.e.
Now double 23.6 ignoring the decimal. This gives 472. Now find N such that 472N x N <= 404 00. This gives N as 8. Append 8 to the result. 4728 x 8 = 37824. Subtract 37824 from 404 00 and bring down the next pair, “00” and so on…
And to 2 decimals we have 23.68.
The key thing to note is that on the first pass we square the value in the result and then subtract values and on subsequent passes we double the result and subtract values. If you try a few examples with pen and paper it should become clear and in the next post I’ll work through an implementation in Haskell.
Thanks for reading!