Format
#include <math.h> double tanh(double x); float tanhf(float x); long double tanhl(long double x);float tanh(float x);
long double tanh(long double x);
Language Level: ANSI, POSIX, XPG4
tanh calculates the hyperbolic tangent of x, where x
is expressed in radians.
Note:
C++ prototypes
float tanh(float x); long double tanh(long double x);
are disabled when you compile using the lang(compatmath) option.
Return Value
tanh returns the value of the hyperbolic tangent of x.
The result of tanh cannot have a range error.
Example
This example computes x as the hyperbolic
tangent of pi/4.
#include <math.h> #include <stdio.h>
int main(void)
{
double pi, x;
pi = 3.1415926; x = tanh(pi/4);
printf("tanh( %lf ) = %lf\n", pi/4, x);
return 0;
/****************************************
The output should be:
tanh( 0.785398 ) = 0.655794 ****************************************/ }
![]()
acos -- Calculate Arccosine
asin -- Calculate Arcsine
atan - atan2 -- Calculate Arctangent
cos -- Calculate Cosine
cosh -- Calculate Hyperbolic Cosine
_fpatan -- Calculate Arctangent
_fptan -- Calculate Tangent
sin -- Calculate Sine
sinh -- Calculate Hyperbolic Sine
tan -- Calculate Tangent
<math.h>
lang(compatmath) option
