def pythag(a, b):
    """Computer c = (a^2 + b^2)^0.5 without destructive underflow or overflow

    It solves the Pythagorean theorem a^2 + b^2 = c^2
    """
    absA = abs(a)
    absB = abs(b)
    if absA > absB:
        return absA * sqrt(1.0 + (absB / float(absA)) ** 2)
    elif absB == 0.0:
        return 0.0
    else:
        return absB * sqrt(1.0 + (absA / float(absB)) ** 2)