2 /* @(#)z_sinef.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 ******************************************************************/
9 /******************************************************************
13 * x - floating point value
14 * cosine - indicates cosine value
20 * This routine calculates sines and cosines.
22 *****************************************************************/
27 static const float HALF_PI
= 1.570796326;
28 static const float ONE_OVER_PI
= 0.318309886;
29 static const float r
[] = { -0.1666665668,
39 float y
, XN
, g
, R
, res
;
40 float YMAX
= 210828714.0;
49 return (z_notanum_f
.f
);
52 /* Use sin and cos properties to ease computations. */
56 y
= fabsf (x
) + HALF_PI
;
72 /* Check for values of y that will overflow here. */
79 /* Calculate the exponent. */
81 N
= (int) (y
* ONE_OVER_PI
- 0.5);
83 N
= (int) (y
* ONE_OVER_PI
+ 0.5);
92 y
= fabsf (x
) - XN
* __PI
;
94 if (-z_rooteps_f
< y
&& y
< z_rooteps_f
)
101 /* Calculate the Taylor series. */
102 R
= (((r
[3] * g
+ r
[2]) * g
+ r
[1]) * g
+ r
[0]) * g
;
104 /* Finally, compute the result. */