mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

Matt McIrvin

Chris Staecker has been continuing his wonderful "12 Days of Curtsmas" series on the vintage Curta calculator, and one of the later segments covered a mildly cryptic method supplied by the manufacturer for computing square roots on the Curta. Of course, it is not specific to the Curta but would really work with any functionally similar calculator, or with hand calculation:

youtube.com/watch?v=Wj3_VUQkBJ

There was a lot of puzzlement in his comments. This method uses a lookup table; if you're going to look up something in a table, why not just have a table of square roots and dispense with the Curta entirely?

Staecker pointed out that the method gives 5-digit accuracy and the table is much shorter than you'd need to get that kind of accuracy with a simple list of square roots. What it's really doing is giving you a piecewise linear approximation method, with the numbers processed slightly to get you past the initial steps.

Each entry has two numbers labeled 𝑅² and 1/(2𝑅). If you have 𝑁² and you want to find the square root 𝑁, you find the value of 𝑅² closest to 𝑁², and then add the first number and multiply the second to compute (𝑁²+𝑅²)/(2𝑅) . And that's it, your five-digit approximation.

What's going on there? Well, one way to see it is that the derivative of the square root of x is 1/(2√𝑥) , that is, 1/(2𝑅) in the Curta table. If you had some approximate guess 𝑅 , a refined one extrapolated along a tangent to the function would be 𝑅+(𝑁²−𝑅²)/(2𝑅) , which is (𝑁²+𝑅²)/(2𝑅) , the quantity calculated with the Curta method.

Jaap Scherphuis, another collector of vintage calculators who makes YouTube videos, has photos of the Curta square root pamphlet on his website:

jaapsch.net/mechcalc/curta.htm

You can see there that it goes on to tell you how a nine-digit refinement of the result "can be found quite easily"--that seems to be instructions for doing the second step in a Newton's method-like iteration. But it involves doing a long division on the Curta, though that's not how they phrase it.

www.jaapsch.netCurta - Jaap's Mechanical Calculators Page

It got me thinking about methods for finding square roots. The only one I ever bothered learning was the so-called Babylonian method (apparently a misnomer), aka Heron's method: take an initial guess for the square root, divide your original number by that, then take the *mean* of your guess and the quotient, which is a better guess. It's pretty obvious that this is going to be closer to the actual square root, so you just repeat the procedure and it converges fast enough to be pretty useful.

I recall a friend referring to this as "Newton's method" and initially my response was "what? Newton's method is something different". But actually it is equivalent to Newton's method for the positive root of 𝑥²−𝑐 = 0 . It took me way too long to realize that.

But there's also a method, sometimes called "the long-division method", for just cranking out the digits of the square root directly. Apparently people of a certain age were taught to do this as part of the standard school arithmetic curriculum, but I was not. The available online tutorials about this are a bit unclear, but I managed to work it out well enough to try to manually crank out the square root of 2, and man, it gets hard fast. Unlike regular long division, the numbers you have to divide get larger and larger as you go on:

byjus.com/maths/square-root-lo

I managed to get to √2≈1.4142, tripped on some kind of arithmetic error and gave up, but I guess that's not too bad.

Anyway, this long-division method is deterministic enough that it's possible to implement it mechanically, and there was a 1950s desktop electromechanical calcuator, the high-end Friden SRW, that actually did. Here's a description (not mine) from the HP Museum website:

hpmuseum.org/root.htm

I wanted to show a video of this working, but the SRW seems to have been much rarer than its square-root-less counterpart the STW, and I can't find one at the moment.

www.hpmuseum.orgHow The Friden Extracted Square Roots

@mattmcirvin The "square roots by long division" method is something I've known for 45 years or so. The good think about it is that it can be used for polynomials as well.

And you don't *really* need to be doing divisions in it ... the apparent divisions can be achieved with a "try it and see" method ... though in reality that is then a refinement of the underlying algorithm.

@mattmcirvin It can also be adapted to finding cube roots, once you know the underlying theory. I've found cube roots of small numbers using that, but there has never really been a use for it.

@ColinTheMathmo Yeah, the Friden used an iterative trial-and-error mechanism based on cranking out perfect squares by adding successive odd numbers.

@mattmcirvin ... reading your blog post now.

Well ... skimming, don't have much time.

Interesting how all these things are connected. A few simple ideas, combined cleverly.

@ColinTheMathmo hmm? I didn't make a blog post, must be somebody else's (that I linked to?)

@mattmcirvin Sorry, yes, I was reading this:

hpmuseum.org/root.htm

You lunk to it and I followed that.

My mistake ... but still all cool stuff.

www.hpmuseum.orgHow The Friden Extracted Square Roots

@mathr I think the "Vedic" algorithm mentioned there is equivalent to the long-division one. The others are different.

...the "Perturbation" note down at the bottom seems very similar in spirit to the Curta algorithm, might be a simple transformation of it.

@mathr ...Oh, also, that infamous Quake III *inverse* square root is kind of similar in spirit to the Curta square root algorithm, except that instead of a table lookup for the first step, it uses dirty tricks with the IEEE float bit representation to get a really rough approximation that it can refine through a Newton iteration:

en.wikipedia.org/wiki/Fast_inv

en.wikipedia.orgFast inverse square root - Wikipedia

@mathr ...The basic idea being just that since IEEE floats put the exponent in the most significant bits, if you just cast the bits to an integer, you get something that is a very roughly a base-2 logarithm, and by tweaking it with a "magic" offset you can make it a little closer.

If you've got that rough base-2 logarithm, you can then do all kinds of quick and dirty math by manipulating it in some way and casting back to a float.

And if you do even one iteration of Newton's method after that, you can get a fairly accurate value for your function in much the same way that the Curta method gets five-digit accuracy starting with a very short lookup table.