Inverse trigonometric cosine function.
- Version
- 1.3
- Date
- 95/01/18
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 x itself;
if |x|>1, return NaN with invalid signal.
Function needed: sqrt
- Copyright
- Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. Developed at SunSoft, a Sun Microsystems, Inc. business. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved.
Definition at line 96 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 RealNumber::ArcCosine(), and RealNumber::ArcSecant().
98 double z,p,q,r,w,s,c,df;
105 if(((ix-0x3ff00000)|lx)==0) {
125 return pi - 2.0*(s+w);
131 c = (z-df*df)/(s+df);
#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.
signed int sword
32 bit signed integer.
double sqrt(double x)
Square root function.
#define SET_LOW_WORD(d, v)
Set the less significant 32 bits of a double from an int.
static const double pio2_lo