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
计算反双曲正切
返回x的反双曲正切。
反双曲正切是双曲正切(hyperbolic tangent)的逆运算。
C99
头文件<tgmath.h>提供了该函数的泛型类型的宏版本。
C++11
在此头文件(<cmath>)中为整型(integral types)提供了额外的重载:这些重载在计算之前有效地将x转换为double类型(定义T为任何整型(integral type))。
此函数在<complex>中也被重载(参见complex atanh)。
形参
x
在区间[-1,+1]内计算其反双曲正切的值。
如果实参超出了这个区间,就会发生定义域错误。
对于-1和+1的值,可能会出现极点错误。
返回值
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;
}
输出: