導航:首頁 > 軟體知識 > atan程序怎麼寫

atan程序怎麼寫

發布時間:2024-12-26 04:48:00

1. 計算機c語言編程arctanx數值計算

#include <stdio.h>
#include <math.h>
long double pi = 3.1415926535897,result1 = 0.0,result2 = 0.0,p,q;

void func1(long double input)
{
int n = 0;
result1 = 0.0,result2 = 0.0;
do
{
result2 = result1;
result1 += ((long double)pow((double)-1,n)/(2*n+1))*pow(input,2*n+1);
n++;
if ( result1 >= result2) p = result1,q = result2;
else q = result1,p = result2;
}
while(p-q>=0.000000000001);
}
void func2(long double input){}

long double Arctan(long double input)
{
if (input < 1 && input > -1 )
func1(input);
else
func2(input);
return result1;
}

int main()
{
long double m = Arctan(0);
return 0;
}

2. 在EXCEL中 SQRT和ATAN是什麼意思呢

SQRT(number) 計算平方根函數,ATAN反正切函數。

示例如下,

1、創建excel,插入樣例數據,兩列,

數值 函數

4

5

12

16

18

3. avr中怎麼運用atan(x,y) 函數

# define PiOv2 (3.14159f / 2.0f)
# define SignBit(f) ((*(const unsigned long *)&(f)) >> 31)
float Atan_16bits_Pre( float y, float x )
{
float a, s;
if ( fabs( y ) > fabs( x ) )
{
a = x / y;
s = a * a;
s = - ( ( ( ( ( ( ( ( ( 0.0028662257f * s - 0.0161657367f ) * s + 0.0429096138f ) * s - 0.0752896400f )
* s + 0.1065626393f ) * s - 0.1420889944f ) * s + 0.1999355085f ) * s - 0.3333314528f ) * s ) + 1.0f ) * a;
if ( SignBit( a ) ) {
return s - PiOv2;
} else {
return s + PiOv2;
}
}
else
{
a = y / x;
s = a * a;
return ( ( ( ( ( ( ( ( ( 0.0028662257f * s - 0.0161657367f ) * s + 0.0429096138f ) * s - 0.0752896400f )
* s + 0.1065626393f ) * s - 0.1420889944f ) * s + 0.1999355085f ) * s - 0.3333314528f ) * s ) + 1.0f ) * a;
}
}
atan(x,y)需要CPU浮點指令級支持,AVR中一般沒有專用浮點單元,所以atan也是軟體實現的。如果你在AVR的庫中一時沒有找到atan,可以用上面這段程序代替,注意,上面程序只提供了兩位元組精度支持,大概小數點後3位左右。
上述程序來至id的4號引擎,基本上都是大神寫的,你很難找到一段效率比它還高的代碼,上述代碼在一定情況下和浮點指令的速度差不多。

閱讀全文

與atan程序怎麼寫相關的資料

熱點內容
代理姐是什麼意思 瀏覽:793
洛陽啤酒代理怎麼找 瀏覽:456
股票軟體交易系統看哪個指標 瀏覽:355
基金交易大師有哪些 瀏覽:774
酒店工程部需要哪些技術支持 瀏覽:631
江蘇代理乳膠漆多少錢 瀏覽:191
表格數據如何轉移 瀏覽:802
醫用信息技術考什麼 瀏覽:393
隨申辦怎麼會有筆支付交易 瀏覽:947
代理機構如何梳理企業的研發項目 瀏覽:318
股票大眾交易後多久可以賣 瀏覽:68
怎麼搭建信息收集小程序 瀏覽:607
杭州匯宇傢具家飾市場怎麼樣 瀏覽:554
市場細分條件之一是什麼 瀏覽:154
南充兒童衣服批發市場在哪裡 瀏覽:522
物聯網和電子信息科學哪個比較好 瀏覽:532
新買的車怎麼交易 瀏覽:381
核心數據平台有哪些 瀏覽:785
餓了么在市區代理權怎麼拿 瀏覽:404
r程序如何新增一列數據 瀏覽:350