def c_acosh(x, y): # XXX the following two lines seem unnecessary at least on Linux; # the tests pass fine without them if not isfinite(x) or not isfinite(y): return acosh_special_values[special_type(x)][special_type(y)] if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE: # avoid unnecessary overflow for large arguments real = math.log(math.hypot(x/2., y/2.)) + M_LN2*2. imag = math.atan2(y, x) else: s1x, s1y = c_sqrt(x - 1., y) s2x, s2y = c_sqrt(x + 1., y) real = asinh(s1x*s2x + s1y*s2y) imag = 2.*math.atan2(s1y, s2x) return (real, imag)
def c_acosh(x, y): # XXX the following two lines seem unnecessary at least on Linux; # the tests pass fine without them if not isfinite(x) or not isfinite(y): return acosh_special_values[special_type(x)][special_type(y)] if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE: # avoid unnecessary overflow for large arguments real = math.log(math.hypot(x / 2., y / 2.)) + M_LN2 * 2. imag = math.atan2(y, x) else: s1x, s1y = c_sqrt(x - 1., y) s2x, s2y = c_sqrt(x + 1., y) real = asinh(s1x * s2x + s1y * s2y) imag = 2. * math.atan2(s1y, s2x) return (real, imag)
def c_asinh(x, y): if not isfinite(x) or not isfinite(y): return asinh_special_values[special_type(x)][special_type(y)] if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE: if y >= 0.: real = copysign(math.log(math.hypot(x/2., y/2.)) + M_LN2*2., x) else: real = -copysign(math.log(math.hypot(x/2., y/2.)) + M_LN2*2., -x) imag = math.atan2(y, fabs(x)) else: s1x, s1y = c_sqrt(1.+y, -x) s2x, s2y = c_sqrt(1.-y, x) real = asinh(s1x*s2y - s2x*s1y) imag = math.atan2(y, s1x*s2x - s1y*s2y) return (real, imag)
def c_asinh(x, y): if not isfinite(x) or not isfinite(y): return asinh_special_values[special_type(x)][special_type(y)] if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE: if y >= 0.: real = copysign( math.log(math.hypot(x / 2., y / 2.)) + M_LN2 * 2., x) else: real = -copysign( math.log(math.hypot(x / 2., y / 2.)) + M_LN2 * 2., -x) imag = math.atan2(y, fabs(x)) else: s1x, s1y = c_sqrt(1. + y, -x) s2x, s2y = c_sqrt(1. - y, x) real = asinh(s1x * s2y - s2x * s1y) imag = math.atan2(y, s1x * s2x - s1y * s2y) return (real, imag)
def c_acos(x, y): if not isfinite(x) or not isfinite(y): return acos_special_values[special_type(x)][special_type(y)] if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE: # avoid unnecessary overflow for large arguments real = math.atan2(fabs(y), x) # split into cases to make sure that the branch cut has the # correct continuity on systems with unsigned zeros if x < 0.: imag = -copysign(math.log(math.hypot(x/2., y/2.)) + M_LN2*2., y) else: imag = copysign(math.log(math.hypot(x/2., y/2.)) + M_LN2*2., -y) else: s1x, s1y = c_sqrt(1.-x, -y) s2x, s2y = c_sqrt(1.+x, y) real = 2.*math.atan2(s1x, s2x) imag = asinh(s2x*s1y - s2y*s1x) return (real, imag)
def c_acos(x, y): if not isfinite(x) or not isfinite(y): return acos_special_values[special_type(x)][special_type(y)] if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE: # avoid unnecessary overflow for large arguments real = math.atan2(fabs(y), x) # split into cases to make sure that the branch cut has the # correct continuity on systems with unsigned zeros if x < 0.: imag = -copysign( math.log(math.hypot(x / 2., y / 2.)) + M_LN2 * 2., y) else: imag = copysign( math.log(math.hypot(x / 2., y / 2.)) + M_LN2 * 2., -y) else: s1x, s1y = c_sqrt(1. - x, -y) s2x, s2y = c_sqrt(1. + x, y) real = 2. * math.atan2(s1x, s2x) imag = asinh(s2x * s1y - s2y * s1x) return (real, imag)