Babylonian Method is one of the easiest methods to calculate square root of non-negative number.

Algorithm:

IN
non-negative real numbers: x, precision
OUT
square root of x
1. Set x to number / 10 and y to number / x.
2. Make x = (x + y) / 2 and y = number / x.
3. Check if x - y > precision.
4. If it is true go to step 2.
5. If not end algorithm and return x as square root of given number.

Sample Output:

IN
3
0.0000000001
OUT
1.7320508082191837
Iteration Numberxy
10.310
25.150.5825
32.86621.0466
41.95641.5333
51.74491.7192
61.73201.7320
71.73201.7320

 

Java Implementation C# Implementation Python Implementation C++ Implementation



Babylonian Method Algorithm
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. You can read more about it the Cookies&Privacy Policy Section Above. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this. You can read more about it the Cookies&Privacy Policy Section.

Close