tanh Function

Calculates the hyperbolic tangent function of a double precision floating-point value.

Include

<math.h>

Prototype

double tanh(double x);

Argument

x
value for which to return the hyperbolic tangent

Return Value

Returns the hyperbolic tangent of x in the ranges of -1 to 1 inclusive.

Remarks

No domain or range error will occur.

Example

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

int main(void)
{
  double x, y;

  x = -1.0;
  y = tanh(x);
  printf("The hyperbolic tangent of %f is %f\n", x, y);

  x = 2.0;
  y = tanh(x);
  printf("The hyperbolic tangent of %f is %f\n", x, y);
}

Example Output

The hyperbolic tangent of -1.000000 is -0.761594
The hyperbolic tangent of 2.000000 is 0.964028