Namespaces
Variants
Views
Actions

atanh

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
(C99)
(C99)
atanh
(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       atanhf( float arg );
(since C99)
double      atanh( double arg );
(since C99)
long double atanhl( long double arg );
(since C99)

Computes area hyperbolic tangent of arg

Contents

[edit] Parameters

arg - floating point value

[edit] Return value

Inverse hyperbolic tangent of arg

[edit] Example

#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <string.h>
 
#pragma STDC FENV_ACCESS ON
 
void show_fe_exceptions(void)
{
    printf("current exceptions raised: ");
    if(fetestexcept(FE_DIVBYZERO))     printf(" FE_DIVBYZERO");
    if(fetestexcept(FE_INEXACT))       printf(" FE_INEXACT");
    if(fetestexcept(FE_INVALID))       printf(" FE_INVALID");
    if(fetestexcept(FE_OVERFLOW))      printf(" FE_OVERFLOW");
    if(fetestexcept(FE_UNDERFLOW))     printf(" FE_UNDERFLOW");
    if(fetestexcept(FE_ALL_EXCEPT)==0) printf(" none");
    printf("\n");
}
 
int main(void)
{
    printf("atanh(0.462117)  = %f\n",    atanh(0.462117));
    printf("tanh(0.5)        = %f\n",    tanh(0.5));         /* inverse of atanh */
    printf("atanh(+0.0)      = %+.1f\n", atanh(+0.0));
    printf("atanh(-0.0)      = %+.1f\n", atanh(-0.0));
    printf("atanh(NAN)       = %f\n",    atanh(NAN));
    printf("\n");
 
    /* domain error                       */
    /* "invalid" floating-point exception */
    errno = 0; feclearexcept(FE_ALL_EXCEPT);
    printf("atanh(1.1)       = %f\n",   atanh(1.1));
    printf("%s\n",strerror(errno));
    show_fe_exceptions();
    printf("\n");
 
    /* range and pole errors                     */
    /* "divide-by-zero" floating-point exception */
    /* similarly, atanh(-1.0)                    */
    errno = 0; feclearexcept(FE_ALL_EXCEPT);
    printf("atanh(1.0)       = %f\n",   atanh(1.0));
    printf("%s\n",strerror(errno));
    show_fe_exceptions();
 
    return 0;
}

Possible output:

atanh(0.462117)  = 0.500000
tanh(0.5)        = 0.462117
atanh(+0.0)      = +0.0
atanh(-0.0)      = -0.0
atanh(NAN)       = nan
 
atanh(1.1)       = -nan
Numerical argument out of domain
current exceptions raised:  FE_INVALID
 
atanh(1.0)       = inf
Numerical result out of range
current exceptions raised:  FE_DIVBYZERO

[edit] See also

(C99)
area hyperbolic sine
(function) [edit]
(C99)
area hyperbolic cosine
(function) [edit]
hyperbolic tangent
(function) [edit]

[edit] External links

Weisstein, Eric W. "Inverse Hyperbolic Tangent." From MathWorld--A Wolfram Web Resource.