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) */
asinhl(long double x)11 long double asinhl(long double x)
12 {
13 long double z;
14 if (!isfinite (x))
15 return x;
16
17 z = fabsl (x);
18
19 /* Avoid setting FPU underflow exception flag in x * x. */
20 #if 0
21 if ( z < 0x1p-32)
22 return x;
23 #endif
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_log1pl (z + z * z / (__fast_sqrtl (z * z + 1.0L) + 1.0L));
31
32 return ( x > 0.0 ? z : -z);
33 }
34