|
|
1.1 root 1: /*
2: * libm/sinh.c
3: * Hyperbolic sine.
4: */
5:
6: #include <math.h>
7:
8: #if EMU87
9: #include "emumath.h"
10: #endif
11:
12: /*
13: * To get a correct result for very small |x|,
14: * the code below just returns x for |x| < THRESHOLD.
15: * We can derive a theoretical value for THRESHOLD from the series:
16: * sinh(x) = x + x^3/3! + x^5/5! + ...
17: * so if |x| < sqrt(6 * DBL_EPSILON) then x^3/3! < x * DBL_EPSILON
18: * and the low-order terms must be insignificant.
19: * The threshold value below, arrived at empirically, is somewhat larger;
20: * it is for IEEE fp, the DECVAX value must be slightly different but...
21: */
22: #define THRESHOLD 8.899087910006383e-6
23:
24: double
25: sinh(x) double x;
26: {
27: double r;
28: register int e;
29:
30: if (fabs(x) < THRESHOLD)
31: return x;
32: /*
33: * Hart (6.2.27) gives an alternative formula for |x| < 1,
34: * unused here; should it be used?
35: */
36: e = errno;
37: r = exp(x);
38: errno = e;
39: r = (r-1.0/r) / 2.0;
40: return r;
41: }
42:
43: /* end of sinh.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.