tanh function(Hyperbolic Tangent) in C Language – example and detail

In the C Programming Language, the tanh characteristic returns the hyperbolic tangent of x.


The syntax for the tanh feature in the C Language is:

double tanh(double x);

Parameters or Arguments


A value expressed in radians (not degrees).


The tanh function returns the hyperbolic tangent of x.

Required Header

In the C Language, the required header for the tanh function is:

#include <math.h>

Applies To

In the C Language, the tanh function can be used in the following versions:

ANSI/ISO 9899-1990

tanh Example

/* Example using tanh by TechOnTheNet.com */

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the tanh of */
    value = 0.5;

    /* Calculate the Hyperbolic Tangent of value */
    result = tanh(value);

    /* Display the result of the calculation */
    printf("The Hyperbolic Tangent of %f is %f\n", value, result);

    return 0;

When compiled and run, this utility will output:

The Hyperbolic Tangent of 0.500000 is 0.462117

Similar Functions

Other C features that are similar to the tanh function:

cosh function <math.h>

sinh function <math.h>

See Also

Other C functions that are noteworthy when dealing with the tanh function:

acos characteristic asin characteristic atan characteristic atan2 feature cos function sin feature tan function