Computing the Square Root of Two

I was dusting off some of my old code for computing pi to many decimal places, and was reminded that I’d never written similar code for computing a more basic value: the square root of two.

The usual way to do this would be to use Newton’s iteration to solve x2 – 2 = 0. If you apply this, you get the following
iteration formula:

x
n 1
x = -- + --
n + 1 2 x
n

There’s a problem with this, you have to implement reciprocals (or long division) to let the Newton’s iteration work. If instead you try to solve 1/x^2 – 1/2 = 0, you get an easier iteration that also works:

Search

Find:

About Myself…

I'm Mark VandeWettering, husband, proud father of a U.S. Airman, grand dad of two beautiful grand daughters, technical director at Pixar Animation Studios, telescope maker, computer science and math afficianado, an Extra class radio amateur licensed as K6HX, and all around geek. I hope you enjoy my website.