Freddie Mac analytics services may need a predictable square-root calculation without relying on language-provided math functions. Implement an algorithm that computes the square root of a nonnegative number using binary search.
Write sqrt_approx(x, epsilon):
x is a nonnegative integer or floating-point number.epsilon is a positive floating-point tolerance.r such that abs(r * r - x) <= epsilon.x = 0, return 0.0.The evaluator accepts answers within the required squared-error tolerance. Aim for logarithmic convergence rather than scanning candidate values incrementally.
def sqrt_approx(x, epsilon):