Home >>C Math Functions >C math tanh() function

C math tanh() function

C math tanh() function

The C math double tanh(double x) function is used to return the hyperbolic tangent of any given argument x. It takes a single argument and returns the value in type double. This function is defined in <math.h> header file.

Syntax:
double tanh(double x)

Parameters:

x − It is the floating point value.

Here is an example of tanh() function:

#include <stdio.h>
#include <math.h>
int main () {
double x, ret;
x = 0.555;
ret = tanh(x);
printf("The hyperbolic tangent of %lf is %lf degrees", x, ret);
return(0);
}

Output:
The hyperbolic tangent of 0.555000 is 0.504258 degrees
Example-2

#include <stdio.h>
#include <math.h>
int main () {
double x, ret;
x = 0.75;
ret = tanh(x);
printf("The hyperbolic tangent of %lf is %lf degrees", x, ret);
return(0);
}

Output:
The hyperbolic tangent of 0.750000 is 0.635149 degrees

No Sidebar ads