cosh, coshf, coshl
來自 cppreference.com
定義於標頭檔案 <math.h> |
||
float coshf( float arg ); |
(1) | (C99 起) |
double cosh( double arg ); |
(2) | |
long double coshl( long double arg ); |
(3) | (C99 起) |
定義於標頭檔案 <tgmath.h> |
||
#define cosh( arg ) |
(4) | (C99 起) |
1-3) 計算
arg
的雙曲餘弦。4) 型別泛型宏:如果引數型別為 long double,則呼叫
coshl
。否則,如果引數型別為整數型別或 double,則呼叫 cosh
。否則,呼叫 coshf
。如果引數是複數,則宏呼叫相應的複數函式(ccoshf、ccosh、ccoshl)。目錄 |
[編輯] 引數
arg | - | 表示雙曲角的浮點值 |
[編輯] 返回值
如果沒有發生錯誤,則返回arg
的雙曲餘弦(cosh(arg),或 earg +e-arg |
2 |
如果因溢位而發生範圍錯誤,則返回 +HUGE_VAL、+HUGE_VALF
或 +HUGE_VALL
。
[編輯] 錯誤處理
錯誤按 math_errhandling
中指定的方式報告。
如果實現支援 IEEE 浮點運算 (IEC 60559),
- 如果引數為 ±0,返回 1
- 如果引數為 ±∞,返回 +∞
- 如果引數為 NaN,返回 NaN
[編輯] 注意
對於相容 IEEE 的型別 double,如果 |arg| > 710.5,則 cosh(arg)
會溢位。
[編輯] 示例
執行此程式碼
#include <errno.h> #include <fenv.h> #include <math.h> #include <stdio.h> // #pragma STDC FENV_ACCESS ON int main(void) { printf("cosh(1) = %f\ncosh(-1)= %f\n", cosh(1), cosh(-1)); printf("log(sinh(1) + cosh(1))=%f\n", log(sinh(1) + cosh(1))); // special values printf("cosh(+0) = %f\ncosh(-0) = %f\n", cosh(0.0), cosh(-0.0)); // error handling errno = 0; feclearexcept(FE_ALL_EXCEPT); printf("cosh(710.5) = %f\n", cosh(710.5)); if (errno == ERANGE) perror(" errno == ERANGE"); if (fetestexcept(FE_OVERFLOW)) puts(" FE_OVERFLOW raised"); }
可能的輸出
cosh(1) = 1.543081 cosh(-1)= 1.543081 log(sinh(1) + cosh(1))=1.000000 cosh(+0) = 1.000000 cosh(-0) = 1.000000 cosh(710.5) = inf errno == ERANGE: Numerical result out of range FE_OVERFLOW raised
[編輯] 參考
- C23 標準 (ISO/IEC 9899:2024)
- 7.12.5.4 cosh 函式 (p: TBD)
- 7.25 型別通用數學 <tgmath.h> (p: TBD)
- F.10.2.4 cosh 函式 (p: TBD)
- C17 標準 (ISO/IEC 9899:2018)
- 7.12.5.4 cosh 函式 (p: 176)
- 7.25 型別通用數學 <tgmath.h> (p: 272-273)
- F.10.2.4 cosh 函式 (p: 379)
- C11 標準 (ISO/IEC 9899:2011)
- 7.12.5.4 cosh 函式 (p: 241)
- 7.25 型別通用數學 <tgmath.h> (p: 373-375)
- F.10.2.4 cosh 函式 (p: 520)
- C99 標準 (ISO/IEC 9899:1999)
- 7.12.5.4 cosh 函式 (p: 222)
- 7.22 型別通用數學 <tgmath.h> (p: 335-337)
- F.9.2.4 cosh 函式 (p: 457)
- C89/C90 標準 (ISO/IEC 9899:1990)
- 4.5.3.1 cosh 函式
[編輯] 另請參閱
(C99)(C99) |
計算雙曲正弦 (sinh(x)) (函式) |
(C99)(C99) |
計算雙曲正切 (tanh(x)) (函式) |
(C99)(C99)(C99) |
計算反雙曲餘弦 (arcosh(x)) (函式) |
(C99)(C99)(C99) |
計算復雙曲餘弦 (函式) |
C++ 文件 for cosh
|