Beispiel #1
0
static double slow1(double x) {
  mynumber u;
  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,c1,c2,xx,cor,res;
  static const double t22 = 6291456.0;
  int4 k;
  y=ABS(x);
  u.x=big.x+y;
  y=y-(u.x-big.x);
  xx=y*y;
  s = y*xx*(sn3 +xx*sn5);
  c = xx*(cs2 +xx*(cs4 + xx*cs6));
  k=u.i[LOW_HALF]<<2;
  sn=sincos.x[k];          /* Data          */
  ssn=sincos.x[k+1];       /*  from         */
  cs=sincos.x[k+2];        /*   tables      */
  ccs=sincos.x[k+3];       /*    sincos.tbl */
  y1 = (y+t22)-t22;
  y2 = y - y1;
  c1 = (cs+t22)-t22;
  c2=(cs-c1)+ccs;
  cor=(ssn+s*ccs+cs*s+c2*y+c1*y2)-sn*c;
  y=sn+c1*y1;
  cor = cor+((sn-y)+c1*y1);
  res=y+cor;
  cor=(y-res)+cor;
  if (res == res+1.0005*cor) return (x>0)?res:-res;
  else {
    __dubsin(ABS(x),0,w);
    if (w[0] == w[0]+1.000000005*w[1]) return (x>0)?w[0]:-w[0];
    else return (x>0)?__mpsin(x,0):-__mpsin(-x,0);
  }
}
Beispiel #2
0
static double
SECTION
sloww2 (double x, double dx, double orig, int n)
{
  mynumber u;
  double w[2], y, cor, res;

  u.x = big + x;
  y = x - (u.x - big);
  res = do_cos_slow (u, y, dx, 3.1e-30 * fabs (orig), &cor);

  if (res == res + cor)
    return (n & 2) ? -res : res;
  else
    {
      __docos (x, dx, w);

      if (w[1] > 0)
	cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
      else
	cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);

      if (w[0] == w[0] + cor)
	return (n & 2) ? -w[0] : w[0];
      else
	return __mpsin (orig, 0, true);
    }
}
Beispiel #3
0
static double
SECTION
sloww1 (double x, double dx, double orig, int m)
{
  mynumber u;
  double w[2], y, cor, res;

  u.x = big + x;
  y = x - (u.x - big);
  res = do_sin_slow (u, y, dx, 3.1e-30 * fabs (orig), &cor);

  if (res == res + cor)
    return (m > 0) ? res : -res;
  else
    {
      __dubsin (x, dx, w);

      if (w[1] > 0)
	cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
      else
	cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);

      if (w[0] == w[0] + cor)
	return (m > 0) ? w[0] : -w[0];
      else
	return __mpsin (orig, 0, true);
    }
}
Beispiel #4
0
static double
SECTION
bsloww2 (double x, double dx, double orig, int n)
{
  mynumber u;
  double w[2], y, cor, res;

  y = fabs (x);
  u.x = big + y;
  y = y - (u.x - big);
  dx = (x > 0) ? dx : -dx;
  res = do_cos_slow (u, y, dx, 1.1e-24, &cor);
  if (res == res + cor)
    return (n & 2) ? -res : res;
  else
    {
      __docos (fabs (x), dx, w);

      if (w[1] > 0)
	cor = 1.000000005 * w[1] + 1.1e-24;
      else
	cor = 1.000000005 * w[1] - 1.1e-24;

      if (w[0] == w[0] + cor)
	return (n & 2) ? -w[0] : w[0];
      else
	return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true);
    }
}
Beispiel #5
0
static double
SECTION
slow (double x)
{
  double res, cor, w[2];
  res = TAYLOR_SLOW (x, 0, cor);
  if (res == res + 1.0007 * cor)
    return res;
  else
    {
      __dubsin (fabs (x), 0, w);
      if (w[0] == w[0] + 1.000000001 * w[1])
	return (x > 0) ? w[0] : -w[0];
      else
	return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
    }
}
Beispiel #6
0
static double slow2(double x) {
  mynumber u;
  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,e1,e2,xx,cor,res,del;
  static const double t22 = 6291456.0;
  int4 k;
  y=ABS(x);
  y = hp0.x-y;
  if (y>=0) {
    u.x = big.x+y;
    y = y-(u.x-big.x);
    del = hp1.x;
  }
  else {
    u.x = big.x-y;
    y = -(y+(u.x-big.x));
    del = -hp1.x;
  }
  xx=y*y;
  s = y*xx*(sn3 +xx*sn5);
  c = y*del+xx*(cs2 +xx*(cs4 + xx*cs6));
  k=u.i[LOW_HALF]<<2;
  sn=sincos.x[k];
  ssn=sincos.x[k+1];
  cs=sincos.x[k+2];
  ccs=sincos.x[k+3];
  y1 = (y+t22)-t22;
  y2 = (y - y1)+del;
  e1 = (sn+t22)-t22;
  e2=(sn-e1)+ssn;
  cor=(ccs-cs*c-e1*y2-e2*y)-sn*s;
  y=cs-e1*y1;
  cor = cor+((cs-y)-e1*y1);
  res=y+cor;
  cor=(y-res)+cor;
  if (res == res+1.0005*cor) return (x>0)?res:-res;
  else {
    y=ABS(x)-hp0.x;
    y1=y-hp1.x;
    y2=(y-y1)-hp1.x;
    __docos(y1,y2,w);
    if (w[0] == w[0]+1.000000005*w[1]) return (x>0)?w[0]:-w[0];
    else return (x>0)?__mpsin(x,0):-__mpsin(-x,0);
  }
}
Beispiel #7
0
static double
SECTION
sloww (double x, double dx, double orig)
{
  double y, t, res, cor, w[2], a, da, xn;
  mynumber v;
  int4 n;
  res = TAYLOR_SLOW (x, dx, cor);
  if (cor > 0)
    cor = 1.0005 * cor + fabs (orig) * 3.1e-30;
  else
    cor = 1.0005 * cor - fabs (orig) * 3.1e-30;

  if (res == res + cor)
    return res;
  else
    {
      (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
      if (w[1] > 0)
	cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30;
      else
	cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30;

      if (w[0] == w[0] + cor)
	return (x > 0) ? w[0] : -w[0];
      else
	{
	  t = (orig * hpinv + toint);
	  xn = t - toint;
	  v.x = t;
	  y = (orig - xn * mp1) - xn * mp2;
	  n = v.i[LOW_HALF] & 3;
	  da = xn * pp3;
	  t = y - da;
	  da = (y - t) - da;
	  y = xn * pp4;
	  a = t - y;
	  da = ((t - a) - y) + da;
	  if (n & 2)
	    {
	      a = -a;
	      da = -da;
	    }
	  (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w);
	  if (w[1] > 0)
	    cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40;
	  else
	    cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40;

	  if (w[0] == w[0] + cor)
	    return (a > 0) ? w[0] : -w[0];
	  else
	    return __mpsin (orig, 0, true);
	}
    }
}
Beispiel #8
0
static double slow(double x) {
static const double th2_36 = 206158430208.0;   /*    1.5*2**37   */
 double y,x1,x2,xx,r,t,res,cor,w[2];
 x1=(x+th2_36)-th2_36;
 y = aa.x*x1*x1*x1;
 r=x+y;
 x2=x-x1;
 xx=x*x;
 t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + bb.x)*xx + 3.0*aa.x*x1*x2)*x +aa.x*x2*x2*x2;
 t=((x-r)+y)+t;
 res=r+t;
 cor = (r-res)+t;
 if (res == res + 1.0007*cor) return res;
 else {
   __dubsin(ABS(x),0,w);
   if (w[0] == w[0]+1.000000001*w[1]) return (x>0)?w[0]:-w[0];
   else return (x>0)?__mpsin(x,0):-__mpsin(-x,0);
 }
}
Beispiel #9
0
static double
SECTION
slow1 (double x)
{
  mynumber u;
  double w[2], y, cor, res;
  y = fabs (x);
  u.x = big + y;
  y = y - (u.x - big);
  res = do_sin_slow (u, y, 0, 0, &cor);
  if (res == res + cor)
    return (x > 0) ? res : -res;
  else
    {
      __dubsin (fabs (x), 0, w);
      if (w[0] == w[0] + 1.000000005 * w[1])
	return (x > 0) ? w[0] : -w[0];
      else
	return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
    }
}
Beispiel #10
0
static double
SECTION
slow2 (double x)
{
  mynumber u;
  double w[2], y, y1, y2, cor, res, del;

  y = fabs (x);
  y = hp0 - y;
  if (y >= 0)
    {
      u.x = big + y;
      y = y - (u.x - big);
      del = hp1;
    }
  else
    {
      u.x = big - y;
      y = -(y + (u.x - big));
      del = -hp1;
    }
  res = do_cos_slow (u, y, del, 0, &cor);
  if (res == res + cor)
    return (x > 0) ? res : -res;
  else
    {
      y = fabs (x) - hp0;
      y1 = y - hp1;
      y2 = (y - y1) - hp1;
      __docos (y1, y2, w);
      if (w[0] == w[0] + 1.000000005 * w[1])
	return (x > 0) ? w[0] : -w[0];
      else
	return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
    }
}
Beispiel #11
0
static double
SECTION
bsloww (double x, double dx, double orig, int n)
{
  double res, cor, w[2];

  res = TAYLOR_SLOW (x, dx, cor);
  cor = (cor > 0) ? 1.0005 * cor + 1.1e-24 : 1.0005 * cor - 1.1e-24;
  if (res == res + cor)
    return res;
  else
    {
      (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
      if (w[1] > 0)
	cor = 1.000000001 * w[1] + 1.1e-24;
      else
	cor = 1.000000001 * w[1] - 1.1e-24;
      if (w[0] == w[0] + cor)
	return (x > 0) ? w[0] : -w[0];
      else
	return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true);
    }
}