# The Babylonian algorithm for computing square roots

## How it works

Using an initial value (X0) and the number we are finding the square root of (T), the algorithm finds the number Xn+1, the mean of the two numbers Xn and T / Xn (which is the number we multiply Xn 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 X0, X1, X2 etc. Otherwise you will only see the final value.

 Number to square root: Initial Value: Number of iterations: View result from each iteration