Calculates the inverse hyperbolic tangent of a number include <math.h> double atanh ( double x ); float atanhf ( float x ); long double atanhl ( long double x ); The atanh( ) functions return the number whose hyperbolic tangent is equal to their argument x. Because the hyperbolic tangent of any number is between -1 and +1, atanh( ) incurs a domain error if the absolute value of the argument is greater than 1. Furthermore, a range error may result if the absolute value of the argument is equal to 1. Example
double x[ ] = { -1.0, -0.5, 0.0, 0.5, 0.99, 1.0, 1.01 };
puts(" x atanh(x) \n"
" ---------------------------------------");
for ( int i = 0; i < sizeof(x) / sizeof(x[0]); ++i )
{
errno = 0;
printf("%+15.2f %+20.10f\n", x[i], atanh(x[i]) );
if ( errno)
perror("atanh");
}
This code produces the following output:
x atanh(x)
---------------------------------------
-1.00 -inf
atanh: Numerical argument out of domain
-0.50 -0.5493061443
+0.00 +0.0000000000
+0.50 +0.5493061443
+0.99 +2.6466524124
+1.00 +inf
atanh: Numerical argument out of domain
+1.01 +nan
atanh: Numerical argument out of domain
See AlsoOther hyperbolic trigonometry functions for real numbers: asinh( ), acosh( ), sinh( ), cosh( ), and tanh( ); the hyperbolic tangent and inverse hyperbolic tangent functions for complex numbers: ctanh( ) and catanh( ) |