1 /* acoshq.c -- __float128 version of e_acosh.c.
2 * Conversion to long double by Jakub Jelinek, jj@ultra.linux.cz.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
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
13 * ====================================================
19 * acoshl(x) = logl [ x + sqrtl(x*x-1) ]
21 * acoshl(x) := logl(x)+ln2, if x is large; else
22 * acoshl(x) := logl(2x-1/(sqrtl(x*x-1)+x)) if x>2; else
23 * acoshl(x) := log1pl(t+sqrtl(2.0*t+t*t)); where t=x-1.
26 * acoshl(x) is NaN with signal if x<1.
27 * acoshl(NaN) is NaN without signal.
30 #include "quadmath-imp.h"
32 static const __float128
34 ln2
= 0.6931471805599453094172321214581766Q
;
42 GET_FLT128_WORDS64(hx
,lx
,x
);
43 if(hx
<0x3fff000000000000LL
) { /* x < 1 */
45 } else if(hx
>=0x4035000000000000LL
) { /* x > 2**54 */
46 if(hx
>=0x7fff000000000000LL
) { /* x is inf of NaN */
49 return logq(x
)+ln2
; /* acoshl(huge)=logl(2x) */
50 } else if(((hx
-0x3fff000000000000LL
)|lx
)==0) {
51 return 0.0Q
; /* acosh(1) = 0 */
52 } else if (hx
> 0x4000000000000000LL
) { /* 2**28 > x > 2 */
54 return logq(2.0Q
*x
-one
/(x
+sqrtq(t
-one
)));
57 return log1pq(t
+sqrtq(2.0Q
*t
+t
*t
));