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

361 views

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

In: 70

7 Answers

Anonymous 0 Comments

The oldest method is a cheat based on knowing that the square root is going to be something in the middle between two products that make that number. This should make sense if you think about it, a little, if two numbers multiply to something, a * b = c, you can nudge a up a little and b down a little to have c stay the same. Using this, we get a method from ancient greece called Heron’s method

Lets say you want to take the root of 19.

Take a guess, lets say 6.

Divide 19/6 = 3.1667.

This tells us that the the square root is between 3.1666 and 6. So we can choose the middle between these, by taking the average (3.166 + 6)/2 = 4.583. We can choose really anything in between these numbers but the exact middle is probably gonna be the best guess.

We can repeat this process

19/4.583 = 4.145.

(4.145 + 4.583)/2 = 4.364, our next guess.

19/4.364 = 4.353

(4.364 + 4.353)/2 = 4.3585, our next guess

You can keep repeating this process until you get the desired error.

Running this even just 3 times gives us 4.3585^2 = 18.99652225, which is pretty damn close.

Newton was able to improve on this a little bit with something called Newton’s method, it actually can be used to solve for more formulas than just the square root, but its classic solution was for that of a square root.

Newton tweaks this by using a a calculus thing called a derivative to make a better guess at every iteration than taking just the average. With a better guess, the formula converges towards the square root much faster.

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