C++官网参考链接:https://cplusplus.com/reference/cmath/atanh/
函数
<cmath> <ctgmath>
atanh
C99
double atanh (double x);
float atanhf (float x);
long double atanhl (long double x);
C++11
double atanh (double x);
float atanh (float x);
long double atanh (long double x);
double atanh( T x ); // additional overloads for integral types
计算反双曲正切
返回反双曲正切atanh(x)。
反双曲正切是双曲正切(hyperbolic tangent)的逆运算。
C99
头文件<tgmath.h>提供了该函数的类型泛型宏版本。
C++11
在此头文件(<cmath>)中为整型(integral types)提供了额外的重载:这些重载在计算之前有效地将x转换为double类型(定义为T为任何整型(integral type))。
此函数在<complex>中也被重载(参见complex atanh)。
参数
x
在区间[-1,+1]内计算其反双曲正切的值。
如果参数超出了这个区间,就会发生域错误。
对于-1和+1的值,可能会出现极点错误。
返回值
反双曲正切atanh(x)。
如果发生域错误:
—math_errhandling设置了MATH_ERRNO:全局变量errno设置为EDOM。
—math_errhandling设置了MATH_ERREXCEPT:将引发FE_INVALID。
如果发生极点错误:
—math_errhandling设置了MATH_ERRNO:全局变量errno设置为ERANGE。
—math_errhandling设置了MATH_ERREXCEPT:引发FE_DIVBYZERO。
用例
/* atanh example */
#include <stdio.h> /* printf */
#include <math.h> /* tanh, atanh */
int main ()
{
double param, result;
param = tanh(1);
result = atanh(param) ;
printf ("The area hyperbolic tangent of %f is %f.\n", param, result);
return 0;
}
输出:
另请参考
tanh Compute hyperbolic tangent (function) (计算双曲正切(函数))
asinh Compute area hyperbolic sine (function) (计算反双曲正弦(函数))
acosh Compute area hyperbolic cosine (function) (计算反双曲余弦(函数))