1
0

acoshl.c 564 B

1234567891011121314151617181920212223
  1. #include "libm.h"
  2. #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
  3. long double acoshl(long double x)
  4. {
  5. return acosh(x);
  6. }
  7. #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
  8. /* acosh(x) = log(x + sqrt(x*x-1)) */
  9. long double acoshl(long double x)
  10. {
  11. union ldshape u = {x};
  12. int e = u.i.se & 0x7fff;
  13. if (e < 0x3fff + 1)
  14. /* |x| < 2, invalid if x < 1 or nan */
  15. return log1pl(x-1 + sqrtl((x-1)*(x-1)+2*(x-1)));
  16. if (e < 0x3fff + 32)
  17. /* |x| < 0x1p32 */
  18. return logl(2*x - 1/(x+sqrtl(x*x-1)));
  19. return logl(x) + 0.693147180559945309417232121458176568L;
  20. }
  21. #endif