如何求反正切atan?

programfish 2005-12-24 07:07:24
j2me中只有正切tan,如何求反正切atan啊?
...全文
623 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
delphiseabird 2005-12-29
  • 打赏
  • 举报
回复
用公式模拟,不过误差较大
我认为最好的办法是存表发,把atan的值都存到数组中,用的时候直接读。
----------------------------------
www.coderpub.com
programfish 2005-12-27
  • 打赏
  • 举报
回复
还有个问题,如何读取TextField中的内容为float类型。
zhengyun_ustc 2005-12-26
  • 打赏
  • 举报
回复
建议使用henson.midp.Float11,你可以在http://www.j2medev.com/Article/ShowArticle.asp?ArticleID=864找到对他的介绍。henson.midp.Float类非常适合科学计算,他的范围很大,具有64位的尾数(mantissa),64位的指数。该Float类和J2SE标准的Float类十分的相似,提供了完备的方法。

他的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;
}
prok 2005-12-26
  • 打赏
  • 举报
回复
查表
programfish 2005-12-25
  • 打赏
  • 举报
回复
能给个数学计算公式吗?谢谢
网络咖啡 2005-12-25
  • 打赏
  • 举报
回复
使用数学公式计算或者是查表,或者是使用第三方的API
xueyong1203 2005-12-24
  • 打赏
  • 举报
回复
MathFP for MIDP 可以很好的满足你的需求
programfish 2005-12-24
  • 打赏
  • 举报
回复
能具体点吗?
zncn2 2005-12-24
  • 打赏
  • 举报
回复
级数展开式

13,097

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧