/* y=0 is not permitted if x<=0. No error messages are given. */ void __mpatan2(mp_no *y, mp_no *x, mp_no *z, int p) { static const double ZERO = 0.0, ONE = 1.0; mp_no mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}; mp_no mpt1,mpt2,mpt3; if (X[0] <= ZERO) { mpone.e = 1; mpone.d[0] = mpone.d[1] = ONE; __dvd(x,y,&mpt1,p); __mul(&mpt1,&mpt1,&mpt2,p); if (mpt1.d[0] != ZERO) mpt1.d[0] = ONE; __add(&mpt2,&mpone,&mpt3,p); __mpsqrt(&mpt3,&mpt2,p); __add(&mpt1,&mpt2,&mpt3,p); mpt3.d[0]=Y[0]; __mpatan(&mpt3,&mpt1,p); __add(&mpt1,&mpt1,z,p); } else { __dvd(y,x,&mpt1,p); __mpatan(&mpt1,z,p); } return; }
/* Final stages. Compute atan(x) by multiple precision arithmetic */ static double atanMp (double x, const int pr[]) { mp_no mpx, mpy, mpy2, mperr, mpt1, mpy1; double y1, y2; int i, p; for (i = 0; i < M; i++) { p = pr[i]; __dbl_mp (x, &mpx, p); __mpatan (&mpx, &mpy, p); __dbl_mp (u9[i].d, &mpt1, p); __mul (&mpy, &mpt1, &mperr, p); __add (&mpy, &mperr, &mpy1, p); __sub (&mpy, &mperr, &mpy2, p); __mp_dbl (&mpy1, &y1, p); __mp_dbl (&mpy2, &y2, p); if (y1 == y2) { LIBC_PROBE (slowatan, 3, &p, &x, &y1); return y1; } } LIBC_PROBE (slowatan_inexact, 3, &p, &x, &y1); return y1; /*if impossible to do exact computing */ }