Eli5: how do machines calculate the value of root of numbers that aren’t perfect squares.

160 views

Eli5: how do machines calculate the value of root of numbers that aren’t perfect squares.

In: 70

7 Answers

Anonymous 0 Comments

There are a bunch of methods. The one I was taught is:

(0) If your number is negative, factor out the -1, whose square root is the special number “i” and only work with the positive part.

(1). Decide how close is close enough. Maybe you need to be accurate to within 0.0001 , maybe you need to be accurate within 0.00000000001 — but there will always be a point that is close enough.

(2). Guess the square root and divide the number by it. Any reasonable guess will do — for example, the biggest integer whose square is less than your number, or even just half of your number to be simple.

(3) Divide the number by the square root guess. If the difference between the quotient and the guess is within the target accuracy, you are done.

(4) Take the average of the guess and the quotient; that’s your new guess. Go back to step 3.

This is not the most efficient algorithm, but it’s easy enough to explain to a ten year old.

(Edited: used the wrong word for quotient)

You are viewing 1 out of 7 answers, click here to view all answers.