Home

# The Babylonian algorithm for computing square roots

## How it works

Using an initial value (X_{0}) and the number we are finding the square root of (T), the algorithm finds the number X_{n+1}, the mean of the two numbers X_{n} and T / X_{n} (which is the number we multiply X_{n} by to get T). By doing this, we recieve a number slightly closer to the square root with each iteration. You will probably see when using the program below that the estimate converges fairly quickly, however maximising the amount of iterations will produce a better result. The answers are given to 25 decimal places; 10 iterations should be enough to get the exact value to this degree of accuracy, providing you give a reasonable initial value.

If you choose an initial value which is a bad estimate for the square root, the algorithm may take a lot of iterations to get close to the actual square root. If you are stuck deciding an appropriate square root estimate, check out the rough square root estimation page here.

## The program

Enter your number to square root, the number of iterations to carry out, and say if you would like to see the result from each iteration. If you check the last box you will see the values of X_{0}, X_{1}, X_{2} etc. Otherwise you will only see the final value.