tanh() — Calculate Hyperbolic Tangent
Format
#include <math.h>
double tanh(double x);
Language Level
ANSI
Threadsafe
Yes
Description
The tanh()
function
calculates the hyperbolic tangent of x,
where x is expressed in radians.
Return Value
The tanh()
function
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 π⁄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);
}
/****************** Output should be similar to: ****************
tanh( 0.785398 ) = 0.655794
*/