Print this page




  89 q6      =   2.087675698767424261441959760729854017855e-0009L,
  90 q7      =  -1.147074481239662089072452129010790774761e-0011L,
  91 q8      =   4.777761647399651599730663422263531034782e-0014L,
  92 /*
  93  *
  94  * |cos(x) - (1+qq1*x^2+...+ qq5*x^10)| <= 2^-123.84 for |x|<=1/128
  95  */
  96 qq1     =  -4.999999999999999999999999999999378373641e-0001L,
  97 qq2     =   4.166666666666666666666665478399327703130e-0002L,
  98 qq3     =  -1.388888888888888888058211230618051613494e-0003L,
  99 qq4     =   2.480158730156105377771585658905303111866e-0005L,
 100 qq5     =  -2.755728099762526325736488376695157008736e-0007L;
 101 /* INDENT ON */
 102 long double
 103 __k_cosl(long double x, long double y) {
 104         long double a, t, z, w;
 105         int *pt = (int *) &t, *px = (int *) &x;
 106         int i, j, hx, ix;
 107 
 108         t = 1.0;
 109 #if defined(_BIG_ENDIAN)
 110         hx = px[0];
 111 #else
 112         XTOI(px, hx);


 113 #endif
 114         ix = hx & 0x7fffffff;
 115         if (ix < 0x3ffc4000) {
 116                 if (ix < 0x3fc60000)
 117                         if ((i = (int) x) == 0)
 118                                 return (one);   /* generate inexact */
 119                 z = x * x;
 120 
 121                 if (ix < 0x3ff80000) /* 0.0078125 */
 122                         return (one + z * (qq1 + z * (qq2 + z * (qq3 + z *
 123                                 (qq4 + z * qq5)))));
 124                 else
 125                         return (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 +
 126                                 z * (q5 + z * (q6 + z * (q7 + z * q8))))))));
 127         }
 128         j = (ix + 0x400) & 0x7ffff800;
 129         i = (j - 0x3ffc4000) >> 11;
 130 #if defined(_BIG_ENDIAN)
 131         pt[0] = j;
 132 #else
 133         ITOX(j, pt);


 134 #endif
 135         if (hx > 0)
 136                 x = y - (t - x);
 137         else
 138                 x = (-y) - (t + x);
 139         a = _TBL_cosl_hi[i];
 140         z = x * x;
 141         t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5))));
 142         w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z *
 143                 pp5)))));
 144         t = _TBL_cosl_lo[i] - (_TBL_sinl_hi[i] * w - a * t);
 145         return (a + t);
 146 }


  89 q6      =   2.087675698767424261441959760729854017855e-0009L,
  90 q7      =  -1.147074481239662089072452129010790774761e-0011L,
  91 q8      =   4.777761647399651599730663422263531034782e-0014L,
  92 /*
  93  *
  94  * |cos(x) - (1+qq1*x^2+...+ qq5*x^10)| <= 2^-123.84 for |x|<=1/128
  95  */
  96 qq1     =  -4.999999999999999999999999999999378373641e-0001L,
  97 qq2     =   4.166666666666666666666665478399327703130e-0002L,
  98 qq3     =  -1.388888888888888888058211230618051613494e-0003L,
  99 qq4     =   2.480158730156105377771585658905303111866e-0005L,
 100 qq5     =  -2.755728099762526325736488376695157008736e-0007L;
 101 /* INDENT ON */
 102 long double
 103 __k_cosl(long double x, long double y) {
 104         long double a, t, z, w;
 105         int *pt = (int *) &t, *px = (int *) &x;
 106         int i, j, hx, ix;
 107 
 108         t = 1.0;
 109 #if defined(__i386) || defined(__amd64)


 110         XTOI(px, hx);
 111 #else
 112         hx = px[0];
 113 #endif
 114         ix = hx & 0x7fffffff;
 115         if (ix < 0x3ffc4000) {
 116                 if (ix < 0x3fc60000)
 117                         if ((i = (int) x) == 0)
 118                                 return (one);   /* generate inexact */
 119                 z = x * x;
 120 
 121                 if (ix < 0x3ff80000) /* 0.0078125 */
 122                         return (one + z * (qq1 + z * (qq2 + z * (qq3 + z *
 123                                 (qq4 + z * qq5)))));
 124                 else
 125                         return (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 +
 126                                 z * (q5 + z * (q6 + z * (q7 + z * q8))))))));
 127         }
 128         j = (ix + 0x400) & 0x7ffff800;
 129         i = (j - 0x3ffc4000) >> 11;
 130 #if defined(__i386) || defined(__amd64)


 131         ITOX(j, pt);
 132 #else
 133         pt[0] = j;
 134 #endif
 135         if (hx > 0)
 136                 x = y - (t - x);
 137         else
 138                 x = (-y) - (t + x);
 139         a = _TBL_cosl_hi[i];
 140         z = x * x;
 141         t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5))));
 142         w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z *
 143                 pp5)))));
 144         t = _TBL_cosl_lo[i] - (_TBL_sinl_hi[i] * w - a * t);
 145         return (a + t);
 146 }