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.

5 comments:

  1. Super! Thanks... Now I just have to learn this before I get my mechanical calculator I ordered from eBay... :-)

    ReplyDelete
  2. Parabéns. O resgate desses métodos por calculadoras mecânicas é muito importante. Não é para todos, mas deve ser para sempre.

    ReplyDelete
  3. Sweet. Just got a couple Rapid calculators, both of which have minor problems but both of which are still deff useable. I've got the mulitiply & divine bit down good and am looking to start on square roots. This'll be fun. Thanks for the info & explanation. Numbers are finally beginning to make sense to me . . . after 74 years of breath ;-)

    ReplyDelete
  4. How would this method work for non perfect squares though?

    ReplyDelete
    Replies
    1. Good question. Decimal places for a non-integer square root can be calculated by adding an even number of zeros to the non-perfect square, then calculating the square root using the technique above. This will give decimal places up to half the number of zeros added.

      For example, to calculate the square root of 2, calculate the square root of
      20000000000 (2 followed by 10 zeros) using the method above, which produces the result 141421, which can be interpreted as the square root of 2 to 5 decimal places, 1.41421

      Note that the decimal approximation is truncated instead of being rounded at the last calculated decimal place.

      Delete