首页 > 编程知识 正文

sine函数c语言,sin函数 c语言

时间:2024-03-07 18:23:41 阅读:332236 作者:ZMSK

本文目录一览:

C语言里sin函数和cos函数的调用

C语言里sin函数和cos函数是C标准数学函数库中的函数,调用需要引入math.h头文件。

一、sin() 函数描述:

C 库函数 double sin(double x) 返回弧度角 x 的正弦。sin() 函数的声明:double sin(double x)。

参数:x -- 浮点值,代表了一个以弧度表示的角度。

返回值:该函数返回 x 的正弦。

二、cos() 函数描述:

cos() 函数的功能是求某个角的余弦值。cos() 函数的声明:double cos(double x)。

参数:x -- 浮点值,代表了一个以弧度表示的角度。

返回值:该函数返回 x 的余弦。

扩展资料:

相关的三角函数:

double asin (double); 结果介于[-PI/2,PI/2]

double acos (double); 结果介于[0,PI]

double atan (double); 反正切(主值),结果介于[-PI/2,PI/2]

double atan2 (double,double); 反正切(整圆值),结果介于[-PI,PI]

参考资料来源:百度百科-math.h

C语言sin怎么用

C语言sin()用来计算参数x 的正玄值,然后将结果返回。返回-1 至1 之间的计算结果。

例子:

#include math.h

main(){

double answer = sin(0.5);

printf("sin(0.5) = %fn", answer);

}

执行

sin(0.5) = 0.479426

C语言sin():

sin()原型:double sin(double x)

sin()角度与弧度:

π=180°

1°=π/180

1(rad)=180/π

角度转弧度:用角度乘以π/180

弧度转角度:用弧度乘以180/π,或者用rtod()函数

扩展资料:

与sin相似的acos函数

函数名: acos

功 能:计算并返回arccos(x)值、要求-1=X=1

函数与形参类型:

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 %lfn", x, result);

return 0;

}

参考资料:CSDN博客频道-C语言中sin和cos的用法

请问sin函数是什么意思,在c语言有什么作用。

sin函数是正弦函数,在C语言中用来求角度的sin值。

在直角三角形ABC中,∠C是直角,AB是∠c斜边,BC是∠A的对边,AC是∠B的对边。正弦函数就是sin(A)=a/c。

扩展资料

对于任意一个实数x都对应着唯一的角(弧度制中等于这个实数),而这个角又对应着唯一确定的正弦值sinx,这样,对于任意一个实数x都有唯一确定的值sinx对应。

在[-(π/2)+2kπ,(π/2)+2kπ],k∈Z上是增函数

在[(π/2)+2kπ,(3π/2)+2kπ],k∈Z上是减函数

最大值:当x=2kπ+(π/2) ,k∈Z时,y(max)=1

最小值:当x=2kπ+(3π/2),k∈Z时,y(min)=-1

参考资料来源:百度百科-sin函数

C语言编写sin函数?求教!

C语言中要编写sin函数,实质上要利用sin的泰勒公式,然后根据泰勒公式,将其中的每一项进行分解,最后用循环,累加计算出最终结果

下面用for循环实现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;    //累加一项

a=a*x*x;     //求下一项分子

b=b*2*i*(2*i+1);   //求下一项分母

s*=-1;

}

printf("sum=%fn",sum);

}

3.  关于上述程序的几点说明:上述程序的计算结果精确到小数点后六位;上述程序运用了sin的泰勒展开式 sin x=x-x^3/3!+x^5/5! ...... ,程序中将sin泰勒公式中的每一项拆成了分子,分母以及每一项前的符号这三项,以便于每一项的累加

C语言三角函数求值,

math.h里的三角函数用的单位是弧度,你貌似错在这里。 答案补充 Example

/* SINCOS.C: This program displays the sine, hyperbolic

* sine, cosine, and hyperbolic cosine of pi / 2.

*/

#include math.h

#include stdio.h

void main( void )

{

double pi = 3.1415926535;

double x, y;

x = pi / 2;

y = sin( x );

printf( "sin( %f ) = %fn", x, y );

y = sinh( x );

printf( "sinh( %f ) = %fn",x, y );

y = cos( x );

printf( "cos( %f ) = %fn", x, y );

y = cosh( x );

printf( "cosh( %f ) = %fn",x, y );

} 答案补充 Output

sin( 1.570796 ) = 1.000000

sinh( 1.570796 ) = 2.301299

cos( 1.570796 ) = 0.000000

cosh( 1.570796 ) = 2.509178

Parameter

x

Angle in radians

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。