|
|
1.1 root 1: /*
2: * Hyperbolic tangent.
3: */
4: #include <math.h>
5:
6: #if EMU87
7: #include "emumath.h"
8: #endif
9:
10: double
11: tanh(x)
12: double x;
13: {
14: double r;
15: register int s;
16:
17: s = 0;
18: if (x < 0.0) {
19: x = -x;
20: s = 1;
21: }
22: r = exp(-2.0*x);
23: r = (1.0-r) / (1.0+r);
24: return (s?-r:r);
25: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.