function
<cmath> <ctgmath>

tanh

double tanh (double x);
     double tanh  (double x);
      float tanhf (float x);
long double tanhl (long double x);
     double tanh (double x);
      float tanh (float x);
long double tanh (long double x);
     double tanh (T x);           // additional overloads for integral types
Compute hyperbolic tangent
Returns the hyperbolic tangent of x radians.

Header <tgmath.h> provides a type-generic macro version of this function.
This function is overloaded in <complex> and <valarray> (see complex tanh and valarray tanh).
Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).

This function is also overloaded in <complex> and <valarray> (see complex tanh and valarray tanh).

Parameters

x
Value representing an angle, expressed in radians.

Return Value

Hyperbolic tangent of x.

Example

1
2
3
4
5
6
7
8
9
10
11
12
/* tanh example */
#include <stdio.h>      /* printf */
#include <math.h>       /* tanh, log */

int main ()
{
  double param, result;
  param = log(2.0);
  result = tanh (param);
  printf ("The hyperbolic tangent of %f is %f.\n", param, result);
  return 0;
}


Output:

The hyperbolic tangent of 0.693147 is 0.600000.

See also