#include "libm.h"12/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */3double __cdecl asinh(double x)4{5union {double f; uint64_t i;} u = {.f = x};6unsigned e = u.i >> 52 & 0x7ff;7unsigned s = u.i >> 63;89/* |x| */10u.i &= (uint64_t)-1/2;11x = u.f;1213if (e >= 0x3ff + 26) {14/* |x| >= 0x1p26 or inf or nan */15x = log(x) + 0.693147180559945309417232121458176568;16} else if (e >= 0x3ff + 1) {17/* |x| >= 2 */18x = log(2*x + 1/(sqrt(x*x+1)+x));19} else if (e >= 0x3ff - 26) {20/* |x| >= 0x1p-26, up to 1.6ulp error in [0.125,0.5] */21x = log1p(x + x*x/(sqrt(x*x+1)+1));22} else {23/* |x| < 0x1p-26, raise inexact if x != 0 */24FORCE_EVAL(x + 0x1p120f);25}26return s ? -x : x;27}282930