tanh(), tanhf(), tanhl() — Calculate hyperbolic tangent
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
Format
#include <math.h>
double tanh(double x);
float tanh(float x); /* C++ only */
long double tanh(long double x); /* C++ only */
float tanhf(float x);
long double tanhl(long double x);
General description
Calculates the hyperbolic
tangent of x, where x is
expressed in radians. The result of the function cannot have a range
error.
Note: These functions work in both IEEE Binary Floating-Point
and hexadecimal floating-point formats. See IEEE binary floating-point for more information about IEEE
Binary Floating-Point.
Returned value
Returns the calculated value of the hyperbolic tangent of x.
If the result underflows, the function returns 0 and sets the errno to ERANGE.
Example
CELEBT02
/* CELEBT02
This example computes x as the hyperbolic tangent of PI/4.
*/
#define _POSIX_SOURCE
#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);
}
Output
tanh( 0.785398 ) = 0.655794
Related information
- math.h
- acos(), acosf(), acosl() — Calculate arccosine
- acosh(), acoshf(), acoshl() — Calculate hyperbolic arccosine
- asin(), asinf(), asinl() — Calculate arcsine
- asinh(), asinhf(), asinhl() — Calculate hyperbolic arcsine
- atan(), atanf(), atanl(), atan2(), atan2f(), atan2l() — Calculate arctangent
- atanh(), atanhf(), atanhl() — Calculate hyperbolic arctangent
- cos(), cosf(), cosl() — Calculate cosine
- cosh(), coshf(), coshl() — Calculate hyperbolic cosine
- sin(), sinf(), sinl() — Calculate sine
- sinh(), sinhf(), sinhl() — Calculate hyperbolic sine
- tan(), tanf(), tanl() — Calculate tangent