Date: Tue, 29 Oct 1996 14:34:52 -0800
From: "Quandries and Queries Consultants
Sender: Ben
Organization: H&L Management Systems

how do you calculate a square root? eg the square root of 2.

There is obviously some sort of successive approximation type algorithm for doing it to however many decimal places is required, but what is the algorithm?

any help much appreciated

Ben.

Hi Ben:

You are correct about the successive approximation algorithm for calculating square roots. There are many such algorithms but I will only show you one, the most rudimentary. This procedure will work for square roots, cube roots, fourth roots and in many other situations as well. I will illustrate it by finding the square root of 2.

To simplify the notation let r be the square root of 2. We need to start with an interval that contains r, here start with the interval from l=1 to u=2. Divide the interval in half, decide which half contains r to get an interval that contains r with half the length of the previous one then start again.

More explicitly:

  1. Let m = (l+u)/2
  2. Compare m2 to 2
    • If m2 > 2 then let u = m
    • If m2 < 2 then let l = m
  3. Return to step 1
If you apply this iteration ten times you end with l = 1.41406 and u = 1.41602 so the root of 2 is approximately (l+u)/2 = 1.41504. This procedure, although easy to apply, is not commonly used as there are other algorithms that arrive at a desired accuracy with fewer steps.

Harley

Go to Math Central

To return to the previous page use your browser's back button.