atanh, atanhf, atanhl
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<math.h>
|
||
|
float
atanhf
(
float
arg
)
;
|
(1) | (C99 起) |
|
double
atanh
(
double
arg
)
;
|
(2) | (C99 起) |
|
long
double
atanhl
(
long
double
arg
)
;
|
(3) | (C99 起) |
|
定义于头文件
<tgmath.h>
|
||
|
#define atanh( arg )
|
(4) | (C99 起) |
atanhl
。否则,若参数为整数类型或
double
类型,则调用
atanh
。否则调用
atanhf
。若参数为复数,则宏调用对应的复数函数(
catanhf
、
catanh
、
catanhl
)。
目录 |
参数
| arg | - | 表示双曲扇形面积的浮点数值 |
返回值
如果未发生错误,则返回
arg
的反双曲正切值(
tanh
-1
(arg)
或
artanh(arg)
)。
如果发生定义域错误,则返回一个由实现定义的值(在支持 NaN 的情况下返回 NaN)。
如果发生极点错误,将返回
±
HUGE_VAL
、
±HUGE_VALF
或
±HUGE_VALL
(保留正确的符号)。
如果由于下溢发生范围错误,将返回正确结果(舍入后)。
错误处理
错误报告方式遵循
math_errhandling
中的规范。
如果参数不在区间
[
-
1
,
+
1
]
内,则会发生范围错误。
如果参数为 ±1,将出现极点错误。
如果实现支持 IEEE 浮点算术 (IEC 60559),
- 若参数为 ±0,则不作修改直接返回。
- 若参数为 ±1,则返回 ±∞ 并引发 FE_DIVBYZERO 。
- 若 |arg|>1 ,则返回 NaN 并引发 FE_INVALID 。
- 若参数为 NaN,则返回 NaN。
注释
尽管C标准将此函数命名为"反双曲正切",但双曲函数的反函数实际上是面积函数。它们的参数是双曲扇形的面积,而非弧长。正确的名称应为"反双曲正切"(POSIX使用)或"面积双曲正切"。
POSIX 规范 规定,在下溢情况下,将原样返回 arg ;若不支持此行为,则返回不大于 DBL_MIN 、 FLT_MIN 和 LDBL_MIN 的实现定义值。
示例
#include <errno.h> #include <fenv.h> #include <float.h> #include <math.h> #include <stdio.h> // #pragma STDC FENV_ACCESS ON int main(void) { printf("atanh(0) = %f\natanh(-0) = %f\n", atanh(0), atanh(-0.0)); printf("atanh(0.9) = %f\n", atanh(0.9)); // 错误处理 errno = 0; feclearexcept(FE_ALL_EXCEPT); printf("atanh(-1) = %f\n", atanh(-1)); if (errno == ERANGE) perror(" errno == ERANGE"); if (fetestexcept(FE_DIVBYZERO)) puts(" FE_DIVBYZERO raised"); }
可能的输出:
atanh(0) = 0.000000
atanh(-0) = -0.000000
atanh(0.9) = 1.472219
atanh(-1) = -inf
errno == ERANGE: 数值结果超出范围
FE_DIVBYZERO raised
参考文献
- C23 标准 (ISO/IEC 9899:2024):
-
- 7.12.5.3 atanh 函数集 (p: 241)
-
- 7.25 泛型数学 <tgmath.h> (p: 373-375)
-
- F.10.2.3 atanh 函数集 (p: 520)
- C17 标准 (ISO/IEC 9899:2018):
-
- 7.12.5.3 atanh 函数 (p: TBD)
-
- 7.25 类型通用数学 <tgmath.h> (p: TBD)
-
- F.10.2.3 atanh 函数 (p: TBD)
- C11 标准 (ISO/IEC 9899:2011):
-
- 7.12.5.3 atanh 函数 (p: 241)
-
- 7.25 类型泛型数学 <tgmath.h> (p: 373-375)
-
- F.10.2.3 atanh 函数 (p: 520)
- C99标准(ISO/IEC 9899:1999):
-
- 7.12.5.3 atanh函数(第221-222页)
-
- 7.22 泛型数学 <tgmath.h>(第335-337页)
-
- F.9.2.3 atanh函数(第457页)
参考
|
(C99)
(C99)
(C99)
|
计算反双曲正弦(
\({\small\operatorname{arsinh}{x} }\)
arsinh(x)
)
(函数) |
|
(C99)
(C99)
(C99)
|
计算反双曲余弦(
\({\small\operatorname{arcosh}{x} }\)
arcosh(x)
)
(函数) |
|
(C99)
(C99)
|
计算双曲正切(
\({\small\tanh{x} }\)
tanh(x)
)
(函数) |
|
(C99)
(C99)
(C99)
|
计算复数反双曲正切
(函数) |
|
C++ 文档
关于
atanh
|
|
外部链接
| 韦斯坦,埃里克·W。《反双曲正切函数》 摘自 MathWorld —— 一个 Wolfram 网络资源。 |