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 )를 호출합니다.

목차

매개변수

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 The tanh functions (p: TBD)
  • 7.25 Type-generic math <tgmath.h> (p: TBD)
  • F.10.2.6 The tanh functions (p: TBD)
  • C17 표준 (ISO/IEC 9899:2018):
  • 7.12.5.6 The tanh functions (p: TBD)
  • 7.25 Type-generic math <tgmath.h> (p: TBD)
  • F.10.2.6 The tanh functions (p: TBD)
  • C11 표준 (ISO/IEC 9899:2011):
  • 7.12.5.6 The tanh functions (p: 242)
  • 7.25 Type-generic math <tgmath.h> (p: 373-375)
  • F.10.2.6 The tanh functions (p: 520)
  • C99 표준 (ISO/IEC 9899:1999):
  • 7.12.5.6 The tanh functions (p: 222-223)
  • 7.22 Type-generic math <tgmath.h> (p: 335-337)
  • F.9.2.6 The tanh functions (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)
복소수 쌍곡탄젠트를 계산함
(함수)