Namespaces
Variants

cosh, coshf, coshl

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 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 - 쌍곡선 각도를 나타내는 부동 소수점 값

반환값

If no errors occur, the hyperbolic cosine of arg ( cosh(arg) , or
e arg
+e -arg
2
) is returned.

오버플로로 인한 범위 오류가 발생하면, +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)));
    // 특수 값
    printf("cosh(+0) = %f\ncosh(-0) = %f\n", cosh(0.0), cosh(-0.0));
    // 오류 처리
    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