cosh() 函数原型
double cosh(double x)
cosh() 函数接受一个参数(弧度制的角度),并以 double
类型返回该角度的双曲余弦值。
cosh() 函数定义在 math.h 头文件中。
为了计算 long double 或 float 类型的数字的双曲余弦值,您可以使用以下原型。
long double coshl( long double arg); float coshf( float arg);
示例:C cosh()
#include <stdio.h>
#include <math.h>
int main ()
{
double x, result;
x = 0.5;
result = cosh(x);
printf("Hyperbolic cosine of %lf (in radians) = %lf\n", x, result);
x = -0.5;
result = cosh(x);
printf("Hyperbolic cosine of %lf (in radians) = %lf\n", x, result);
x = 0;
result = cosh(x);
printf("Hyperbolic cosine of %lf (in radians) = %lf\n", x, result);
x = 1.5;
result = cosh(x);
printf("Hyperbolic cosine of %lf (in radians) = %lf\n", x, result);
return 0;
}
输出
Hyperbolic cosine of 0.500000 (in radians) = 1.127626 Hyperbolic cosine of -0.500000 (in radians) = 1.127626 Hyperbolic cosine of 0.000000 (in radians) = 1.000000 Hyperbolic cosine of 1.500000 (in radians) = 2.352410