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

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 tangent of arg ( tanh(arg) , or
e arg
-e -arg
e arg
+e -arg
) is returned.

Si une erreur de plage se produit en raison d'un dépassement inférieur, le résultat correct (après arrondi) est retourné.

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, ±0 est retourné.
  • Si l'argument est ±∞, ±1 est retourné.
  • Si l'argument est NaN, NaN est retourné.

Notes

POSIX spécifie qu'en cas de dépassement inférieur, arg est retourné inchangé, et si cela n'est pas pris en charge, une valeur définie par l'implémentation non supérieure à DBL_MIN , FLT_MIN , et LDBL_MIN est retournée.

Exemple

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

Sortie :

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

Références

  • Norme C23 (ISO/CEI 9899:2024) :
  • 7.12.5.6 Les fonctions tanh (p: TBD)
  • 7.25 Mathématiques génériques de type <tgmath.h> (p: TBD)
  • F.10.2.6 Les fonctions tanh (p: TBD)
  • Norme C17 (ISO/CEI 9899:2018) :
  • 7.12.5.6 Les fonctions tanh (p: TBD)
  • 7.25 Mathématiques génériques de type <tgmath.h> (p: TBD)
  • F.10.2.6 Les fonctions tanh (p: TBD)
  • Norme C11 (ISO/CEI 9899:2011) :
  • 7.12.5.6 Les fonctions tanh (p: 242)
  • 7.25 Mathématiques génériques de type <tgmath.h> (p: 373-375)
  • F.10.2.6 Les fonctions tanh (p: 520)
  • Norme C99 (ISO/CEI 9899:1999) :
  • 7.12.5.6 Les fonctions tanh (p. 222-223)
  • 7.22 Mathématiques génériques de type <tgmath.h> (p. 335-337)
  • F.9.2.6 Les fonctions tanh (p. 457)
  • Norme C89/C90 (ISO/CEI 9899:1990) :
  • 4.5.3.3 La fonction tanh

Voir aussi

(C99) (C99)
calcule le sinus hyperbolique ( sinh(x) )
(fonction)
(C99) (C99)
calcule le cosinus hyperbolique ( cosh(x) )
(fonction)
(C99) (C99) (C99)
calcule la tangente hyperbolique inverse ( artanh(x) )
(fonction)
(C99) (C99) (C99)
calcule la tangente hyperbolique complexe
(fonction)