C++官网参考链接:https://cplusplus.com/reference/cmath/acosh/
函数
<cmath> <ctgmath>
acosh
C99
double acosh (double x);
float acoshf (float x);
long double acoshl (long double x);
C++11
double acosh (double x);
float acosh (float x);
long double acosh (long double x);
double acosh (T x); // additional overloads for integral types
计算反双曲余弦
返回非负x的反双曲余弦。
反双曲余弦是双曲余弦(hyperbolic cosine)的逆运算。
C99
头文件<tgmath.h>提供了该函数的泛型类型的宏版本。
C++11
在此头文件(<cmath>)中为整型(integral types)提供了额外的重载:这些重载在计算之前有效地将x转换为double类型(定义T为任何整型(integral type))。
此函数在<complex>中也被重载(参见complex acosh)。
形参
x
计算反双曲余弦的值。
如果实参小于1,则发生定义域错误。
返回值
非负x的反双曲余弦,在区间[0,+∞]内。
注意,这个值的负数也是一个有效的x的反双曲余弦
如果发生定义域错误:
—math_errhandling具有MATH_ERRNO集合:全局变量errno设置为EDOM。
—math_errhandling具有MATH_ERREXCEPT集合:将引发FE_INVALID。
用例
/* acosh example */
#include <stdio.h> /* printf */
#include <math.h> /* acosh, exp, sinh */
int main ()
{
double param, result;
param = exp(2) - sinh(2);
result = acosh(param) ;
printf ("The area hyperbolic cosine of %f is %f radians.\n", param, result);
return 0;
}
输出: