C语言中计算正弦的相关函数总结
C语言sin()函数:正弦函数 #include <math.h> sin() 函数用来求给定值的正弦值,其原型为: double sin(double x); 【参数】给定的值(弧度)。 【返回值】返回-1 至1 之间的计算结果。 弧度与角度的关系为: 使用 rtod( ) 函数可以将弧度值转换为角度值。 注意,使用 GCC 编译时请加入-lm。 举例如下: #include <stdio.h> #include <math.h> int main () { printf ("7 ^ 3 = %fn",pow (7.0,3.0) ); printf ("4.73 ^ 12 = %fn",pow (4.73,12.0) ); printf ("32.01 ^ 1.54 = %fn",pow (32.01,1.54) ); return 0; } 输出结果: 7 ^ 3 = 343.000000 4.73 ^ 12 = 125410439.217423 32.01 ^ 1.54 = 208.036691 C语言sinh()函数:双曲正玄函数 #include <math.h> sinh() 用来求双曲正弦值,其原型为: double sinh(double x); 【参数】x 为即将被计算的值。 双曲正弦的定义为:(exp(x)-exp(-x))/2,即 双曲线示意图如下: 【返回值】返回参数x 的双曲正玄值。 如果返回值过大,将返回 HUGE_VAL、或 HUGE_VALF、或 HUGE_VALL,正负号与 x 相同,并导致一个范围溢出错误,将全局变量 errno 设置为 ERANGE。 注意,使用 GCC 编译时请加入-lm。 请看下面的代码: #include <math.h> main(){ double answer = sinh(0.5); printf("sinh(0.5) = %fn",answer); } 输出结果: sinh(0.5) = 0.521095 C语言asin()函数:求反正弦的值(以弧度表示) #include <math.h> 定义函数: double asin (double x) 函数说明:asin()用来计算参数x 的反正弦值,然后将结果返回。参数x 范围为-1 至1 之间,超过此范围则会失败。 返回值:返回-PI/2 之PI/2 之间的计算结果。 错误代码:EDOM 参数x 超出范围。 注意,使用 GCC 编译时请加入-lm。 范例 #include <math.h> main(){ double angle; angle = asin (0.5); printf("angle = %fn",angle); } 执行 angle = 0.523599 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |