atanh, atanhf, atanhl
来自 cppreference.cn
定义于头文件 <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 起) |
1-3) 计算 arg 的反双曲正切。
4) 类型泛型宏:如果参数类型为 long double,则调用
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)); // 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 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: 待定)
- 7.25 类型通用数学 <tgmath.h> (p: TBD)
- F.10.2.3 atanh 函数 (p: 待定)
- 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 函数 (p: 221-222)
- 7.22 类型通用数学 <tgmath.h> (p: 335-337)
- F.9.2.3 atanh 函数 (p: 457)
[编辑] 参阅
(C99)(C99)(C99) |
计算反双曲正弦 (arsinh(x)) (函数) |
(C99)(C99)(C99) |
计算反双曲余弦 (arcosh(x)) (函数) |
(C99)(C99) |
计算双曲正切 (tanh(x)) (函数) |
(C99)(C99)(C99) |
计算复反双曲正切 (函数) |
C++ 文档 用于 atanh
|
[编辑] 外部链接
Weisstein, Eric W. "反双曲正切。" 来自 MathWorld — Wolfram Web 资源。 |