cosx函數(shù)

10年積累的成都網(wǎng)站制作、做網(wǎng)站、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有萬(wàn)秀免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
#includestdio.h
#includemath.h
int main()
{
int n=0;
double x,sum=0;
printf("please enter x:");
scanf("%lf",x);//
double cosx(double x,int n);
do
{
sum=sum+cosx(x,n);
n=n+1;
}
while(fabs(cosx(x,n))1e-8);
printf("%9.8f\n",sum);
return 0;
}
double cosx(double x,int n)
{
double p,q;//
p=pow(x,2*n);
double fact(int n);//
q=fact(2*n);
if(n%2)
return(-p/q);
else
return(p/q);
}
double fact(int n)//
{
double ans=1; int i;
if(n=1)
return 1;
for(i=1;i=n; ++i)
ans*=i;
return ans;
}
cosx函數(shù)即反余弦函數(shù)
函數(shù)y=cosx(x∈[0,π])的反函數(shù)叫做反余弦函數(shù),
記作y=arccosx(x∈[-1,1]).
如何在C語(yǔ)言中解決正弦或余弦函數(shù)的表示方法我是一個(gè)?頭文件包含。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。
用法:
doublesin(doublex);
doublecos(doubley);
例:
#includestdio.h
#includemath.h
intmain()
{
intn;
doublet;
constdoublepi=4.0*atan(1.0);
scanf("%d",n);
t=(n*pi)*1.0/180;
printf("%lf\n",pi);
printf("%lf\n",sin(t));
擴(kuò)展資料
sinln等函數(shù),sin(pi/2)=1,ln1=0的使用
例:
#includemath.h
#includestdio.h
intmain()
{
doublepi=3.1416;
printf("sin(pi/2)=%f\nln1=%f\n",sin(pi/2),log(1.0));
return0;
}
cos函數(shù)的輸入值為弧度,也就是將cos函數(shù)后加上弧度,然后就可以得到想要的結(jié)果。我們需要把度化為弧度:
假設(shè)度數(shù)為d,則對(duì)應(yīng)的弧度為:d * pi / 180
cos()是庫(kù)函數(shù),在頭文件math.h中,原型是double?cos(double?x);,其中x要用弧度表示。如求30°的余弦值可用下列代碼實(shí)現(xiàn):
//#include?"stdafx.h"http://If?the?vc++6.0,?with?this?line.
#include?"stdio.h"
#include?"math.h"
int?main(void){
printf("cos30°=?%.10f\n",cos(30*3.1415926535897932/180));
return?0;
}
名稱欄目:c語(yǔ)言中cos函數(shù),c語(yǔ)言中cos函數(shù)值域
標(biāo)題來源:http://chinadenli.net/article41/dsgpihd.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、ChatGPT、動(dòng)態(tài)網(wǎng)站、營(yíng)銷型網(wǎng)站建設(shè)、面包屑導(dǎo)航、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(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í)需注明來源: 創(chuàng)新互聯(lián)