- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Babylonian method to find the square root

The Babylonian method to find square root is based on one of the numerical method, which is based on the Newton- Raphson method for solving non-linear equations.

The idea is simple, starting from an arbitrary value of x, and y as 1, we can simply get next approximation of root by finding the average of x and y. Then the y value will be updated with number / x.

## Input and Output

Input: A number: 65 Output: The square root of 65 is: 8.06226

## Algorithm

sqRoot(number)

**Input:** The number in real.

**Output:** Square root of given number.

Begin x := number y := 1 precision := 0.000001 while relative error of x and y > precision, do x := (x+y) / 2 y := number / x done return x End

## Example

#include<iostream> #include<cmath> using namespace std; float sqRoot(float number) { float x = number, y = 1; //initial guess as number and 1 float precision = 0.000001; //the result is correct upto 0.000001 while(abs(x - y)/abs(x) > precision) { x = (x + y)/2; y = number/x; } return x; } int main() { int n; cout << "Enter Number to find square root: "; cin >> n; cout << "The square root of " << n <<" is: " << sqRoot(n); }

## Output

Enter Number to find square root: 65 The square root of 65 is: 8.06226

- Related Articles
- How to find square root by division method.
- Find the square root of 18.4041 by division method.
- Find the square root of 900 by the division method.
- 8086 program to find the square root of a perfect square root number
- How to solve square root in division method?
- How to find perfect square root?
- How to find the Square root of 169?
- Find the square root of 2025.
- Find the square root of 3.5.
- Find the square root of 1056.25
- Find the square root of 1250.
- Find the square root of 3881.29
- Find the square root of 6.9169
- Find the square root of 1.7424.
- Find the square root of 9216 by using the method of prime factorization.

Advertisements