2 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
12 #include "localmath.h"
15 sinus(double x
, int cos_flag
)
17 /* Algorithm and coefficients from:
18 "Software manual for the elementary functions"
19 by W.J. Cody and W. Waite, Prentice-Hall, 1980
23 -0.16666666666666665052e+0,
24 0.83333333333331650314e-2,
25 -0.19841269841201840457e-3,
26 0.27557319210152756119e-5,
27 -0.25052106798274584544e-7,
28 0.16058936490371589114e-9,
29 -0.76429178068910467734e-12,
30 0.27204790957888846175e-14
50 /* ??? avoid loss of significance, if y is too large, error ??? */
54 if (y
>= DBL_MAX
/M_PI
) return 0.0;
56 /* Use extended precision to calculate reduced argument.
57 Here we used 12 bits of the mantissa for a1.
58 Also split x in integer part x1 and fraction part x2.
60 #define A1 3.1416015625
61 #define A2 -8.908910206761537356617e-6
66 if (modf(0.5*y
, &x1
)) neg
= -neg
;
67 if (cos_flag
) y
-= 0.5;
81 /* ??? avoid underflow ??? */
84 x
+= x
* y
* POLYNOM7(y
, r
);
85 return neg
==-1 ? -x
: x
;