In search of the square root (mechanical calculators)

Nice article here (in German)

Archimedes, Badenia, Brunsviga, Diehl, Euclid, Thales, Triumphator, Walther: These were machines from the golden age of mechanical computing. They had no printing mechanism and were primarily used for adding, multiplying, and dividing. In the late 1950s, the engineer Willi Faber created a machine in the East Westphalian town of Neesen that could also square numbers and extract roots.

Here’s a missing square root function:

Caption: Brunsviga triple calculator… There would be space for the automatic root extraction function in the upper left corner.

Edit: see also previous topics
Many mechanical calculators
CT scan of a Curta (pepperpot) mechanical calculator
Fascinating Soviet mechanical computer in Russia: the Ascot 170

4 Likes

Squaring isn’t difficult - it’s just 2 multiplies, scale as required.

Square root… on the other hand…

I have a few mechanical calculators and I remembered the manual for my Curta has a method- but right now I can’t find the manual, however

This would readily adapt for the Brunsviga/Nippon/Busicom pinwheel types. The first one is classic Newton - involves a lot of remembering numbers along the way, the other they call the “Dibble Dabble” method.

That really in a “Frankencalc” above though - going to need good arm muscles to use it regularly…

-Gordon

2 Likes

I’m guessing Newton’s method will in this case be slower.

I did do some investigations into square root routines, specifically for situations where there is no fast multiply or divide. But I didn’t finish.

2 Likes

No idea how my Sharp Compet 361 does it, in all its discrete components, magnetic core and nixie tube wonder. It doesn’t even advertise that it can do roots, but it can.

I’m not super keen to dig about in it while it’s running, as those display power lines run at 185 V. A little too bitey.

2 Likes

Ah, perhaps ÷= - what a civilised shortcut! (I would expect reciprocal from most simple calculators.)

1 Like

It has some weird things in there, like the red = key for subtraction. Its spec shows 0.31 seconds for a 16 digit square root: not bad for a 50 kHz machine, and possibly faster than later Texas handhelds like the SR-50/TI-30

1 Like

It may be noteworthy to mention that the problem almost disappears in binary: a candidate either fits or does not, and what’s taking guesses and backtracking with larger radix systems becomes a simple binary condition with an immediate answer. Doing this in base-10 and mechanically is really “on the other hand”!

1 Like

I wish I could remember the algorithm the HP35 calculator used; it was probably a cordic variation. I do remember starting with 1, then adding 3, then 5, then 7 (producing the square) until it got bigger than the number whose swaure root was being taken. The number of iterations was an approximation of the square root. It then did something like adding .1, .3, .5 etc , then .01, .03 , .05, successively refining the answer until it got to the precision it needed. The HP35 was a marvel - all those scientific functions in 767 words of 10bit ROM (one word was not possible to use for very obscure reasons having to do with the keyboard…)

What I was thinking of was something along the line of this [1], where I’m trying to make sense of some early 1960s code for the DEC PDP-1.

[1] https://masswerk.at/spacewar/inside/insidespacewar-pt6-gravity.html#square_roots
(This is part of an exursus covering the math routines found in Spacewar!. I’ve no idea where this particular routine came from: multiply and divide routines came from BBN, the sine/cosine routine came from Adams Associates, who were working with Itek on a CAD system, but there’s no info or comment on this one.)
The lesson of this is that some math problems are much easier in binary, since choices become simple conditions with definitive answers, thanks to the small radix. Conversely, algorithmic complexity increases with the radix size – and then doing this in mechanics…

1 Like

From a page you link within:

When there was a Friden in use in the room, everyone there knew it. The room lights dimmed, the motor whirred, the entire desktop shook, and the wheels spun with a sound somewhere between a threshing machine and a car in dire need of Mr. Transmission. It sounded as though the machine couldn’t possibly last out the day, but in fact, the Friden was quite a reliable machine. The basic Friden was strictly a four-function calculator, with no memory except the little wheels on the carriage. However, a square root version was available at considerable extra cost. Our office had only one square root Friden, so we all had to take turns with it when we needed square roots. Or so I thought.

One day I was busily thinking deep-space thoughts, while my officemate was banging away on our common, non-square-root Friden. I heard a strange sound that went something like “punch-punch-cachunk, punch-punch-cachunk, punch-punch-cachunk-DING, punch-punch-DING-clang-clang” in a repeated rhythm. I thought my mate had either lost his marbles, or was creating some new kind of computer game.

I asked him what the heck he was doing. He said, “Finding a square root.”

“But, um…,” I said, “this isn’t a square root Friden.”

“I know,” he replied. “That’s why I have to do it this way.”

3 Likes

Just to note, I came across a 1990 paper on binary square root: A Fast Method for Finding an Integer Square Root by Ken Lyons of Harris Semiconductor. It seems the RTX2000 Forth CPU had a square-root-step instruction:

In the RTX processors a 16 bit root and a 17 bit remainder of a 32 bit number is calculated in 23 cycles, including initialization and a subroutine call and return. Since this is on the order of the amount of cycles required to perform one multiplication operation without a hardware multiplier, this algorithm is much faster than Newton’s method, which requires numerous multiplications. Even without special hardware, the algorithm should be much faster than Newton’s method on machines without hardware multipliers.

(via Did any processor implement an integer square root instruction? on retrocomputing stack exchange.)

3 Likes

Is there a good source of integer algorithms? I’d be interested in seeing integer trig. and log functions, as well.

1 Like

Generally, with algorithms relying on shift-divide and shift-multiply steps, there shouldn’t be much of a difference, since this is mostly a matter of adjusting the values in the registers. Generally, algorithms will be advertised as fractional (with the decimal point to the left of the most significant bit), but if you align values right (padding to the left with zeros), values can be assumed as integer. But don’t ask me, if this still holds up for transcendental functions. Most of these involve multiple computational steps and precision will be lost on the lower end. So, if we align to the right, there should be some impact.

But, of course, there’s the famous Minsky circle algorithm,

XNEW = XOLDepsilon × YOLD
YNEW = YOLD + epsilon × XNEW

(which isn’t exactly trigonometry, but close and works on integer coordinates.)

This is a variation on the well known formula,
x’ = x × cos(θ) − y × sin(θ)
y’ = x × sin(θ) + y × cos(θ)
with the common shortcut assumptions that the cosine will approach 1 for small values of θ and that the sine will approach θ for small values (as known from some video games), which is guaranteed by our small (less than zero) epsilon, which can be transformed to,
XNEW = XOLDepsilon × YOLD
YNEW = YOLD + epsilon × XOLD
This, however, is not a circle and will result in an increasing spiral.

Somehow, Minsky’s error self-corrects this. It will be still not exactly a circle, though, rather a fat ellipse rotated by 45°.

So, how does this work? Well, for any conical (function which wraps around a cone), we can tell from its determinant (|A|), if it is to return to where it started. Only if this is 1, the conical will loop.
So, looking at our defective shortcut version,
XNEW = XOLDepsilon × YOLD
YNEW = YOLD + epsilon × XOLD
which is


⎛ xn+1 ⎞   ⎛ 1   −ε ⎞ ⎛ xn ⎞
⎜      ⎟ = ⎜        ⎟ ⎜    ⎟
⎝ yn+1 ⎠   ⎝ ε    1 ⎠ ⎝ yn ⎠

the determinant is (1×1)−(−ε×ε) = 1+ε² > 1, thus the spiral.
However, the Minsky version gives us

⎛ xn+1 ⎞   ⎛ 1   −ε ⎞ ⎛ xn ⎞
⎜      ⎟ = ⎜        ⎟ ⎜    ⎟
⎝ yn+1 ⎠   ⎝ ε  1−ε²⎠ ⎝ yn ⎠

which indeed cancels out the error (ε²): (1×(1−ε²))−(−ε×ε) = 1−ε²+ε² = 1
So, while not exactly a circle, it will still loop and with small values of epsilon (as may be achieved by right-shifts), it will be close.
Gene Salamin gave another explation in HAKMEM, Item 152, but this is still generally the same concept.
(Rich Schroeppel already hinted at having a look at the predecessor in HAKMEM, Item 150.)

1 Like

Here’s a HAKMEM link:

I’ve been using Heron’s method for finding integer square roots in a few little test programs I’ve written in BCPL and my own TinyBasic. It’s iterative, but seems fast enough for 32-bit integers:

This is my TinyBasic version:

REM Integer Square Root - Herons method.
REM   Input:  S
REM   Output: Q
REM   Uses:  X,Y

1000 IF S < 2 Q=S : RETURN
1110 X=S/2
1120 Y=(S/X+X)/2
1130 DO
1140   X=Y
1150   Y=(S/X+X)/2
1160 UNTIL X <= Y
1170 Q=X
1180 RETURN

See: Square root algorithms - Wikipedia

And looking at some old (paper) log tables I have; “Four-Figure Mathematical Tables” It has a couple of pages of square roots (1-10 and 10-100) It was first published in 1923, so someone, somewhere did the calculations for that and wrote them down before typesetting, hopefully correctly…

-Gordon

2 Likes

See also the calculating prodigies, as mentioned previously in Computing at CERN - humans. In particular, perhaps, Zacharias Dase (1824 - 1861)

Dase did seek some employment in addition to making money from his exhibitions:-

In 1844, he had a position in the Railway Department in Vienna; in 1845 he appears in Mannheim; in 1846 he seems to have had a position in Berlin.

He undertook other tasks which were suggested to him as being useful for science. He constructed 7 figure tables of natural logarithms of the numbers from 1 to 1,005,000 in 1847 (this task was completed over a period of three years). He also assisted in reducing the data which had been collected for the Prussian triangulations and completed this task in the same year of 1847:-

In 1850 the largest hyperbolic table, as regards range, was published by him under the title ‘Tafel der natürlichen Logarithmen der Zahlen’ Ⓣ; the same was reprinted in the annals of the Vienna observatory.

(One of Babbage’s motivations was to automate not only the computation but also the route to printing: the printout of one of his designs was to be an impression on papier mache ready to be cast, as I recall.)

4 Likes

AKA stereotype, or in the North American press, flong. This is supposedly a corruption of the Spanish word flan: while stereotypes do look slightly cakey, I wouldn’t eat one for dessert.

1 Like

A, yes, I forgot. HAKMEM is a collection of programming related memos from Minsky’s AI lab at MIT. Here, it’s particularly about AI Memo 239, from February 29, 1972.
(Period-correctly, this includes a few snippets of PDP-10 code.)

https://www.inwap.com/pdp10/hbaker/hakmem/hacks.html

(The related discussion starts with Minsky’s entry at Item 149.)

Finally, for the more visually oriented, here’s a visualisation of the relation of conical functions and their determinant. (This is from an unfinished blog post about the “Minskytron”, I wrote a few years ago, which became much too long to be of any use.)