Namespaces
Variants
Views
Actions

tanh

From cppreference.com
< c‎ | numeric‎ | math
Revision as of 04:59, 27 March 2014 by Newatthis (Talk | contribs)

 
 
 
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

Parameters

arg - floating point value

Return value

Hyperbolic tangent of arg

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

See also

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