Calculates the hyperbolic tangent of a number #include <math.h> double tanh ( double x); float tanhf ( float x); (C99) long double tanhl ( long double x); (C99) The tanh( ) function returns the hyperbolic tangent of its argument x, which is defined as sinh(x)/cosh(x). Example
double x = -0.5, y1, y2;
y1 = tanh(x);
y2 = exp(2*x);
y2 = (y2 -1) / (y2 + 1);
printf("The tanh( ) function returns %.15f.\n", y1 );
printf("Using the function exp( ) yields %.15f.\n", y2 );
This code produces the following output: The tanh( ) function returns -0.462117157260010. Using the function exp( ) yields -0.462117157260010. See Alsosinh( ), cosh( ), atanh( ); the hyperbolic tangent and inverse tangent functions for complex numbers, ctanh( ) and catanh( ) |