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
Definiert im Header <math.h>
float coshf ( float arg ) ;
(1) (seit C99)
double cosh ( double arg ) ;
(2)
long double coshl ( long double arg ) ;
(3) (seit C99)
Definiert im Header <tgmath.h>
#define cosh( arg )
(4) (seit C99)
1-3) Berechnet den hyperbolischen Kosinus von arg .
4) Typgenerisches Makro: Wenn das Argument den Typ long double hat, wird coshl aufgerufen. Andernfalls, wenn das Argument einen Ganzzahltyp oder den Typ double hat, wird cosh aufgerufen. Andernfalls wird coshf aufgerufen. Wenn das Argument komplex ist, ruft das Makro die entsprechende komplexe Funktion auf ( ccoshf , ccosh , ccoshl ).

Inhaltsverzeichnis

Parameter

arg - Fließkommawert, der einen hyperbolischen Winkel darstellt

Rückgabewert

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

Wenn ein Bereichsfehler aufgrund von Überlauf auftritt, +HUGE_VAL , +HUGE_VALF , oder +HUGE_VALL wird zurückgegeben.

Fehlerbehandlung

Fehler werden gemeldet, wie in math_errhandling festgelegt.

Wenn die Implementierung IEEE-Gleitkommaarithmetik (IEC 60559) unterstützt,

  • wenn das Argument ±0 ist, wird 1 zurückgegeben
  • Wenn das Argument ±∞ ist, wird +∞ zurückgegeben
  • wenn das Argument NaN ist, wird NaN zurückgegeben

Hinweise

Für den IEEE-kompatiblen Typ double , wenn |arg| > 710.5 , dann cosh(arg) führt zu einem Überlauf.

Beispiel

#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");
}

Mögliche Ausgabe:

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

Referenzen

  • C23-Standard (ISO/IEC 9899:2024):
  • 7.12.5.4 Die cosh-Funktionen (S: TBD)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: TBD)
  • F.10.2.4 Die cosh-Funktionen (S: TBD)
  • C17-Standard (ISO/IEC 9899:2018):
  • 7.12.5.4 Die cosh-Funktionen (S. 176)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S. 272-273)
  • F.10.2.4 Die cosh-Funktionen (S. 379)
  • C11-Standard (ISO/IEC 9899:2011):
  • 7.12.5.4 Die cosh-Funktionen (S: 241)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: 373-375)
  • F.10.2.4 Die cosh-Funktionen (S: 520)
  • C99-Standard (ISO/IEC 9899:1999):
  • 7.12.5.4 Die cosh-Funktionen (S. 222)
  • 7.22 Typgenerische Mathematik <tgmath.h> (S. 335-337)
  • F.9.2.4 Die cosh-Funktionen (S. 457)
  • C89/C90 Standard (ISO/IEC 9899:1990):
  • 4.5.3.1 Die cosh-Funktion

Siehe auch

(C99) (C99)
berechnet den hyperbolischen Sinus ( sinh(x) )
(Funktion)
(C99) (C99)
berechnet den hyperbolischen Tangens ( tanh(x) )
(Funktion)
(C99) (C99) (C99)
berechnet den Areakosinus Hyperbolicus ( arcosh(x) )
(Funktion)
(C99) (C99) (C99)
berechnet den komplexen hyperbolischen Kosinus
(Funktion)