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"
17 /* Algorithm and coefficients from:
18 "Software manual for the elementary functions"
19 by W.J. Cody and W. Waite, Prentice-Hall, 1980
27 -0.13338350006421960681e+0,
28 0.34248878235890589960e-2,
29 -0.17861707342254426711e-4
33 -0.46671683339755294240e+0,
34 0.25663832289440112864e-1,
35 -0.31181531907010027307e-3,
36 0.49819433993786512270e-6
45 /* ??? avoid loss of significance, error if x is too large ??? */
49 if (y
>= DBL_MAX
/M_PI_2
) return 0.0;
51 /* Use extended precision to calculate reduced argument.
52 Here we used 12 bits of the mantissa for a1.
53 Also split x in integer part x1 and fraction part x2.
55 #define A1 1.57080078125
56 #define A2 -4.454455103380768678308e-6
61 if (modf(0.5*y
, &x1
)) invert
= 1;
70 /* ??? avoid underflow ??? */
72 x
+= x
* y
* POLYNOM2(y
, p
+1);
75 return invert
? -y
/x
: x
/y
;