C語(yǔ)言sin()用來(lái)計(jì)算參數(shù)x
創(chuàng)新互聯(lián)是一家專注于成都做網(wǎng)站、網(wǎng)站制作和雅安電信機(jī)房的網(wǎng)絡(luò)公司,有著豐富的建站經(jīng)驗(yàn)和案例。
的正玄值,然后將結(jié)果返回。返回-1
至1
之間的計(jì)算顫慶結(jié)果。
例子:
#include
math.h
main(){
double
answer
=
sin(0.5);
printf("sin(0.5)
=
%f\n",
answer);
}
執(zhí)行
sin(0.5)
=
0.479426
C語(yǔ)言sin():
sin()原型:double
sin(double
x)
sin()角度與弧度:
π=180°
1°=π/180
1(rad)=180/π
角埋談度轉(zhuǎn)弧度:用角度乘以π/180
弧度轉(zhuǎn)角度:用彎洞碰弧度乘以180/π,或者用rtod()函數(shù)
擴(kuò)展資料:
與sin相似的acos函數(shù)
函數(shù)名:
acos
功
能:計(jì)算并返回arccos(x)值、要求-1=X=1
函數(shù)與形參類型:
double
acos(x)
double
x;
程序例:
#include
stdio.h
#include
math.h
int
main(void)
{
double
result;
double
x
=
0.5;
result
=
acos(x);
printf("The
arc
cosine
of
%lf
is
%lf\n",
x,
result);
return
0;
}
參考資料:CSDN博客頻道-C語(yǔ)言中sin和cos的用法
1、C語(yǔ)言中要編寫sin函數(shù),實(shí)質(zhì)上要利用sin的泰勒公式,然后根據(jù)泰勒公式,將其中的每一項(xiàng)純姿歷進(jìn)行分解,最后用循環(huán),累加計(jì)算出最終結(jié)果。
2、下面用for循環(huán)實(shí)現(xiàn)sin的算法,程序代碼如下:
#includestdio.h
#includemath.h
void?main()
{
int??i;
float??x,sum,a,b;??//sum代表和,a為分子,b為分母
char?s;
printf("please?input?x");
scanf("%f",x);
s=1;
sum=0;
a=x;?????//分母賦初值
b=1;?????//分子賦初值
for(i=1;a/b=1e-6;i++)
{
sum=sum+s*a/b;????//累加一項(xiàng)
a=a*x*x;?????//求下一項(xiàng)分子
b=b*2*i*(2*i+1);?做搜??//求下一項(xiàng)分母
s*=-1;
}
printf("sum=%f\n",sum);
}
3、? 關(guān)于上述程序的幾點(diǎn)說(shuō)明:上述程序的計(jì)算結(jié)果精確到小數(shù)點(diǎn)后六位;上述程序運(yùn)用了sin的泰勒展開式 sin x=x-x^3/3!+x^5/5! ...... ,程序中將sin泰勒公式中的每一項(xiàng)拆成了分子,分母以及每一項(xiàng)前的符號(hào)這三項(xiàng),以便于每一項(xiàng)的累冊(cè)游加。
頭文件包含。math.h
cos :余弦函數(shù)
函數(shù)原型:double cos(double x);
頭文叢消件:#includemath.h
是否是標(biāo)準(zhǔn)函數(shù):是
函數(shù)功能:求x的余弦值,這里,x為弧度。
返回值:計(jì)算結(jié)果的雙精度值。
例程如下宴雹: 求cosx。
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = M_PI;
result = cos(x);
printf("cos(PI) is %lf\n", result);
return 0;
}
sin:正弦函數(shù)
函數(shù)原型:double sin(double x);
頭文件:#includemath.h
是否是標(biāo)準(zhǔn)函數(shù):是
函數(shù)功能:求x的正弦值,這里,x為弧度。
返回值:計(jì)算結(jié)果的雙精度滲祥知值。
例程如下: 求sinx。
#include stdio.h
#include math.h
int main(void)
{
float x;
x=M_PI/2;
printf("sin(PI/2)=%f",sin(x));
getchar();
return 0;
}
分享標(biāo)題:c語(yǔ)言正弦函數(shù)運(yùn)算十次 c語(yǔ)言正弦余弦函數(shù)
網(wǎng)頁(yè)鏈接:http://jinyejixie.com/article6/ddpisog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、動(dòng)態(tài)網(wǎng)站、網(wǎng)站策劃、建站公司、App設(shè)計(jì)、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)