double __ieee754_y1(double x) { double z, s,c,ss,cc,u,v,u1,u2,v1,v2,v3,z2,z4; int32_t hx,ix,lx; EXTRACT_WORDS(hx,lx,x); ix = 0x7fffffff&hx; /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ if(__builtin_expect(ix>=0x7ff00000, 0)) return one/(x+x*x); if(__builtin_expect((ix|lx)==0, 0)) return -HUGE_VAL+x; /* -inf and overflow exception. */; if(__builtin_expect(hx<0, 0)) return zero/(zero*x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ __sincos (x, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure x+x not overflow */ z = __cos(x+x); if ((s*c)>zero) cc = z/ss; else ss = z/cc; } /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrt(x); else { u = pone(x); v = qone(x); z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrt(x); } return z; } if(__builtin_expect(ix<=0x3c900000, 0)) { /* x < 2**-54 */ return(-tpi/x); } z = x*x; #ifdef DO_NOT_USE_THIS u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); #else u1 = U0[0]+z*U0[1];z2=z*z; u2 = U0[2]+z*U0[3];z4=z2*z2; u = u1 + z2*u2 + z4*U0[4]; v1 = one+z*V0[0]; v2 = V0[1]+z*V0[2]; v3 = V0[3]+z*V0[4]; v = v1 + z2*v2 + z4*v3; #endif return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x)); }
double y1(double x) { double z, s, c, ss, cc, u, v; /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ if (!finite(x)) { if (!_IEEE) return (infnan(EDOM)); else if (x < 0) return(zero/zero); else if (x > 0) return (0); else return(x); } if (x <= 0) { if (_IEEE && x == 0) return -one/zero; else if(x == 0) return(infnan(-ERANGE)); else if(_IEEE) return (zero/zero); else return(infnan(EDOM)); } if (x >= 2) { /* |x| >= 2.0 */ s = sin(x); c = cos(x); ss = -s-c; cc = s-c; if (x < .5 * DBL_MAX) { /* make sure x+x not overflow */ z = cos(x+x); if ((s*c)>zero) cc = z/ss; else ss = z/cc; } /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if (_IEEE && x>two_129) { z = (invsqrtpi*ss)/sqrt(x); } else { u = pone(x); v = qone(x); z = invsqrtpi*(u*ss+v*cc)/sqrt(x); } return z; } if (x <= two_m54) { /* x < 2**-54 */ return (-tpi/x); } z = x*x; u = u0[0]+z*(u0[1]+z*(u0[2]+z*(u0[3]+z*u0[4]))); v = one+z*(v0[0]+z*(v0[1]+z*(v0[2]+z*(v0[3]+z*v0[4])))); return (x*(u/v) + tpi*(j1(x)*log(x)-one/x)); }
double __ieee754_y1(double x) { double z, s,c,ss,cc,u,v; int32_t hx,ix,lx; EXTRACT_WORDS(hx,lx,x); ix = 0x7fffffff&hx; /* * y1(NaN) = NaN. * y1(Inf) = 0. * y1(-Inf) = NaN and raise invalid exception. */ if(ix>=0x7ff00000) return vone/(x+x*x); /* y1(+-0) = -inf and raise divide-by-zero exception. */ if((ix|lx)==0) return -one/vzero; /* y1(x<0) = NaN and raise invalid exception. */ if(hx<0) return vzero/vzero; if(ix >= 0x40000000) { /* |x| >= 2.0 */ s = sin(x); c = cos(x); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure x+x not overflow */ z = cos(x+x); if ((s*c)>zero) cc = z/ss; else ss = z/cc; } /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x); else { u = pone(x); v = qone(x); z = invsqrtpi*(u*ss+v*cc)/sqrt(x); } return z; } if(ix<=0x3c900000) { /* x < 2**-54 */ return(-tpi/x); } z = x*x; u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x)); }
double y1 (double x) { if (x <= 0.0) return (dzero/dzero); /* IEEE machines: invalid operation */ if (x < 8.0) return x * yone(x) + TWO_ON_PI * (j1(x) * log(x) - 1.0/x); else return (sqrt(TWO_ON_PI/x) * (pone(x) * sin (x - THREE_PI_ON_FOUR) + (8.0/x) * qone(x) * cos(x - THREE_PI_ON_FOUR))); }
double __ieee754_j1(double x) { double z, s,c,ss,cc,r,u,v,y,r1,r2,s1,s2,s3,z2,z4; int32_t hx,ix; GET_HIGH_WORD(hx,x); ix = hx&0x7fffffff; if(__builtin_expect(ix>=0x7ff00000, 0)) return one/x; y = fabs(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ __sincos (y, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure y+y not overflow */ z = __cos(y+y); if ((s*c)>zero) cc = z/ss; else ss = z/cc; } /* * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrt(y); else { u = pone(y); v = qone(y); z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrt(y); } if(hx<0) return -z; else return z; } if(__builtin_expect(ix<0x3e400000, 0)) { /* |x|<2**-27 */ if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */ } z = x*x; #ifdef DO_NOT_USE_THIS r = z*(r00+z*(r01+z*(r02+z*r03))); s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); r *= x; #else r1 = z*R[0]; z2=z*z; r2 = R[1]+z*R[2]; z4=z2*z2; r = r1 + z2*r2 + z4*R[3]; r *= x; s1 = one+z*S[1]; s2 = S[2]+z*S[3]; s3 = S[4]+z*S[5]; s = s1 + z2*s2 + z4*s3; #endif return(x*0.5+r/s); }
double j1(double x) { double z, s,c,ss,cc,r,u,v,y; y = fabs(x); if (!finite(x)) { /* Inf or NaN */ if (_IEEE && x != x) return(x); else return (copysign(x, zero)); } y = fabs(x); if (y >= 2) { /* |x| >= 2.0 */ s = sin(y); c = cos(y); ss = -s-c; cc = s-c; if (y < .5*DBL_MAX) { /* make sure y+y not overflow */ z = cos(y+y); if ((s*c)<zero) cc = z/ss; else ss = z/cc; } /* * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ #if !defined(__vax__) && !defined(tahoe) if (y > two_129) /* x > 2^129 */ z = (invsqrtpi*cc)/sqrt(y); else #endif /* defined(__vax__) || defined(tahoe) */ { u = pone(y); v = qone(y); z = invsqrtpi*(u*cc-v*ss)/sqrt(y); } if (x < 0) return -z; else return z; } if (y < 7.450580596923828125e-009) { /* |x|<2**-27 */ if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */ } z = x*x; r = z*(r00+z*(r01+z*(r02+z*r03))); s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); r *= x; return (x*0.5+r/s); }
double j1 (double x) { double v,w; v = x; if (x < 0.0) x = -x; if (x < 8.0) return v * jone(x); else { w = (sqrt(TWO_ON_PI/x) * (pone(x) * cos(x - THREE_PI_ON_FOUR) - 8.0 / x * qone(x) * sin (x - THREE_PI_ON_FOUR))); if (v < 0.0) w = -w; return w; } }
double j1(double x) { double z, s,c,ss,cc,r,u,v,y; int32_t hx,ix; GET_HIGH_WORD(hx,x); ix = hx&0x7fffffff; if(ix>=0x7ff00000) return one/x; y = fabs(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ s = sin(y); c = cos(y); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure y+y not overflow */ z = cos(y+y); if ((s*c)>zero) cc = z/ss; else ss = z/cc; } /* * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(y); else { u = pone(y); v = qone(y); z = invsqrtpi*(u*cc-v*ss)/sqrt(y); } if(hx<0) return -z; else return z; } if(ix<0x3e400000) { /* |x|<2**-27 */ if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */ } z = x*x; r = z*(r00+z*(r01+z*(r02+z*r03))); s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); r *= x; return(x*0.5+r/s); }
double __ieee754_j1 (double x) { double z, s, c, ss, cc, r, u, v, y, r1, r2, s1, s2, s3, z2, z4; int32_t hx, ix; GET_HIGH_WORD (hx, x); ix = hx & 0x7fffffff; if (__glibc_unlikely (ix >= 0x7ff00000)) return one / x; y = fabs (x); if (ix >= 0x40000000) /* |x| >= 2.0 */ { __sincos (y, &s, &c); ss = -s - c; cc = s - c; if (ix < 0x7fe00000) /* make sure y+y not overflow */ { z = __cos (y + y); if ((s * c) > zero) cc = z / ss; else ss = z / cc; } /* * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ if (ix > 0x48000000) z = (invsqrtpi * cc) / sqrt (y); else { u = pone (y); v = qone (y); z = invsqrtpi * (u * cc - v * ss) / sqrt (y); } if (hx < 0) return -z; else return z; } if (__glibc_unlikely (ix < 0x3e400000)) /* |x|<2**-27 */ { if (huge + x > one) /* inexact if x!=0 necessary */ { double ret = math_narrow_eval (0.5 * x); math_check_force_underflow (ret); if (ret == 0 && x != 0) __set_errno (ERANGE); return ret; } } z = x * x; r1 = z * R[0]; z2 = z * z; r2 = R[1] + z * R[2]; z4 = z2 * z2; r = r1 + z2 * r2 + z4 * R[3]; r *= x; s1 = one + z * S[1]; s2 = S[2] + z * S[3]; s3 = S[4] + z * S[5]; s = s1 + z2 * s2 + z4 * s3; return (x * 0.5 + r / s); }
double __ieee754_y1 (double x) { double z, s, c, ss, cc, u, v, u1, u2, v1, v2, v3, z2, z4; int32_t hx, ix, lx; EXTRACT_WORDS (hx, lx, x); ix = 0x7fffffff & hx; /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ if (__glibc_unlikely (ix >= 0x7ff00000)) return one / (x + x * x); if (__glibc_unlikely ((ix | lx) == 0)) return -1 / zero; /* -inf and divide by zero exception. */ /* -inf and overflow exception. */; if (__glibc_unlikely (hx < 0)) return zero / (zero * x); if (ix >= 0x40000000) /* |x| >= 2.0 */ { __sincos (x, &s, &c); ss = -s - c; cc = s - c; if (ix < 0x7fe00000) /* make sure x+x not overflow */ { z = __cos (x + x); if ((s * c) > zero) cc = z / ss; else ss = z / cc; } /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if (ix > 0x48000000) z = (invsqrtpi * ss) / sqrt (x); else { u = pone (x); v = qone (x); z = invsqrtpi * (u * ss + v * cc) / sqrt (x); } return z; } if (__glibc_unlikely (ix <= 0x3c900000)) /* x < 2**-54 */ { z = -tpi / x; if (isinf (z)) __set_errno (ERANGE); return z; } z = x * x; u1 = U0[0] + z * U0[1]; z2 = z * z; u2 = U0[2] + z * U0[3]; z4 = z2 * z2; u = u1 + z2 * u2 + z4 * U0[4]; v1 = one + z * V0[0]; v2 = V0[1] + z * V0[2]; v3 = V0[3] + z * V0[4]; v = v1 + z2 * v2 + z4 * v3; return (x * (u / v) + tpi * (__ieee754_j1 (x) * __ieee754_log (x) - one / x)); }
GENERIC j1(GENERIC x) { GENERIC z, d, s, c, ss, cc, r; int i, sgn; if (!finite(x)) return (one/x); sgn = signbit(x); x = fabs(x); if (x > 8.00) { s = sin(x); c = cos(x); /* * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x0)-q1(x)*sin(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if (x > 8.9e307) { /* x+x may overflow */ ss = -s-c; cc = s-c; } else if (signbit(s) != signbit(c)) { cc = s - c; ss = cos(x+x)/cc; } else { ss = -s-c; cc = cos(x+x)/ss; } /* * j1(x) = 1/sqrt(pi*x) * (P(1,x)*cc - Q(1,x)*ss) * y1(x) = 1/sqrt(pi*x) * (P(1,x)*ss + Q(1,x)*cc) */ if (x > 1.0e40) d = (invsqrtpi*cc)/sqrt(x); else d = invsqrtpi*(pone(x)*cc-qone(x)*ss)/sqrt(x); if (x > X_TLOSS) { if (sgn != 0) { d = -d; x = -x; } return (_SVID_libm_err(x, d, 36)); } else if (sgn == 0) return (d); else return (-d); } if (x <= small) { if (x <= tiny) d = 0.5*x; else d = x*(0.5-x*x*0.125); if (sgn == 0) return (d); else return (-d); } z = x*x; if (x < 1.28) { r = r0[3]; s = s0[3]; for (i = 2; i >= 0; i--) { r = r*z + r0[i]; s = s*z + s0[i]; } d = x*0.5+x*(z*(r/s)); } else { r = r1[11]; for (i = 10; i >= 0; i--) r = r*z + r1[i]; s = s1[0]+z*(s1[1]+z*(s1[2]+z*(s1[3]+z*s1[4]))); d = x*(r/s); } if (sgn == 0) return (d); else return (-d); }
GENERIC y1(GENERIC x) { GENERIC z, d, s, c, ss, cc, u, v; int i; if (isnan(x)) return (x*x); /* + -> * for Cheetah */ if (x <= zero) { if (x == zero) /* return -one/zero; */ return (_SVID_libm_err(x, x, 10)); else /* return zero/zero; */ return (_SVID_libm_err(x, x, 11)); } if (x > 8.0) { if (!finite(x)) return (zero); s = sin(x); c = cos(x); /* * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x0)-q1(x)*sin(x0)) * where x0 = x-3pi/4 * Better formula: * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) * = 1/sqrt(2) * (sin(x) - cos(x)) * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) * = -1/sqrt(2) * (cos(x) + sin(x)) * To avoid cancellation, use * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ if (x > 8.9e307) { /* x+x may overflow */ ss = -s-c; cc = s-c; } else if (signbit(s) != signbit(c)) { cc = s - c; ss = cos(x+x)/cc; } else { ss = -s-c; cc = cos(x+x)/ss; } /* * j1(x) = 1/sqrt(pi*x) * (P(1,x)*cc - Q(1,x)*ss) * y1(x) = 1/sqrt(pi*x) * (P(1,x)*ss + Q(1,x)*cc) */ if (x > 1.0e91) d = (invsqrtpi*ss)/sqrt(x); else d = invsqrtpi*(pone(x)*ss+qone(x)*cc)/sqrt(x); if (x > X_TLOSS) return (_SVID_libm_err(x, d, 37)); else return (d); } if (x <= tiny) { return (-tpi/x); } z = x*x; if (x < 1.28) { u = u0[3]; v = v0[3]+z*v0[4]; for (i = 2; i >= 0; i--) { u = u*z + u0[i]; v = v*z + v0[i]; } } else { for (u = u1[11], i = 10; i >= 0; i--) u = u*z+u1[i]; v = v1[0]+z*(v1[1]+z*(v1[2]+z*(v1[3]+z*v1[4]))); } return (x*(u/v) + tpi*(j1(x)*log(x)-one/x)); }