You are Here: Home

# Way To Make Root Estimation watch

1. Not sure whether to post this here or in the maths forum, but I'll give you a go.

I'm writing a very simple program to estimate the square root of a given number, using the Newton iteration method (http://en.wikipedia.org/wiki/Methods...wton_iteration). However, I can't think of a way to automatically make the initial estimate of the square root. I suppose the other option would be to have an arbitary estimation for all roots, and differ the number of iterations of the formula based on the magnitude of the number... maybe.

Anyone have a suggestion?

Thanks.
2. Why not use the first method under:
Finding square roots using mental arithmetic

// x is the number we're trying to approximate the square root of.

// number of iterations
iteration = 1

// cumulative frequency
cumulativeFrequency = x

while ( cumulativeFrequency > (2*iteration - 1)) {
cumulativeFrequency = cumulativeFrequency - (2*iteration - 1)
iteration = iteration + 1
)

print "Approximation to the square root of" + x + " is " + iteration

That's a bit of pseudo pseudo-code.

It subtracts the odd integers (going from 1, 3, 5, ...) until the number is less than the number you were planning to subtract from, e.g.:

To find an approximation of the square root of 27:

27 - 1 = 26
26 - 3 = 23
23 - 5 = 18
18 - 7 = 11
11 - 9 = 2

We stop now since subtracting 11 from 2 would result in a negative number. Since we've gone through this cycle 5 times, the first digit of the square root of 27 is 5.
3. That's probably a far more suitable way actually, thanks.
4. If you want an acurate way of doing this, there is a method rather like long division.

First hit on google for "square root by hand". I used to know this. Now I don't. A good read none the less. As for whether this will produce less operations or not, my_clue == 0.

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: April 9, 2006
Today on TSR

### Fastest and slowest offer senders

Which unis still haven't sent offers?

Poll
Useful resources