• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #include <math.h>
7 #include <errno.h>
8 #include "fastmath.h"
9 
10  /* asinh(x) = copysign(log(fabs(x) + sqrt(x * x + 1.0)), x) */
asinhf(float x)11 float asinhf(float x)
12 {
13   float z;
14   if (!isfinite (x))
15     return x;
16   z = fabsf (x);
17 
18   /* Avoid setting FPU underflow exception flag in x * x. */
19 #if 0
20   if ( z < 0x1p-32)
21     return x;
22 #endif
23 
24 
25   /* Use log1p to avoid cancellation with small x. Put
26      x * x in denom, so overflow is harmless.
27      asinh(x) = log1p (x + sqrt (x * x + 1.0) - 1.0)
28               = log1p (x + x * x / (sqrt (x * x + 1.0) + 1.0))  */
29 
30   z = __fast_log1p (z + z * z / (__fast_sqrt (z * z + 1.0) + 1.0));
31 
32   return ( x > 0.0 ? z : -z);
33 }
34