Namespaces
Variants
Views
Actions

tanh

From cppreference.com
< c‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)(C99)(C99)
Exponential functions
(C99)
(C99)
(C99)
(C99)
Power functions
(C99)
(C99)
Trigonometric and hyperbolic functions
tanh
(C99)
(C99)
(C99)
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Nearest integer floating point operations
(C99)(C99)(C99)
(C99)
(C99)(C99)(C99)
Floating point manipulation functions
(C99)(C99)
(C99)
(C99)
Classification
(C99)
(C99)
(C99)
Macro constants
 
Defined in header <math.h>
float       tanhf( float arg );
(since C99)
double      tanh( double arg );
long double tanhl( long double arg );
(since C99)

Computes hyperbolic tangent of arg

Contents

[edit] Parameters

arg - floating point value

[edit] Return value

Hyperbolic tangent of arg

[edit] Example

#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <float.h>
 
int main()
{
    printf("tanh(0.5)       = %f\n",    tanh(0.5));
    printf("atanh(0.462117) = %f\n",    atanh(0.462117));   /* inverse of tanh */
    printf("tanh(+0.0)      = %+.1f\n", tanh(+0.0));
    printf("tanh(-0.0)      = %+.1f\n", tanh(-0.0));
    printf("tanh(+INFINITY) = %+.1f\n", tanh(+INFINITY));
    printf("tanh(-INFINITY) = %+.1f\n", tanh(-INFINITY));
    printf("tanh(NAN)       = %f\n",    tanh(NAN));
    printf("\n");
 
    return 0;
}

Possible output:

tanh(0.5)       = 0.462117
atanh(0.462117) = 0.500000
tanh(+0.0)      = +0.0
tanh(-0.0)      = -0.0
tanh(+INFINITY) = +1.0
tanh(-INFINITY) = -1.0
tanh(NAN)       = nan

[edit] See also

computes hyperbolic sine (sh(x))
(function) [edit]
computes hyperbolic cosine (ch(x))
(function) [edit]
(C99)
area hyperbolic tangent
(function) [edit]