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
Défini dans l'en-tête <math.h>
float coshf ( float arg ) ;
(1) (depuis C99)
double cosh ( double arg ) ;
(2)
long double coshl ( long double arg ) ;
(3) (depuis C99)
Défini dans l'en-tête <tgmath.h>
#define cosh( arg )
(4) (depuis C99)
1-3) Calcule le cosinus hyperbolique de arg .
4) Macro générique de type : Si l'argument a le type long double , coshl est appelé. Sinon, si l'argument a un type entier ou le type double , cosh est appelé. Sinon, coshf est appelé. Si l'argument est complexe, alors la macro appelle la fonction complexe correspondante ( ccoshf , ccosh , ccoshl ).

Table des matières

Paramètres

arg - valeur en virgule flottante représentant un angle hyperbolique

Valeur de retour

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

Si une erreur de plage due à un dépassement de capacité se produit, +HUGE_VAL , +HUGE_VALF , ou +HUGE_VALL est renvoyé.

Gestion des erreurs

Les erreurs sont signalées comme spécifié dans math_errhandling .

Si l'implémentation prend en charge l'arithmétique à virgule flottante IEEE (IEC 60559),

  • si l'argument est ±0, 1 est retourné
  • si l'argument est ±∞, +∞ est retourné
  • si l'argument est NaN, NaN est retourné

Notes

Pour le type compatible IEEE double , si |arg| > 710.5 , alors cosh(arg) provoque un dépassement de capacité.

Exemple

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

Sortie possible :

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

Références

  • Norme C23 (ISO/CEI 9899:2024) :
  • 7.12.5.4 Les fonctions cosh (p: TBD)
  • 7.25 Mathématiques génériques de type <tgmath.h> (p: TBD)
  • F.10.2.4 Les fonctions cosh (p: TBD)
  • Norme C17 (ISO/CEI 9899:2018) :
  • 7.12.5.4 Les fonctions cosh (p: 176)
  • 7.25 Mathématiques génériques <tgmath.h> (p: 272-273)
  • F.10.2.4 Les fonctions cosh (p: 379)
  • Norme C11 (ISO/IEC 9899:2011) :
  • 7.12.5.4 Les fonctions cosh (p: 241)
  • 7.25 Mathématiques génériques de type <tgmath.h> (p: 373-375)
  • F.10.2.4 Les fonctions cosh (p: 520)
  • Norme C99 (ISO/CEI 9899:1999) :
  • 7.12.5.4 Les fonctions cosh (p. 222)
  • 7.22 Mathématiques génériques de type <tgmath.h> (p. 335-337)
  • F.9.2.4 Les fonctions cosh (p. 457)
  • Norme C89/C90 (ISO/IEC 9899:1990) :
  • 4.5.3.1 La fonction cosh

Voir aussi

(C99) (C99)
calcule le sinus hyperbolique ( sinh(x) )
(fonction)
(C99) (C99)
calcule la tangente hyperbolique ( tanh(x) )
(fonction)
(C99) (C99) (C99)
calcule le cosinus hyperbolique inverse ( arcosh(x) )
(fonction)
(C99) (C99) (C99)
calcule le cosinus hyperbolique complexe
(fonction)