tanh, tanhf, tanhl

Calculates the hyperbolic tangent.

Syntax

double tanh( double x );
float tanhf( float x );
long double tanhl( long double x );
float tanh( float x );  // C++ only
long double tanh( long double x );  // C++ only

Parameters

x
Angle in radians.

Return value

The tanh functions return the hyperbolic tangent of x. There is no error return.

Input SEH Exception Matherr Exception
± QNAN,IND none _DOMAIN

Remarks

Because C++ allows overloading, you can call overloads of tanh that take and return float or long double values. In a C program, tanh always takes and returns double.

Requirements

Routine Required header (C) Required header (C)
tanh, tanhf, tanhl <math.h> <cmath> or <math.h>

For additional compatibility information, see Compatibility.

Example

// crt_tanh.c
// This program displays the tangent of pi / 4
// and the hyperbolic tangent of the result.
// Compile by using: cl crt_tanh.c

#include <math.h>
#include <stdio.h>

int main( void )
{
   double pi = 3.1415926535;
   double x, y;

   x = tan( pi / 4 );
   y = tanh( x );
   printf( "tan( %f ) = %f\n", pi/4, x );
   printf( "tanh( %f ) = %f\n", x, y );
}
tan( 0.785398 ) = 1.000000
tanh( 1.000000 ) = 0.761594

See also

Floating-Point Support
acosh, acoshf, acoshl
asinh, asinhf, asinhl
atanh, atanhf, atanhl
cosh, coshf, coshl
sinh, sinhf, sinhl