Finding square root without using sqrt function?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Finding the square root of a number is a common mathematical operation. While many programming languages offer built-in functions—such as Python's math.sqrt()—understanding how to calculate square roots manually not only enhances your mathematical acumen but is also crucial in computational fields where optimizing or avoiding specific functions might be necessary. This article provides an overview of manual methods for finding square roots without using the sqrt function.
Overview of the Methods
1. Newton's Method (Newton-Raphson Method)
Newton's Method is an iterative numerical technique that provides successively better approximations to the roots (or zeroes) of a real-valued function. It's efficient and widely used due to its quadratic convergence property.
Technical Explanation
• Function Definition: Newton's Method involves approximating the square root of a number N by setting up the function . The root of this function is the square root of N.
• Iterative Formula: The iterative formula to converge towards the square root is:
where . Thus:
• Initialization: Start with an initial guess, , for example, or another positive number if further optimization is required.
Example
To find the square root of 25:
• Start with . • Use the iterative formula:
Repeating this process several times will converge to the square root.
2. Binary Search Method
This method is effective for finding square roots of non-negative numbers by utilizing the properties of a sorted sequence.
Technical Explanation
• Initial Range: Suppose you're finding the square root of N. Begin with a range [0, N].
• Mid-Point and Comparison: Calculate mid-point . If is sufficiently close to N, return m as the square root. If , move the low bound to . Otherwise, move the high bound to m.
Example
To find the square root of 25:
• Start with initial range: [0, 25]. • Calculate . Since , adjust the range to [0, 12.5]. • Repeat until you narrow down to the desired precision.
3. Long Division Method
A manual method primarily taught in schools before calculators became popular.
Technical Explanation
• Digits Grouping: Separate the digits of the number in pairs from right to left (for digits to the left of the decimal point).
• Estimation and Subtraction: Find the largest integer whose square is less than or equal to the pair and write it above the line. Subtract the square from the group and bring down the next pair of digits.
• Double and Find Next Digit: Double the result written above and determine the next digit by estimating what digit in the form of (20 × result + digit) × digit would be less than or equal to the current number.
Example
To find the square root of 625:
• Pair the digits: (6 25)
• Estimate: The closest square to 6 is 4 (since ). Write down 2. Subtract 4 from 6, get 2 and bring down 25.
• Next: Double 2 to get 4 and find a digit such that . It turns out 5 works (). The square root is 25.
Comparing the Methods
| Method | Efficiency | Applications | Notes |
| Newton's Method | Fast | Engineering, CS | Needs a good initial approximation. |
| Binary Search | Moderate | General purpose | Best for non-negative integers. |
| Long Division | Slow | Educational | Manual calculation. Requires practice. |
Conclusion
Calculating square roots manually or algorithmically without relying on built-in functions or libraries helps deepen understanding of numerical methods. Each method has its specific applications and advantages: Newton's method is particularly effective in programming, binary search is understandable and simple to implement, and the long division method enhances manual problem-solving skills. Exploring these methods offers valuable insights into both mathematical theory and practical calculations.

