atan() 如何提高精度

来源:百度知道 编辑:UC知道 时间:2024/05/13 14:27:28
在C++语言中,atan()函数算出来的精度很低,请问要用什么算法来算atan(反正切)的值,才能提高精度?

跟你定义的变量类型有关吧,你将其定义成double精度也不够吗

用:
double atan ( double x );
long double atan ( long double x );

或 用 atan2:

double atan2 ( double y, double x );
long double atan2 ( long double y, long double x );

当然,自己写长长双精度数 再用级数算 也可以。

自己设计atan函数(参见高数的泰勒公式设计),之后使用char[]存储数据,即可。