The Sanskrit Square Root Algorithm

Years ago, no math education was complete without understanding how to compute a square root. Today, you are probably just reaching for a calculator, or if you are writing a program, you’ll probably just guess and iterate. [MindYourDecisions] was curious how people did square roots before they had such aids. Don’t remember? Never learned? Watch the video below and learn a new skill.

The process is straightforward, but if you are a product of a traditional math education, you might find his terminology a bit confusing. He will refer to something like 18b meaning “a three-digit number where the last digit is b,” not “18 times b,” as you might expect.

If you think the first few examples are a little convenient, don’t worry. The video gets harder as you go along. By the end, you’ll be working with numbers that have fractional parts and whose square roots are not integers.

Speaking of the last part, stay tuned for the end, where you’ll learn the origin of the algorithm and why it works. Oddly, its origin is a Sanskrit poem. Who knew? He also talks about other ways the ancients computed square roots. As for us, we’ll stick with our slide rule.

13 thoughts on “The Sanskrit Square Root Algorithm

    1. Everything old is new again… I learned this algorithm in grammar school, as well as the cube root version, and, back in the 1980’s, implemented it in microcode, then in hardware, for a bit slice processor. Fastest method in binary at the expense of, well, extra hardware. There are better options today.

      Still teach it as an algorithm study to engineering students, as well as the Babylonian method, along with several derivations for each.

  1. I am often insecure in the fact that there are a lot of things that i cannot calculate without the use of calculators. Things like decimal exponents (5^2.05), log with any random base, trigonometric values for random degrees.

    Like most people I’m not too far from a calculator at any given time but i still think i should be able to do these things. Interestingly, there is not a lot of material covering this on the YouTubes and internets

    1. Back in the 80s, we covered square roots using the Newton / Raphson method. Exponents, logs, trig functions were ignored. There’s a lot to feel i secure about.

      Never mind reading Knuth’s “Seminumerical Methods”. Heck, basic addition & subtraction using floats is a challenge.
      Kudos to whoever wrote the Dec64 / 128 code, used on the Swiss Micro calculators.

  2. Square roots have always fascinated me. In trying to learn to calculate them without SQR(x) I went back to my TRS-80 model I level 1 reference manual. It did not have any fancy math functions so the manual provided this BASIC subroutine:

    30000 end
    30010 rem "square root" input x. output y
    30020 rem also uses w & z internally
    30030 if x=0 then y=0 : return
    30040 if x>0 then goto 30060
    30050 print "root of negative #?" : stop
    30060 y=x*0.5 : z=0
    30070 w=(x/y-y)*0.5
    30080 if (w=0) and (w=z) then return
    30090 y=y+w : z=w : goto 30070
    

    Hopefully this will post correctly.. It is an easy study! :-)

    1. THis is the Babylonian method (Also called divide and average, it is the same recurrence as Newton’s method for the polynomial $x^2-c$, where the zero will be $\sqrt{c}$). It is VERY efficient if there is a fast (hardware) divide available, doubling the number of correct bits each iteration. The Sanskrit (traditional `long division’ method) is as fast as a single divide, at one bit per cycle, when there isn’t a fast, pipelined hardware divide that can have effectively one cycle cost.

  3. Back before the days of hand held calculators, my favorite cheat code for finding the nth root of a number was to look it up in a log table, dividing the result by n, then converting that result back into the answer I was looking for. In case you were wondering, I’d forgotten how to do it on my slide rule.

Leave a Reply to AdamCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.