Bell 32V development
[unix-history] / usr / src / libm / sinh.c
CommitLineData
94759b7b
TL
1/*
2 sinh(arg) returns the hyperbolic sine of its floating-
3 point argument.
4
5 The exponential function is called for arguments
6 greater in magnitude than 0.5.
7
8 A series is used for arguments smaller in magnitude than 0.5.
9 The coefficients are #2029 from Hart & Cheney. (20.36D)
10
11 cosh(arg) is computed from the exponential function for
12 all arguments.
13*/
14
15double exp();
16
17static double p0 = -0.6307673640497716991184787251e+6;
18static double p1 = -0.8991272022039509355398013511e+5;
19static double p2 = -0.2894211355989563807284660366e+4;
20static double p3 = -0.2630563213397497062819489e+2;
21static double q0 = -0.6307673640497716991212077277e+6;
22static double q1 = 0.1521517378790019070696485176e+5;
23static double q2 = -0.173678953558233699533450911e+3;
24
25double
26sinh(arg)
27double arg;
28{
29 double temp, argsq;
30 register sign;
31
32 sign = 1;
33 if(arg < 0) {
34 arg = - arg;
35 sign = -1;
36 }
37
38 if(arg > 21.) {
39 temp = exp(arg)/2;
40 if (sign>0)
41 return(temp);
42 else
43 return(-temp);
44 }
45
46 if(arg > 0.5) {
47 return(sign*(exp(arg) - exp(-arg))/2);
48 }
49
50 argsq = arg*arg;
51 temp = (((p3*argsq+p2)*argsq+p1)*argsq+p0)*arg;
52 temp /= (((argsq+q2)*argsq+q1)*argsq+q0);
53 return(sign*temp);
54}
55
56double
57cosh(arg)
58double arg;
59{
60 if(arg < 0)
61 arg = - arg;
62 if(arg > 21.) {
63 return(exp(arg)/2);
64 }
65
66 return((exp(arg) + exp(-arg))/2);
67}