atanh, atanhf, atanhl

< c‎ | numeric‎ | math
在标头 <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。若实参为复数,则调用对应的复函数(catanhfcatanhcatanhl)。

参数

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 标准命名此函数为“弧双曲正切”,但双曲函数的反函数是面积函数。其实参为双曲扇形的面积,而非弧。正确的名称为“反双曲正切”(POSIX 所用)或“面积双曲正切”。

POSIX 指定在下溢的情况下,返回不修改的 arg,而且若不支持,则返回不大于 DBL_MINFLT_MINLDBL_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: Numerical result out of range
    FE_DIVBYZERO raised

引用

  • C23 标准(ISO/IEC 9899:2024):
  • 7.12.5.3 The atanh functions (第 241 页)
  • 7.25 Type-generic math <tgmath.h> (第 373-375 页)
  • F.10.2.3 The atanh functions (第 520 页)
  • C17 标准(ISO/IEC 9899:2018):
  • 7.12.5.3 The atanh functions (第 TBD 页)
  • 7.25 Type-generic math <tgmath.h> (第 TBD 页)
  • F.10.2.3 The atanh functions (第 TBD 页)
  • C11 标准(ISO/IEC 9899:2011):
  • 7.12.5.3 The atanh functions (第 241 页)
  • 7.25 Type-generic math <tgmath.h> (第 373-375 页)
  • F.10.2.3 The atanh functions (第 520 页)
  • C99 标准(ISO/IEC 9899:1999):
  • 7.12.5.3 The atanh functions (第 221-222 页)
  • 7.22 Type-generic math <tgmath.h> (第 335-337 页)
  • F.9.2.3 The atanh functions (第 457 页)

参阅

(C99)(C99)(C99)
计算反双曲正弦(arsinh(x)
(函数)
(C99)(C99)(C99)
计算反双曲余弦(arcosh(x)
(函数)
(C99)(C99)
计算双曲正切(tanh(x)
(函数)
(C99)(C99)(C99)
计算复数反双曲正切
(函数)

外部链接

Weisstein, Eric W. “反双曲正切。”来自 MathWorld--A Wolfram Web Resource。