Back to index

glibc  2.9
Functions | Variables
e_j0.c File Reference
#include "math.h"
#include "math_private.h"

Go to the source code of this file.

Functions

static double pzero ()
static double qzero ()
double __ieee754_j0 (double x)
double __ieee754_y0 (double x)
static double pzero (double x)
static double qzero (double x)

Variables

static double huge = 1e300
static double one = 1.0
static double invsqrtpi = 5.64189583547756279280e-01
static double tpi = 6.36619772367581382433e-01
static double R []
static double S []
static double zero = 0.0
static double U []
static double V []
static double pR8 [6]
static double pS8 [5]
static double pR5 [6]
static double pS5 [5]
static double pR3 [6]
static double pS3 [5]
static double pR2 [6]
static double pS2 [5]
static double qR8 [6]
static double qS8 [6]
static double qR5 [6]
static double qS5 [6]
static double qR3 [6]
static double qS3 [6]
static double qR2 [6]
static double qS2 [6]

Function Documentation

double __ieee754_j0 ( double  x)

Definition at line 102 of file e_j0.c.

{
       double z, s,c,ss,cc,r,u,v,r1,r2,s1,s2,z2,z4;
       int32_t hx,ix;

       GET_HIGH_WORD(hx,x);
       ix = hx&0x7fffffff;
       if(ix>=0x7ff00000) return one/(x*x);
       x = fabs(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;
              }
       /*
        * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
        * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
        */
              if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrt(x);
              else {
                  u = pzero(x); v = qzero(x);
                  z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrt(x);
              }
              return z;
       }
       if(ix<0x3f200000) {  /* |x| < 2**-13 */
           if(huge+x>one) { /* raise inexact if x != 0 */
               if(ix<0x3e400000) return one;     /* |x|<2**-27 */
               else        return one - 0.25*x*x;
           }
       }
       z = x*x;
#ifdef DO_NOT_USE_THIS
       r =  z*(R02+z*(R03+z*(R04+z*R05)));
       s =  one+z*(S01+z*(S02+z*(S03+z*S04)));
#else
       r1 = z*R[2]; z2=z*z;
       r2 = R[3]+z*R[4]; z4=z2*z2;
       r  = r1 + z2*r2 + z4*R[5];
       s1 = one+z*S[1];
       s2 = S[2]+z*S[3];
       s = s1 + z2*s2 + z4*S[4];
#endif
       if(ix < 0x3FF00000) {       /* |x| < 1.00 */
           return one + z*(-0.25+(r/s));
       } else {
           u = 0.5*x;
           return((one+u)*(one-u)+z*(r/s));
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

double __ieee754_y0 ( double  x)

Definition at line 179 of file e_j0.c.

{
       double z, s,c,ss,cc,u,v,z2,z4,z6,u1,u2,u3,v1,v2;
       int32_t hx,ix,lx;

       EXTRACT_WORDS(hx,lx,x);
        ix = 0x7fffffff&hx;
    /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0, y0(0) is -inf.  */
       if(ix>=0x7ff00000) return  one/(x+x*x);
        if((ix|lx)==0) return -HUGE_VAL+x; /* -inf and overflow exception.  */
        if(hx<0) return zero/(zero*x);
        if(ix >= 0x40000000) {  /* |x| >= 2.0 */
        /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
         * where x0 = x-pi/4
         *      Better formula:
         *              cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
         *                      =  1/sqrt(2) * (sin(x) + cos(x))
         *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
         *                      =  1/sqrt(2) * (sin(x) - cos(x))
         * To avoid cancellation, use
         *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
         * to compute the worse one.
         */
              __sincos (x, &s, &c);
                ss = s-c;
                cc = s+c;
       /*
        * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
        * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
        */
                if(ix<0x7fe00000) {  /* make sure x+x not overflow */
                    z = -__cos(x+x);
                    if ((s*c)<zero) cc = z/ss;
                    else            ss = z/cc;
                }
                if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrt(x);
                else {
                    u = pzero(x); v = qzero(x);
                    z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrt(x);
                }
                return z;
       }
       if(ix<=0x3e400000) { /* x < 2**-27 */
           return(U[0] + tpi*__ieee754_log(x));
       }
       z = x*x;
#ifdef DO_NOT_USE_THIS
       u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
       v = one+z*(v01+z*(v02+z*(v03+z*v04)));
#else
       u1 = U[0]+z*U[1]; z2=z*z;
       u2 = U[2]+z*U[3]; z4=z2*z2;
       u3 = U[4]+z*U[5]; z6=z4*z2;
       u = u1 + z2*u2 + z4*u3 + z6*U[6];
       v1 = one+z*V[0];
       v2 = V[1]+z*V[2];
       v = v1 + z2*v2 + z4*V[3];
#endif
       return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static double pzero ( ) [static]

Here is the caller graph for this function:

static double pzero ( double  x) [static]

Definition at line 350 of file e_j0.c.

{
#ifdef __STDC__
       const double *p,*q;
#else
       double *p,*q;
#endif
       double z,r,s,z2,z4,r1,r2,r3,s1,s2,s3;
       int32_t ix;
       GET_HIGH_WORD(ix,x);
       ix &= 0x7fffffff;
       if(ix>=0x40200000)     {p = pR8; q= pS8;}
       else if(ix>=0x40122E8B){p = pR5; q= pS5;}
       else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
       else if(ix>=0x40000000){p = pR2; q= pS2;}
       z = one/(x*x);
#ifdef DO_NOT_USE_THIS
       r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
       s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
#else
       r1 = p[0]+z*p[1]; z2=z*z;
       r2 = p[2]+z*p[3]; z4=z2*z2;
       r3 = p[4]+z*p[5];
       r = r1 + z2*r2 + z4*r3;
       s1 = one+z*q[0];
       s2 = q[1]+z*q[2];
       s3 = q[3]+z*q[4];
       s = s1 + z2*s2 + z4*s3;
#endif
       return one+ r/s;
}
static double qzero ( )

Here is the caller graph for this function:

static double qzero ( double  x) [static]

Definition at line 497 of file e_j0.c.

{
#ifdef __STDC__
       const double *p,*q;
#else
       double *p,*q;
#endif
       double s,r,z,z2,z4,z6,r1,r2,r3,s1,s2,s3;
       int32_t ix;
       GET_HIGH_WORD(ix,x);
       ix &= 0x7fffffff;
       if(ix>=0x40200000)     {p = qR8; q= qS8;}
       else if(ix>=0x40122E8B){p = qR5; q= qS5;}
       else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
       else if(ix>=0x40000000){p = qR2; q= qS2;}
       z = one/(x*x);
#ifdef DO_NOT_USE_THIS
       r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
       s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
#else
       r1 = p[0]+z*p[1]; z2=z*z;
       r2 = p[2]+z*p[3]; z4=z2*z2;
       r3 = p[4]+z*p[5]; z6=z4*z2;
       r= r1 + z2*r2 + z4*r3;
       s1 = one+z*q[0];
       s2 = q[1]+z*q[2];
       s3 = q[3]+z*q[4];
       s = s1 + z2*s2 + z4*s3 +z6*q[5];
#endif
       return (-.125 + r/s)/x;
}

Variable Documentation

double huge = 1e300 [static]

Definition at line 79 of file e_j0.c.

double invsqrtpi = 5.64189583547756279280e-01 [static]

Definition at line 81 of file e_j0.c.

double one = 1.0 [static]

Definition at line 80 of file e_j0.c.

double pR2[6] [static]
Initial value:
 {

 -8.87534333032526411254e-08, 
 -7.03030995483624743247e-02, 
 -1.45073846780952986357e+00, 
 -7.63569613823527770791e+00, 
 -1.11931668860356747786e+01, 
 -3.23364579351335335033e+00, 
}

Definition at line 326 of file e_j0.c.

double pR3[6] [static]
Initial value:
 {

 -2.54704601771951915620e-09, 
 -7.03119616381481654654e-02, 
 -2.40903221549529611423e+00, 
 -2.19659774734883086467e+01, 
 -5.80791704701737572236e+01, 
 -3.14479470594888503854e+01, 
}

Definition at line 302 of file e_j0.c.

double pR5[6] [static]
Initial value:
 { 

 -1.14125464691894502584e-11, 
 -7.03124940873599280078e-02, 
 -4.15961064470587782438e+00, 
 -6.76747652265167261021e+01, 
 -3.31231299649172967747e+02, 
 -3.46433388365604912451e+02, 
}

Definition at line 278 of file e_j0.c.

double pR8[6] [static]
Initial value:
 { 

  0.00000000000000000000e+00, 
 -7.03124999999900357484e-02, 
 -8.08167041275349795626e+00, 
 -2.57063105679704847262e+02, 
 -2.48521641009428822144e+03, 
 -5.25304380490729545272e+03, 
}

Definition at line 254 of file e_j0.c.

double pS2[5] [static]
Initial value:
 {

  2.22202997532088808441e+01, 
  1.36206794218215208048e+02, 
  2.70470278658083486789e+02, 
  1.53875394208320329881e+02, 
  1.46576176948256193810e+01, 
}

Definition at line 338 of file e_j0.c.

double pS3[5] [static]
Initial value:
 {

  3.58560338055209726349e+01, 
  3.61513983050303863820e+02, 
  1.19360783792111533330e+03, 
  1.12799679856907414432e+03, 
  1.73580930813335754692e+02, 
}

Definition at line 314 of file e_j0.c.

double pS5[5] [static]
Initial value:
 {

  6.07539382692300335975e+01, 
  1.05125230595704579173e+03, 
  5.97897094333855784498e+03, 
  9.62544514357774460223e+03, 
  2.40605815922939109441e+03, 
}

Definition at line 290 of file e_j0.c.

double pS8[5] [static]
Initial value:
 {

  1.16534364619668181717e+02, 
  3.83374475364121826715e+03, 
  4.05978572648472545552e+04, 
  1.16752972564375915681e+05, 
  4.76277284146730962675e+04, 
}

Definition at line 266 of file e_j0.c.

double qR2[6] [static]
Initial value:
 {

  1.50444444886983272379e-07, 
  7.32234265963079278272e-02, 
  1.99819174093815998816e+00, 
  1.44956029347885735348e+01, 
  3.16662317504781540833e+01, 
  1.62527075710929267416e+01, 
}

Definition at line 472 of file e_j0.c.

double qR3[6] [static]
Initial value:
 {

  4.37741014089738620906e-09, 
  7.32411180042911447163e-02, 
  3.34423137516170720929e+00, 
  4.26218440745412650017e+01, 
  1.70808091340565596283e+02, 
  1.66733948696651168575e+02, 
}

Definition at line 447 of file e_j0.c.

double qR5[6] [static]
Initial value:
 { 

  1.84085963594515531381e-11, 
  7.32421766612684765896e-02, 
  5.83563508962056953777e+00, 
  1.35111577286449829671e+02, 
  1.02724376596164097464e+03, 
  1.98997785864605384631e+03, 
}

Definition at line 422 of file e_j0.c.

double qR8[6] [static]
Initial value:
 { 

  0.00000000000000000000e+00, 
  7.32421874999935051953e-02, 
  1.17682064682252693899e+01, 
  5.57673380256401856059e+02, 
  8.85919720756468632317e+03, 
  3.70146267776887834771e+04, 
}

Definition at line 397 of file e_j0.c.

double qS2[6] [static]
Initial value:
 {

  3.03655848355219184498e+01, 
  2.69348118608049844624e+02, 
  8.44783757595320139444e+02, 
  8.82935845112488550512e+02, 
  2.12666388511798828631e+02, 
 -5.31095493882666946917e+00, 
}

Definition at line 484 of file e_j0.c.

double qS3[6] [static]
Initial value:
 {

  4.87588729724587182091e+01, 
  7.09689221056606015736e+02, 
  3.70414822620111362994e+03, 
  6.46042516752568917582e+03, 
  2.51633368920368957333e+03, 
 -1.49247451836156386662e+02, 
}

Definition at line 459 of file e_j0.c.

double qS5[6] [static]
Initial value:
 {

  8.27766102236537761883e+01, 
  2.07781416421392987104e+03, 
  1.88472887785718085070e+04, 
  5.67511122894947329769e+04, 
  3.59767538425114471465e+04, 
 -5.35434275601944773371e+03, 
}

Definition at line 434 of file e_j0.c.

double qS8[6] [static]
Initial value:
 {

  1.63776026895689824414e+02, 
  8.09834494656449805916e+03, 
  1.42538291419120476348e+05, 
  8.03309257119514397345e+05, 
  8.40501579819060512818e+05, 
 -3.43899293537866615225e+05, 
}

Definition at line 409 of file e_j0.c.

double R[] [static]
Initial value:
  {0.0, 0.0, 1.56249999999999947958e-02, 
 -1.89979294238854721751e-04, 
  1.82954049532700665670e-06, 
 -4.61832688532103189199e-09}

Definition at line 84 of file e_j0.c.

double S[] [static]
Initial value:
  {0.0, 1.56191029464890010492e-02, 
  1.16926784663337450260e-04, 
  5.13546550207318111446e-07, 
  1.16614003333790000205e-09}

Definition at line 88 of file e_j0.c.

double tpi = 6.36619772367581382433e-01 [static]

Definition at line 82 of file e_j0.c.

double U[] [static]
Initial value:
 {-7.38042951086872317523e-02, 
  1.76666452509181115538e-01, 
 -1.38185671945596898896e-02, 
  3.47453432093683650238e-04, 
 -3.81407053724364161125e-06, 
  1.95590137035022920206e-08, 
 -3.98205194132103398453e-11}

Definition at line 164 of file e_j0.c.

double V[] [static]
Initial value:
  {1.27304834834123699328e-02, 
  7.60068627350353253702e-05, 
  2.59150851840457805467e-07, 
  4.41110311332675467403e-10}

Definition at line 171 of file e_j0.c.

double zero = 0.0 [static]

Definition at line 96 of file e_j0.c.