11.001001000011111101101010100010001000 Arithmazium
Home

This is an automatically generated file.

Part 1

Part 2

# =============================================
# Tests of square root accuracy and monotonicity.
# =============================================
def sqrt_single_bound_test(tlist):
    """Test x = sqrt(x*x), raise error if not, and track max and min
    signed error in units of ulp.

    Uses an artful decomposition of x into xa + xb to facilitate test for
    equality.
    ***TODO: elaborate that this decomposition is exact -- because the values
    of x all have trailing 0s?

    Args:
        tlist - a list of tuples of:
            x - value to be tested
            ulp - 1/2 ulp of argument x
            error_kind - level of alarm to raise

    Returns:
        True if all tests pass, False otherwise
    """

Part 3

    global min_sqrt_error, max_sqrt_error
    success = True
    for (x, ulp, error_kind) in tlist:
        xb = x * ONE_OVER_B
        xa = x - xb
        err = ((sqrt(x * x) - xb) - xa) / ulp

Part 4

        if err != ZERO:
            success = False
            if err < min_sqrt_error:
                min_sqrt_error = err
            if err > max_sqrt_error:
                max_sqrt_error = err
            bad_cond(error_kind, "\n")
            print("sqrt( {:0.17e}) - {:0.17e}  = {:0.17e}".format(x * x, x, ulp * err))
            print("\tinstead of correct value 0 .")
    return success


Part 5

Home