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

Inhaltsverzeichnis

Parameter

arg - Fließkommawert, der einen hyperbolischen Winkel darstellt

Rückgabewert

If no errors occur, the hyperbolic tangent of arg ( tanh(arg) , or
e arg
-e -arg
e arg
+e -arg
) is returned.

Wenn ein Bereichsfehler aufgrund von Unterlauf auftritt, wird das korrekte Ergebnis (nach Rundung) 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 ±0 zurückgegeben.
  • Wenn das Argument ±∞ ist, wird ±1 zurückgegeben.
  • Wenn das Argument NaN ist, wird NaN zurückgegeben.

Hinweise

POSIX spezifiziert , dass im Fall eines Unterlaufs arg unverändert zurückgegeben wird, und falls dies nicht unterstützt wird, ein implementierungsdefinierter Wert nicht größer als DBL_MIN , FLT_MIN , und LDBL_MIN zurückgegeben wird.

Beispiel

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

Ausgabe:

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

Referenzen

  • C23-Standard (ISO/IEC 9899:2024):
  • 7.12.5.6 Die tanh-Funktionen (S: TBD)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: TBD)
  • F.10.2.6 Die tanh-Funktionen (S: TBD)
  • C17-Standard (ISO/IEC 9899:2018):
  • 7.12.5.6 Die tanh-Funktionen (S.: TBD)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S.: TBD)
  • F.10.2.6 Die tanh-Funktionen (S.: TBD)
  • C11-Standard (ISO/IEC 9899:2011):
  • 7.12.5.6 Die tanh-Funktionen (S: 242)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: 373-375)
  • F.10.2.6 Die tanh-Funktionen (S: 520)
  • C99-Standard (ISO/IEC 9899:1999):
  • 7.12.5.6 Die tanh-Funktionen (S. 222-223)
  • 7.22 Typgenerische Mathematik <tgmath.h> (S. 335-337)
  • F.9.2.6 Die tanh-Funktionen (S. 457)
  • C89/C90 Standard (ISO/IEC 9899:1990):
  • 4.5.3.3 Die tanh-Funktion

Siehe auch

(C99) (C99)
berechnet den hyperbolischen Sinus ( sinh(x) )
(Funktion)
(C99) (C99)
berechnet den hyperbolischen Kosinus ( cosh(x) )
(Funktion)
(C99) (C99) (C99)
berechnet den Areatangens Hyperbolicus ( artanh(x) )
(Funktion)
(C99) (C99) (C99)
berechnet den komplexen hyperbolischen Tangens
(Funktion)