123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #if defined(LIBM_SCCS) && !defined(lint)
- static char rcsid[] = "$NetBSD: k_cos.c,v 1.8 1995/05/10 20:46:22 jtc Exp $";
- #endif
- #include "math.h"
- #include "math_private.h"
- #ifdef __STDC__
- static const double
- #else
- static double
- #endif
- one = 1.00000000000000000000e+00,
- C1 = 4.16666666666666019037e-02,
- C2 = -1.38888888888741095749e-03,
- C3 = 2.48015872894767294178e-05,
- C4 = -2.75573143513906633035e-07,
- C5 = 2.08757232129817482790e-09,
- C6 = -1.13596475577881948265e-11;
- #ifdef __STDC__
- double __kernel_cos(double x, double y)
- #else
- double __kernel_cos(x, y)
- double x,y;
- #endif
- {
- double a,hz,z,r,qx;
- int32_t ix;
- GET_HIGH_WORD(ix,x);
- ix &= 0x7fffffff;
- if(ix<0x3e400000) {
- if(((int)x)==0) return one;
- }
- z = x*x;
- r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
- if(ix < 0x3FD33333)
- return one - (0.5*z - (z*r - x*y));
- else {
- if(ix > 0x3fe90000) {
- qx = 0.28125;
- } else {
- INSERT_WORDS(qx,ix-0x00200000,0);
- }
- hz = 0.5*z-qx;
- a = one-qx;
- return a - (hz - (z*r-x*y));
- }
- }
|