changed from Hart & Cheney to Cody & Waite

This commit is contained in:
eck
1989-12-18 15:44:36 +00:00
parent 6e2b44962f
commit d43142d811
19 changed files with 483 additions and 374 deletions

View File

@@ -6,31 +6,61 @@
*/
/* $Header$ */
#include <errno.h>
#include <math.h>
#include <errno.h>
#include "localmath.h"
static double
asin_acos(double x, int cosfl)
{
int negative = x < 0;
int i;
double g;
static double p[] = {
-0.27368494524164255994e+2,
0.57208227877891731407e+2,
-0.39688862997540877339e+2,
0.10152522233806463645e+2,
-0.69674573447350646411e+0
};
static double q[] = {
-0.16421096714498560795e+3,
0.41714430248260412556e+3,
-0.38186303361750149284e+3,
0.15095270841030604719e+3,
-0.23823859153670238830e+2,
1.0
};
if (negative) {
x = -x;
}
if (x > 1) {
errno = EDOM;
return 0;
if (x > 0.5) {
i = 1;
if (x > 1) {
errno = EDOM;
return 0;
}
g = 0.5 - 0.5 * x;
x = - sqrt(g);
x += x;
}
if (x == 1) {
x = M_PI_2;
else {
/* ??? avoid underflow ??? */
i = 0;
g = x * x;
}
else x = atan(x/sqrt(1-x*x));
if (negative) x = -x;
x += x * g * POLYNOM4(g, p) / POLYNOM5(g, q);
if (cosfl) {
return M_PI_2 - x;
if (! negative) x = -x;
}
if ((cosfl == 0) == (i == 1)) {
x = (x + M_PI_4) + M_PI_4;
}
else if (cosfl && negative && i == 1) {
x = (x + M_PI_2) + M_PI_2;
}
if (! cosfl && negative) x = -x;
return x;
}