Tuesday 7 October 2014

Calculating square roots on a pinwheel calculator

Before electronic calculators became affordable, complex calculations were often done using pinwheel calculators. These were manufactured by several companies, for example, Odhner, Brunsviga, Thales, Schubert, all based on designs of Frank Baldwin and Willgodt Odhner in the 19th century.

Original Odhner 127
Original Odhner 227
Brunsviga 20

Having recently acquired three of these calculators, I set about investigating what they were capable of. As well as the four basic arithmetic operations, addition, subtraction, multiplication and division, square roots can also be calculated.

The instruction manual for the Original Odhner 227 describes the procedure to extract the square root of 966289.

At first glance, the instructions look like an alchemist's spell, but they are performing the following calculations to derive 966289 = 983:

From Odhner 227 instructions (click to enlarge)

c)
 966289
 
- 10000 - 30000 - 50000 - 70000 - 90000 -110000 - 130000 - 150000 - 170000
=
156289
( 9 subtractions)
d) & e)
156289
 
- 18100 - 18300 - 18500 - 18700 - 18900 - 19100 - 19300 - 19500
=
5889
( 8 subtractions)
f)
5889
1961 - 1963 -1965
= 0
( 3 subtractions)

 The algorithm is based on the fact that the square of n is the sum of the first n odd numbers:
12 = 1     =     1
22 = 4     =     1+3
32 = 9     =     1+3+5
42 = 16    =     1+3+5+7
52 = 25    =     1+3+5+7+9
etc.

The square root of a number can therefore be calculated by
subtracting successive odd numbers until the sum is zero.
The square root is the number of subtractions performed.

For example, to find the square root of 64,
successively subtract 1,3,5,... until zero is reached.
The number of subtractions required, in this case 8,
is the square root of the number.

For large numbers, e.g. 966289, this would obviously be
impractical, but we can attack large numbers one pair of digits
at a time, to produce one digit of the square root at a time:
64 -  1 = 63
63 -  3 = 60
60 -  5 = 55
55 -  7 = 48
48 -  9 = 39
39 - 11 = 28
28 - 13 = 15
15 - 15 =  0

To find the first digit of the square root of 966289, subtract odd ten thousands: 10000, 30000, 50000, ...  until the point just before the result would turn negative, so subtract 10000+30000+...+170000.  Now, 1+3+...+17 = 92 , so 10000+30000+...+170000 = 900. The first digit of the square root is 9.

To find the first two digits of the square root, we could start with 966289 and subtract odd hundreds: 100, 300, 500,... up to 19500. However, we have already subtracted 9002, which is equal to 100+300+500+...+17700+17900, so we can start subtracting at 18100, subtracting only 18100+18300+...+19500.  We have now subtracted a total of 9802.

Similarly to find the first three digits of the square root (i.e. the complete square root), we could start with 966289 and subtract 1, 3, 5,...up to 1965. But we have already subtracted 9802 = 1+3+5+...+1959, so we can start subtracting at 1961, only needing to subtract 1961+1963+1965

10000+30000+...+170000 
= 9002
18100+18300+...+19500  = (100+300+...+19500) - (100+300+...+17900) = 9802 - 9002
1961+1963+1965   = (1+3+...+1965) - (1+3+...+1959) = 9832 - 9802


The algorithm can also be used to calculate approximations to the square root of numbers that are not perfect squares. Here is a video by James Grime (singingbanana) and Hugh Hunt that demonstrates an Original Odhner being used to calculate 2.