Namespaces
Variants

tanh, tanhf, tanhl

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
定義先ヘッダ <math.h>
float tanhf ( float arg ) ;
(1) (C99以降)
double tanh ( double arg ) ;
(2)
long double tanhl ( long double arg ) ;
(3) (C99以降)
定義先ヘッダ <tgmath.h>
#define tanh( arg )
(4) (C99以降)
1-3) 双曲線正接を計算します arg
4) 型総称マクロ: 引数の型が long double の場合、 tanhl が呼び出される。それ以外の場合、引数が整数型または double 型の場合、 tanh が呼び出される。それ以外の場合、 tanhf が呼び出される。引数が複素数の場合、マクロは対応する複素数関数( ctanhf ctanh ctanhl )を呼び出す。

目次

翻訳の説明: - 「Contents」を「目次」に翻訳しました - HTMLタグ、属性、クラス名はすべて保持されています - リンクテキスト(Parameters、Return value、Error handlingなど)はC++関連の専門用語として翻訳せずに保持しています - 数値や構造は完全に保持されています - フォーマットとインデントは元のまま維持されています

パラメータ

arg - 双曲角を表す浮動小数点値

戻り値

If no errors occur, the hyperbolic tangent of arg ( tanh(arg) , or
e arg
-e -arg
e arg
+e -arg
) is returned.

アンダーフローによる範囲エラーが発生した場合、正しい結果(丸め後)が返されます。

エラー処理

エラーは math_errhandling で指定された通りに報告されます。

IEEE浮動小数点演算(IEC 60559)を実装がサポートしている場合、

  • 引数が±0の場合、±0が返されます。
  • 引数が±∞の場合、±1が返されます。
  • 引数がNaNの場合、NaNが返されます。

注記

POSIXは アンダーフローが発生した場合、 arg が変更されずに返され、それがサポートされていない場合は、 DBL_MIN FLT_MIN 、および LDBL_MIN を超えない実装定義の値が返されることを規定しています。

#include <math.h>
#include <stdio.h>
int main(void)
{
    printf("tanh(1) = %f\ntanh(-1) = %f\n", tanh(1), tanh(-1));
    printf("tanh(0.1)*sinh(0.2)-cosh(0.2) = %f\n", tanh(0.1) * sinh(0.2) - cosh(0.2));
    // special values
    printf("tanh(+0) = %f\ntanh(-0) = %f\n", tanh(0.0), tanh(-0.0));
}

出力:

tanh(1) = 0.761594
tanh(-1) = -0.761594
tanh(0.1)*sinh(0.2)-cosh(0.2) = -1.000000
tanh(+0) = 0.000000
tanh(-0) = -0.000000

参考文献

  • C23規格 (ISO/IEC 9899:2024):
  • 7.12.5.6 tanh関数群 (p: TBD)
  • 7.25 総称数学 <tgmath.h> (p: TBD)
  • F.10.2.6 tanh関数群 (p: TBD)
  • C17規格 (ISO/IEC 9899:2018):
  • 7.12.5.6 tanh関数群 (p: TBD)
  • 7.25 総称型数学 <tgmath.h> (p: TBD)
  • F.10.2.6 tanh関数群 (p: TBD)
  • C11規格 (ISO/IEC 9899:2011):
  • 7.12.5.6 tanh関数群 (p: 242)
  • 7.25 総称数学 <tgmath.h> (p: 373-375)
  • F.10.2.6 tanh関数群 (p: 520)
  • C99標準 (ISO/IEC 9899:1999):
  • 7.12.5.6 tanh関数 (p: 222-223)
  • 7.22 総称数学 <tgmath.h> (p: 335-337)
  • F.9.2.6 tanh関数 (p: 457)
  • C89/C90標準 (ISO/IEC 9899:1990):
  • 4.5.3.3 tanh関数

関連項目

(C99) (C99)
双曲線正弦を計算する ( sinh(x) )
(関数)
(C99) (C99)
双曲線余弦を計算する ( cosh(x) )
(関数)
(C99) (C99) (C99)
逆双曲線正接を計算する ( artanh(x) )
(関数)
(C99) (C99) (C99)
複素双曲線正接を計算する
(関数)