17 * Returns hyperbolic tangent of argument in the range MINLOG to
20 * A rational function is used for |x| < 0.625. The form
21 * x + x**3 P(x)/Q(x) of Cody _& Waite is employed.
23 * tanh(x) = sinh(x)/cosh(x) = 1 - 2/(exp(2x) + 1).
30 * arithmetic domain # trials peak rms
31 * DEC -2,2 50000 3.3e-17 6.4e-18
32 * IEEE -2,2 30000 2.5e-16 5.8e-17
37 Cephes Math Library Release 2.8: June, 2000
38 Copyright 1984, 1995, 2000 by Stephen L. Moshier
45 -9.64399179425052238628E-1,
46 -9.92877231001918586564E1,
47 -1.61468768441708447952E3
50 /* 1.00000000000000000000E0,*/
51 1.12811678491632931402E2,
52 2.23548839060100448583E3,
53 4.84406305325125486048E3
57 static unsigned short P[] = {
58 0140166,0161335,0053753,0075126,
59 0141706,0111520,0070463,0040552,
60 0142711,0153001,0101300,0025430
62 static unsigned short Q[] = {
63 /*0040200,0000000,0000000,0000000,*/
64 0041741,0117624,0051300,0156060,
65 0043013,0133720,0071251,0127717,
66 0043227,0060201,0021020,0020136
71 static unsigned short P[] = {
72 0x6f4b,0xaafd,0xdc5b,0xbfee,
73 0x682d,0x0e26,0xd26a,0xc058,
74 0x0563,0x3058,0x3ac0,0xc099
76 static unsigned short Q[] = {
77 /*0x0000,0x0000,0x0000,0x3ff0,*/
78 0x1b86,0x8a58,0x33f2,0x405c,
79 0x35fa,0x0e55,0x76fa,0x40a1,
80 0x040c,0x2442,0xec10,0x40b2
85 static unsigned short P[] = {
86 0xbfee,0xdc5b,0xaafd,0x6f4b,
87 0xc058,0xd26a,0x0e26,0x682d,
88 0xc099,0x3ac0,0x3058,0x0563
90 static unsigned short Q[] = {
91 0x405c,0x33f2,0x8a58,0x1b86,
92 0x40a1,0x76fa,0x0e55,0x35fa,
93 0x40b2,0xec10,0x2442,0x040c
98 extern double fabs ( double );
99 extern double exp ( double );
100 extern double polevl ( double, void *, int );
101 extern double p1evl ( double, void *, int );
103 double fabs(), exp(), polevl(), p1evl();
105 extern double MAXLOG;
117 if( z > 0.5 * MAXLOG )
127 z = 1.0 - 2.0/(s + 1.0);
136 z = polevl( s, P, 2 )/p1evl(s, Q, 3);