summaryrefslogtreecommitdiff log msg author committer range
path: root/missing/acosh.c
 ```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 ``` ``````/********************************************************************** acosh.c - \$Author\$ \$Date\$ created at: Fri Apr 12 00:34:17 JST 2002 public domain rewrite of acosh(3), asinh(3) and atanh(3) **********************************************************************/ #include #include #include /* DBL_MANT_DIG must be less than 4 times of bits of int */ #ifndef DBL_MANT_DIG #define DBL_MANT_DIG 53 /* in this case, at least 12 digit precision */ #endif #define BIG_CRITERIA_BIT (1< 0 #define BIG_CRITERIA (1.0*BIG_CRITERIA_BIT) #else #define BIG_CRITERIA (1.0*(1< 0 #define SMALL_CRITERIA (1.0/SMALL_CRITERIA_BIT) #else #define SMALL_CRITERIA (1.0*(1< BIG_CRITERIA) x += x; else x += sqrt((x + 1) * (x - 1)); return log(x); } #endif #ifndef HAVE_ASINH double asinh(x) double x; { int neg = x < 0; double z = fabs(x); if (z < SMALL_CRITERIA) return x; if (z < (1.0/(1< BIG_CRITERIA) { z = log(z + z); } else { z = log(z + sqrt(z * z + 1)); } if (neg) z = -z; return z; } #endif #ifndef HAVE_ATANH double atanh(x) double x; { int neg = x < 0; double z = fabs(x); if (z < SMALL_CRITERIA) return x; z = log(z > 1 ? -1 : (1 + z) / (1 - z)) / 2; if (neg) z = -z; return z; } #endif ``````