1 /* ef_acosh.c -- float version of e_acosh.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
4
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 *
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
14 *
15 */
16
17 #include "fdlibm.h"
18
19 static const float one = 1.0, ln2 = 6.9314718246e-01; /* 0x3f317218 */
20
21 float
acoshf(float x)22 acoshf(float x)
23 {
24 float t;
25 __int32_t hx;
26 GET_FLOAT_WORD(hx, x);
27 if (hx < 0x3f800000) { /* x < 1 */
28 return __math_invalidf(x);
29 } else if (hx >= 0x4d800000) { /* x > 2**28 */
30 if (!FLT_UWORD_IS_FINITE(hx)) { /* x is inf of NaN */
31 return x + x;
32 } else
33 return logf(x) + ln2; /* acosh(huge)=log(2x) */
34 } else if (hx == 0x3f800000) {
35 return 0.0; /* acosh(1) = 0 */
36 } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
37 t = x * x;
38 return logf((float)2.0 * x - one / (x + sqrtf(t - one)));
39 } else { /* 1<x<2 */
40 t = x - one;
41 return log1pf(t + sqrtf((float)2.0 * t + t * t));
42 }
43 }
44
45 _MATH_ALIAS_f_f(acosh)
46