def newton_sqrt1(x):
    """Return the square root of x using Newton's method"""
    val = x
    while True:
        last = val
        val = (val + x / val) * 0.5
        if abs(val - last) < 1e-9:
            break
    return val