94 * |tan(x) - (x+t1*x^3+...+t6*x^13)| 95 * |------------------------------ | <= 2^-59.73 for |x|<0.15625 96 * | x | 97 */ 98 t1 = 3.333333333333333333333333333333423342490e-0001L, 99 t2 = 1.333333333333333333333333333093838744537e-0001L, 100 t3 = 5.396825396825396825396827906318682662250e-0002L, 101 t4 = 2.186948853615520282185576976994418486911e-0002L, 102 t5 = 8.863235529902196573354554519991152936246e-0003L, 103 t6 = 3.592128036572480064652191427543994878790e-0003L, 104 t7 = 1.455834387051455257856833807581901305474e-0003L, 105 t8 = 5.900274409318599857829983256201725587477e-0004L, 106 t9 = 2.391291152117265181501116961901122362937e-0004L, 107 t10 = 9.691533169382729742394024173194981882375e-0005L, 108 t11 = 3.927994733186415603228178184225780859951e-0005L, 109 t12 = 1.588300018848323824227640064883334101288e-0005L, 110 t13 = 6.916271223396808311166202285131722231723e-0006L; 111 /* INDENT ON */ 112 long double 113 __k_tanl(long double x, long double y, int k) { 114 long double a, t, z, w, s, c; 115 int *pt = (int *) &t, *px = (int *) &x; 116 int i, j, hx, ix; 117 118 t = 1.0; 119 #if defined(_BIG_ENDIAN) 120 hx = px[0]; 121 #else 122 XTOI(px, hx); 123 #endif 124 ix = hx & 0x7fffffff; 125 if (ix < 0x3ffc4000) { 126 if (ix < 0x3fc60000) { 127 if ((i = (int) x) == 0) /* generate inexact */ 128 w = x; 129 } else { 130 z = x * x; 131 if (ix < 0x3ff30000) /* 2**-12 */ 132 t = z * (t1 + z * (t2 + z * (t3 + z * t4))); 133 else 134 t = z * (t1 + z * (t2 + z * (t3 + z * (t4 + 135 z * (t5 + z * (t6 + z * (t7 + z * 136 (t8 + z * (t9 + z * (t10 + z * (t11 + 137 z * (t12 + z * t13)))))))))))); 138 t = y + x * t; 139 w = x + t; 140 } 141 return (k == 0 ? w : -one / w); 142 } 143 j = (ix + 0x400) & 0x7ffff800; 144 i = (j - 0x3ffc4000) >> 11; 145 #if defined(_BIG_ENDIAN) 146 pt[0] = j; 147 #else 148 ITOX(j, pt); 149 #endif 150 if (hx > 0) 151 x = y - (t - x); 152 else 153 x = (-y) - (t + x); 154 a = _TBL_tanl_hi[i]; 155 z = x * x; 156 /* cos(x)-1 */ 157 t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); 158 /* sin(x) */ 159 s = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * 160 pp5))))); 161 if (k == 0) { 162 w = a * s; 163 t = _TBL_tanl_lo[i] + (s + a * w) / (one - (w - t)); 164 return (hx < 0 ? -a - t : a + t); 165 } else { 166 w = s + a * t; 167 c = w + _TBL_tanl_lo[i]; 168 z = (one - (a * s - t)); | 94 * |tan(x) - (x+t1*x^3+...+t6*x^13)| 95 * |------------------------------ | <= 2^-59.73 for |x|<0.15625 96 * | x | 97 */ 98 t1 = 3.333333333333333333333333333333423342490e-0001L, 99 t2 = 1.333333333333333333333333333093838744537e-0001L, 100 t3 = 5.396825396825396825396827906318682662250e-0002L, 101 t4 = 2.186948853615520282185576976994418486911e-0002L, 102 t5 = 8.863235529902196573354554519991152936246e-0003L, 103 t6 = 3.592128036572480064652191427543994878790e-0003L, 104 t7 = 1.455834387051455257856833807581901305474e-0003L, 105 t8 = 5.900274409318599857829983256201725587477e-0004L, 106 t9 = 2.391291152117265181501116961901122362937e-0004L, 107 t10 = 9.691533169382729742394024173194981882375e-0005L, 108 t11 = 3.927994733186415603228178184225780859951e-0005L, 109 t12 = 1.588300018848323824227640064883334101288e-0005L, 110 t13 = 6.916271223396808311166202285131722231723e-0006L; 111 /* INDENT ON */ 112 long double 113 __k_tanl(long double x, long double y, int k) { 114 long double a, t, z, w = 0.0, s, c; 115 int *pt = (int *) &t, *px = (int *) &x; 116 int i, j, hx, ix; 117 118 t = 1.0; 119 #if defined(__i386) || defined(__amd64) 120 XTOI(px, hx); 121 #else 122 hx = px[0]; 123 #endif 124 ix = hx & 0x7fffffff; 125 if (ix < 0x3ffc4000) { 126 if (ix < 0x3fc60000) { 127 if ((i = (int) x) == 0) /* generate inexact */ 128 w = x; 129 } else { 130 z = x * x; 131 if (ix < 0x3ff30000) /* 2**-12 */ 132 t = z * (t1 + z * (t2 + z * (t3 + z * t4))); 133 else 134 t = z * (t1 + z * (t2 + z * (t3 + z * (t4 + 135 z * (t5 + z * (t6 + z * (t7 + z * 136 (t8 + z * (t9 + z * (t10 + z * (t11 + 137 z * (t12 + z * t13)))))))))))); 138 t = y + x * t; 139 w = x + t; 140 } 141 return (k == 0 ? w : -one / w); 142 } 143 j = (ix + 0x400) & 0x7ffff800; 144 i = (j - 0x3ffc4000) >> 11; 145 #if defined(__i386) || defined(__amd64) 146 ITOX(j, pt); 147 #else 148 pt[0] = j; 149 #endif 150 if (hx > 0) 151 x = y - (t - x); 152 else 153 x = (-y) - (t + x); 154 a = _TBL_tanl_hi[i]; 155 z = x * x; 156 /* cos(x)-1 */ 157 t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); 158 /* sin(x) */ 159 s = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * 160 pp5))))); 161 if (k == 0) { 162 w = a * s; 163 t = _TBL_tanl_lo[i] + (s + a * w) / (one - (w - t)); 164 return (hx < 0 ? -a - t : a + t); 165 } else { 166 w = s + a * t; 167 c = w + _TBL_tanl_lo[i]; 168 z = (one - (a * s - t)); |