double sin(x) double x;
{ double y, z, zz; int j, sign;
#ifdef MINUSZERO if (x == 0.0) return (x); #endif #ifdef NANS if (isnan(x)) return (x); if (!isfinite(x)) {
mtherr("sin", DOMAIN); return (NAN);
} #endif /* make argument positive but save the sign */
sign = 1; if (x < 0) {
x = -x;
sign = -1;
}
if (x > lossth) {
mtherr("sin", TLOSS); return (0.0);
}
y = floor(x / PIO4); /* integer part of x/PIO4 */
/* strip high bits of integer part to prevent integer overflow */
z = ldexp(y, -4);
z = floor(z); /* integer part of y/8 */
z = y - ldexp(z, 4); /* y - 16 * (y/16) */
j = z; /* convert to integer for tests on the phase angle */ /* map zeros to origin */ if (j & 1) {
j += 1;
y += 1.0;
}
j = j & 07; /* octant modulo 360 degrees */ /* reflect in x axis */ if (j > 3) {
sign = -sign;
j -= 4;
}
/* Extended precision modular arithmetic */
z = ((x - y * DP1) - y * DP2) - y * DP3;
zz = z * z;
if ((j == 1) || (j == 2)) {
y = 1.0 - ldexp(zz, -1) + zz * zz * polevl(zz, coscof, 5);
} else { /* y = z + z * (zz * polevl( zz, sincof, 5 ));*/
y = z + z * z * z * polevl(zz, sincof, 5);
}
if (sign < 0)
y = -y;
return (y);
}
double cos(x) double x;
{ double y, z, zz; long i; int j, sign;
#ifdef NANS if (isnan(x)) return (x); if (!isfinite(x)) {
mtherr("cos", DOMAIN); return (NAN);
} #endif
/* make argument positive */
sign = 1; if (x < 0)
x = -x;
if (x > lossth) {
mtherr("cos", TLOSS); return (0.0);
}
y = floor(x / PIO4);
z = ldexp(y, -4);
z = floor(z); /* integer part of y/8 */
z = y - ldexp(z, 4); /* y - 16 * (y/16) */
/* integer and fractional part modulo one octant */
i = z; if (i & 1) /* map zeros to origin */
{
i += 1;
y += 1.0;
}
j = i & 07; if (j > 3) {
j -= 4;
sign = -sign;
}
if (j > 1)
sign = -sign;
/* Extended precision modular arithmetic */
z = ((x - y * DP1) - y * DP2) - y * DP3;
zz = z * z;
if ((j == 1) || (j == 2)) { /* y = z + z * (zz * polevl( zz, sincof, 5 ));*/
y = z + z * z * z * polevl(zz, sincof, 5);
} else {
y = 1.0 - ldexp(zz, -1) + zz * zz * polevl(zz, coscof, 5);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.