|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 961 (0x3c1)
Types: TextFile
Notes: UNIX file
Names: »cos.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »libm/cos.c«
/*
* Evaluate the cosine function.
*/
#include <math.h>
/*
* (Hart 2923, 19.96)
*/
static double sintab[] ={
0.523598775598298873071308e+00,
-0.239245962039350458667960e-01,
0.327953194428661969081000e-03,
-0.214071976918198811800000e-05,
0.815125650404748400000000e-08,
-0.203153509377510000000000e-10,
0.355397103280000000000000e-13
};
/*
* (Hart 3824, 19.45)
*/
static double costab[] ={
0.99999999999999999996415,
-0.30842513753404245242414,
0.01585434424381541089754,
-0.00032599188692668755044,
0.00000359086044588581953,
-0.00000002461136382637005,
0.00000000011500497024263,
-0.00000000000038577620372
};
double
cos(x)
double x;
{
double r;
register int s;
x = modf(x/(2.0*PI), &r);
s = 0;
if (x > 0.5) {
s = 1;
x -= 0.5;
}
if (x > 0.25) {
s ^= 1;
x = 0.5 - x;
}
if (x > 0.125) {
x = 3.0 - 12.0*x;
r = x*_pol(x*x, sintab, 7);
} else {
x *= 8.0;
r = _pol(x*x, costab, 8);
}
return (s?-r:r);
}