1 /**********************************************************************
6 created at: Fri Apr 12 00:34:17 JST 2002
8 public domain rewrite of acosh(3), asinh(3) and atanh(3)
10 **********************************************************************/
17 /* DBL_MANT_DIG must be less than 4 times of bits of int */
19 #define DBL_MANT_DIG 53 /* in this case, at least 12 digit precision */
21 #define BIG_CRITERIA_BIT (1<<DBL_MANT_DIG/2)
22 #if BIG_CRITERIA_BIT > 0
23 #define BIG_CRITERIA (1.0*BIG_CRITERIA_BIT)
25 #define BIG_CRITERIA (1.0*(1<<DBL_MANT_DIG/4)*(1<<(DBL_MANT_DIG/2+1-DBL_MANT_DIG/4)))
27 #define SMALL_CRITERIA_BIT (1<<(DBL_MANT_DIG/3))
28 #if SMALL_CRITERIA_BIT > 0
29 #define SMALL_CRITERIA (1.0/SMALL_CRITERIA_BIT)
31 #define SMALL_CRITERIA (1.0*(1<<DBL_MANT_DIG/4)*(1<<(DBL_MANT_DIG/3+1-DBL_MANT_DIG/4)))
42 else if (x
> BIG_CRITERIA
)
45 x
+= sqrt((x
+ 1) * (x
- 1));
57 if (z
< SMALL_CRITERIA
) return x
;
58 if (z
< (1.0/(1<<DBL_MANT_DIG
/5))) {
60 z
*= 1 + x2
* (-1.0/6.0 + x2
* 3.0/40.0);
62 else if (z
> BIG_CRITERIA
) {
66 z
= log(z
+ sqrt(z
* z
+ 1));
80 if (z
< SMALL_CRITERIA
) return x
;
81 z
= log(z
> 1 ? -1 : (1 + z
) / (1 - z
)) / 2;