atanh, atanhf, atanhl
来自 cppreference.cn
定义于头文件 <math.h> |
||
float atanhf( float arg ); |
(1) | (since C99) |
double atanh( double arg ); |
(2) | (since C99) |
long double atanhl( long double arg ); |
(3) | (since C99) |
定义于头文件 <tgmath.h> |
||
#define atanh( arg ) |
(4) | (since C99) |
1-3) 计算 arg 的反双曲正切。
4) 类型泛型宏:如果参数类型为 long double,则调用
atanhl
。否则,如果参数具有整数类型或类型 double,则调用 atanh
。否则,调用 atanhf
。如果参数是复数,则宏调用相应的复数函数(catanhf、catanh、catanhl)。目录 |
[编辑] 参数
arg | - | 浮点值,表示双曲扇形的面积 |
[编辑] 返回值
如果没有错误发生,则返回 arg 的反双曲正切(tanh-1
(arg) 或 artanh(arg))。
如果发生域错误,则返回实现定义的值(如果支持则为 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 标准将此函数命名为 "arc hyperbolic tangent"(反双曲正切),但双曲函数的反函数是面积函数。它们的参数是双曲扇形的面积,而不是弧长。正确的名称是 "inverse hyperbolic tangent"(反双曲正切)(POSIX 使用)或 "area hyperbolic tangent"(面积双曲正切)。
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)); // error handling 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: Numerical result out of range FE_DIVBYZERO raised
[编辑] 参考
- C23 标准 (ISO/IEC 9899:2024)
- 7.12.5.3 The atanh functions (p: 241)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.2.3 The atanh functions (p: 520)
- C17 标准 (ISO/IEC 9899:2018)
- 7.12.5.3 The atanh functions (p: TBD)
- 7.25 Type-generic math <tgmath.h> (p: TBD)
- F.10.2.3 The atanh functions (p: TBD)
- C11 标准 (ISO/IEC 9899:2011)
- 7.12.5.3 The atanh functions (p: 241)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.2.3 The atanh functions (p: 520)
- C99 标准 (ISO/IEC 9899:1999)
- 7.12.5.3 The atanh functions (p: 221-222)
- 7.22 Type-generic math <tgmath.h> (p: 335-337)
- F.9.2.3 The atanh functions (p: 457)
[编辑] 参见
(C99)(C99)(C99) |
计算反双曲正弦 (arsinh(x)) (函数) |
(C99)(C99)(C99) |
计算反双曲余弦 (arcosh(x)) (函数) |
(C99)(C99) |
计算双曲正切 (tanh(x)) (函数) |
(C99)(C99)(C99) |
计算复数反双曲正切 (函数) |
C++ 文档 关于 atanh
|
[编辑] 外部链接
Weisstein, Eric W. "Inverse Hyperbolic Tangent." 来自 MathWorld — A Wolfram Web Resource. |