Inverse cosine function.
Method
acos(x) = pi/2 - asin(x)
acos(-x) = pi/2 + asin(x)
For |x|<=0.5
acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c)
For x>0.5
acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
= 2asin(sqrt((1-x)/2))
= 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z)
= 2f + (2c + 2s*z*R(z))
where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
for f so that f+c ~ sqrt(z).
For x<-0.5
acos(x) = pi - 2asin(sqrt((1-|x|)/2))
= pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
Special cases
if x is NaN, return NaN
if |x|>1, return NaN
Definition at line 92 of file acos.c.
References one, pi, pio2_hi, pio2_lo, pS0, pS1, pS2, pS3, pS4, pS5, qS1, qS2, qS3, qS4, and sqrt().
Referenced by ahvc(), RealNumber::ArcCosine(), asec(), and avcs().
94 double z, p, q, r, w, s, c, df;
102 if (ix >= 0x3FF00000)
107 if (((ix - 0x3FF00000) | lx) == 0)
127 if (ix <= 0x3C600000)
147 return pi - 2.0 * (s + w);
155 c = (z - df * df) / (s + df);
160 return 2.0 * (df + w);
#define GET_HIGH_WORD(i, d)
Get the more significant 32 bit int from a double.
static const double pio2_hi
#define GET_LOW_WORD(i, d)
Get the less significant 32 bit int from a double.
#define SET_LOW_WORD(d, v)
Set the less significant 32 bits of a double from an int.
double sqrt(double x)
Square root function.
static const double pio2_lo