Back to problems

Implement Square Root Without Using sqrt (Precision Required)

Algorithm · Squarepoint · Medium

Problem Write a function sqrt(x, eps) that computes an approximation of the square root of x without calling any library square-root function. The approximation r must satisfy the error bound rr - x = 0 eps – a real number specifying the allowed absolute error in rr (e.g., 1e-6) Output: a real number r that meets the error condition. You may use Newton's method, binary search, or any other approach that respects the constraints. Constraints 0 <= x <= 1e12 1e-12 <= eps <=…

Checking your access…