2 /* @(#)z_tanf.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
19 * This routine calculates the tangent of x.
21 *****************************************************************/
26 static const float TWO_OVER_PI
= 0.6366197723;
27 static const float p
[] = { -0.958017723e-1 };
28 static const float q
[] = { -0.429135777,
34 float y
, f
, g
, XN
, xnum
, xden
, res
;
37 /* Check for special values. */
45 return (z_notanum_f
.f
);
50 /* Check for values that are out of our range. */
58 N
= (int) (x
* TWO_OVER_PI
- 0.5);
60 N
= (int) (x
* TWO_OVER_PI
+ 0.5);
64 f
= x
- N
* __PI_OVER_TWO
;
66 /* Check for values that are too small. */
67 if (-z_rooteps_f
< f
&& f
< z_rooteps_f
)
73 /* Calculate the polynomial. */
78 xnum
= f
* (p
[0] * g
) + f
;
79 xden
= (q
[1] * g
+ q
[0]) * g
+ 1.0;
82 /* Check for odd or even values. */
96 #ifdef _DOUBLE_IS_32BITS
100 return (double) tanf ((float) x
);
103 #endif /* _DOUBLE_IS_32BITS */