atanh, atanhf, atanhl
來自 cppreference.com
定義於標頭檔案 <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 資源。 |