2 /* @(#)z_asine.c 1.0 98/08/13 */
3 /******************************************************************
4 * The following routines are coded directly from the algorithms
5 * and coefficients given in "Software Manual for the Elementary
6 * Functions" by William J. Cody, Jr. and William Waite, Prentice
8 ******************************************************************/
12 <<asin>>, <<asinf>>, <<acos>>, <<acosf>>, <<asine>>, <<asinef>>---arc sine or cosine
29 double asine(double <[x]>);
30 float asinef(float <[x]>);
31 double asin(double <[x]>);
32 float asinf(float <[x]>);
33 double acos(double <[x]>);
34 float acosf(float <[x]>);
38 <<asin>> computes the inverse sine or cosine of the argument <[x]>.
39 Arguments to <<asin>> and <<acos>> must be in the range @minus{}1 to 1.
41 <<asinf>> and <<acosf>> are identical to <<asin>> and <<acos>>, other
42 than taking and returning floats.
46 <<asin>> and <<acos>> return values in radians, in the range of -pi/2 to pi/2.
49 <<asin>> and <<acos>> return values in radians, in the range of $-\pi/2$ to $\pi/2$.
52 If <[x]> is not in the range @minus{}1 to 1, <<asin>> and <<asinf>>
53 return NaN (not a number), set the global variable <<errno>> to
54 <<EDOM>>, and issue a <<DOMAIN error>> message.
58 /******************************************************************
62 * x - floating point value
63 * acosine - indicates acos calculation
69 * This routine calculates arcsine / arccosine.
71 *****************************************************************/
76 #ifndef _DOUBLE_IS_32BITS
78 static const double p
[] = { -0.27368494524164255994e+2,
79 0.57208227877891731407e+2,
80 -0.39688862997404877339e+2,
81 0.10152522233806463645e+2,
82 -0.69674573447350646411 };
83 static const double q
[] = { -0.16421096714498560795e+3,
84 0.41714430248260412556e+3,
85 -0.38186303361750149284e+3,
86 0.15095270841030604719e+3,
87 -0.23823859153670238830e+2 };
88 static const double a
[] = { 0.0, 0.78539816339744830962 };
89 static const double b
[] = { 1.57079632679489661923, 0.78539816339744830962 };
97 double g
, res
, R
, P
, Q
, y
;
99 /* Check for special values. */
101 if (i
== NAN
|| i
== INF
)
107 return (z_infinity
.d
);
117 /* Check for range error. */
121 return (z_notanum
.d
);
137 if (y
>= z_rooteps
|| branch
== 1)
139 /* Calculate the Taylor series. */
140 P
= ((((p
[4] * g
+ p
[3]) * g
+ p
[2]) * g
+ p
[1]) * g
+ p
[0]) * g
;
141 Q
= ((((g
+ q
[4]) * g
+ q
[3]) * g
+ q
[2]) * g
+ q
[1]) * g
+ q
[0];
147 /* Calculate asine or acose. */
150 res
= (a
[i
] + res
) + a
[i
];
157 res
= (b
[i
] + res
) + b
[i
];
159 res
= (a
[i
] - res
) + a
[i
];
165 #endif /* _DOUBLE_IS_32BITS */