Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <math.h>
  2. #include <errno.h>
  3. #include "fastmath.h"
  4.  
  5. /* acosh(x) = log (x + sqrt(x * x - 1)) */
  6. long double acoshl (long double x)
  7. {
  8.   if (isnan (x))
  9.     return x;
  10.  
  11.   if (x < 1.0L)
  12.     {
  13.       errno = EDOM;
  14.       return nanl("");
  15.     }
  16.   if (x > 0x1p32L)
  17.     /* Avoid overflow (and unnecessary calculation when
  18.        sqrt (x * x - 1) == x).
  19.        The M_LN2 define doesn't have enough precison for
  20.        long double so use this one. GCC optimizes by replacing
  21.        the const with a fldln2 insn. */
  22.     return __fast_logl (x) + 6.9314718055994530941723E-1L;
  23.  
  24.    /* Since  x >= 1, the arg to log will always be greater than
  25.       the fyl2xp1 limit (approx 0.29) so just use logl. */
  26.    return __fast_logl (x + __fast_sqrtl((x + 1.0L) * (x - 1.0L)));
  27. }
  28.