cosh, coshf, coshl
From 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)を呼び出します。目次 |
[edit] パラメータ
| arg | - | 双曲線角度を表す浮動小数点数 |
[edit] 戻り値
エラーが発生しない場合、arg の双曲線余弦(cosh(arg)、または | earg +e-arg |
| 2 |
オーバーフローによる範囲エラーが発生した場合、+HUGE_VAL、+HUGE_VALF、または +HUGE_VALL が返されます。
[edit] エラー処理
エラーは math_errhandling で指定されたとおりに報告されます。
実装がIEEE浮動小数点算術 (IEC 60559) をサポートしている場合、
- 引数が ±0 の場合、1 を返します。
- 引数が ±∞ の場合、+∞ を返します。
- 引数が NaN の場合、NaN を返します。
[edit] 注記
IEEE 互換の double 型の場合、|arg| > 710.5 であると、cosh(arg) はオーバーフローします。
[edit] 例
このコードを実行
#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[edit] 参照
- C23標準 (ISO/IEC 9899:2024)
- 7.12.5.4 The cosh functions (p: TBD)
- 7.25 Type-generic math <tgmath.h> (p: TBD)
- F.10.2.4 The cosh functions (p: TBD)
- C17標準 (ISO/IEC 9899:2018)
- 7.12.5.4 The cosh functions (p: 176)
- 7.25 型総称数学関数 <tgmath.h> (p: 272-273)
- F.10.2.4 The cosh functions (p: 379)
- C11標準 (ISO/IEC 9899:2011)
- 7.12.5.4 The cosh functions (p: 241)
- 7.25 型総称数学関数 <tgmath.h> (p: 373-375)
- F.10.2.4 The cosh functions (p: 520)
- C99標準 (ISO/IEC 9899:1999)
- 7.12.5.4 The cosh functions (p: 222)
- 7.22 型総称数学関数 <tgmath.h> (p: 335-337)
- F.9.2.4 The cosh functions (p: 457)
- C89/C90標準 (ISO/IEC 9899:1990)
- 4.5.3.1 The cosh function
[edit] 関連項目
| (C99)(C99) |
双曲線サインを計算する (sinh(x)) (関数) |
| (C99)(C99) |
双曲線タンジェントを計算する (tanh(x)) (関数) |
| (C99)(C99)(C99) |
逆双曲線コサインを計算する (arcosh(x)) (関数) |
| (C99)(C99)(C99) |
複素双曲線コサインを計算する (関数) |
| C++ ドキュメント (cosh)
| |