他的atan方法代码如下所示:
/**
* Returns the arc tangent of an angle, in the range of -pi/2 through pi/2. Special cases: If the argument is NaN, then the result is NaN. If the argument is zero, then the result is a zero with the same sign as the argument. A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic
* @param x Float - the value whose arc tangent is to be returned
* @return Float - the arc tangent of the argument
*/
static public Float atan(Float x)
{
boolean signChange=false;
boolean Invert=false;
int sp=0;
Float x2, a;
// check up the sign change
if(x.Less(ZERO))
{
x=x.Neg();
signChange=true;
}
// check up the invertation
if(x.Great(ONE))
{
x=ONE.Div(x);
Invert=true;
}
// process shrinking the domain until x<PI/12
while(x.Great(PIdiv12))
{
sp++;
a=x.Add(SQRT3);
a=ONE.Div(a);
x=x.Mul(SQRT3);
x=x.Sub(ONE);
x=x.Mul(a);
}
// calculation core
x2=x.Mul(x);
a=x2.Add(new Float(14087812, -7));
a=new Float(55913709, -8).Div(a);
a=a.Add(new Float(60310579, -8));
a=a.Sub(x2.Mul(new Float(5160454, -8)));
a=a.Mul(x);
// process until sp=0
while(sp>0)
{
a=a.Add(PIdiv6);
sp--;
}
// invertation took place
if(Invert) a=PIdiv2.Sub(a);
// sign change took place
if(signChange) a=a.Neg();
//
return a;
}