2 /* @(#)e_acosh.c 5.1 93/09/24 */
6 <<acosh>>, <<acoshf>>---inverse hyperbolic cosine
15 double acosh(double <[x]>);
16 float acoshf(float <[x]>);
19 <<acosh>> calculates the inverse hyperbolic cosine of <[x]>.
20 <<acosh>> is defined as
22 . log(<[x]> + sqrt(<[x]>*<[x]>-1))
25 $$ln\Bigl(x + \sqrt{x^2-1}\Bigr)$$
28 <[x]> must be a number greater than or equal to 1.
30 <<acoshf>> is identical, other than taking and returning floats.
33 <<acosh>> and <<acoshf>> return the calculated value. If <[x]>
34 less than 1, the return value is NaN and <<errno>> is set to <<EDOM>>.
37 Neither <<acosh>> nor <<acoshf>> are ANSI C. They are not recommended
38 for portable programs.
47 acosh, NAN, arg,DOMAIN,EDOM
48 acosh, < 1.0, NAN,DOMAIN,EDOM
49 acosh, >=1.0, acosh(arg),,,
52 acoshf, NAN, arg,DOMAIN,EDOM
53 acoshf, < 1.0, NAN,DOMAIN,EDOM
54 acoshf, >=1.0, acosh(arg),,,
59 * ====================================================
60 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
62 * Developed at SunPro, a Sun Microsystems, Inc. business.
63 * Permission to use, copy, modify, and distribute this
64 * software is freely granted, provided that this notice
66 * ====================================================
73 * acosh(x) = log [ x + sqrt(x*x-1) ]
75 * acosh(x) := log(x)+ln2, if x is large; else
76 * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
77 * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
80 * acosh(x) is NaN with signal if x<1.
81 * acosh(NaN) is NaN without signal.
86 #ifndef _DOUBLE_IS_32BITS
94 ln2
= 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
97 double acosh(double x
)
106 EXTRACT_WORDS(hx
,lx
,x
);
107 if(hx
<0x3ff00000) { /* x < 1 */
109 } else if(hx
>=0x41b00000) { /* x > 2**28 */
110 if(hx
>=0x7ff00000) { /* x is inf of NaN */
113 return log(x
)+ln2
; /* acosh(huge)=log(2x) */
114 } else if(((hx
-0x3ff00000)|lx
)==0) {
115 return 0.0; /* acosh(1) = 0 */
116 } else if (hx
> 0x40000000) { /* 2**28 > x > 2 */
118 return log(2.0*x
-one
/(x
+sqrt(t
-one
)));
121 return log1p(t
+sqrt(2.0*t
+t
*t
));
125 #endif /* defined(_DOUBLE_IS_32BITS) */