C programming atanh , atanhf and atanhl function


In C programming the <math.h> atanh,atanhf and atanhl compute the arc hyperbolic tangent of the argument.The declaration of the functions are given below.

1 float atanh(float x);
2 double atanh(double x)
3 long double atanh(long double x);
4 float atanhf(float x);
5 long double atanhl(long double x);

Parameters:
x -The value whose arc hyperbolic tangent is to be computed.

Return type
floating point value -The arc hyperbolic tangent of ‘x’.

All the functions are the same,they compute the arc hyperbolic tangent of ‘x’.The 1st,2nd and the 3rd function have the same name i.e.’atanh’.The 4th and 5th function have different names.What does having a different names mean is explained in detail below.

Some points to note:
i) atanh(x) is same as tanh-1(x).

ii)If the argument is not in the interval [-1,+1] domain error occurs-a ‘nan‘ is returned.

iii)If the argument equals +1 or -1 range error may occur-an ‘±inf‘ is returned.

Code example

double d=0.1200 , x1=-1 ;

float f=0.1200 ;

long double ld=0.1200 ;

printf(“%lf”, atanh( d ) ) ; //calls the 2nd version
printf(“\n%f”, atanh( f ) ) ; //calls the 1st version
printf(“\n%Lf”, atanh( ld ) ) ;//calls the 3rd version

printf(“\n%lf”, atanh( x1 ) ) ;
printf(“\n%lf”, atanh(INFINITY) ) ;

Output in Visual Studio,

0.120581
0.120581
0.120581
-inf
nan

If the argument is -1 ‘-inf’ is returned.


 


atanhf

The ‘atanhf‘ function is same as the 1st function.This means the parameter and return type of the function is float type.The ‘f‘ character appended to ‘atanhf‘ stands for float and it signify the parameter and return type of the function.

Code example

float x= 0.991 ;

printf(“%f”, atanh( x ) ); //Calls the 1st version
printf(“\n%f”, atanhf( 0.991 ) ); Calls the 4th version

Output,

2.699584
2.699584


atanhl

The ‘atanhl‘ function is same as the 3rd function.This means the parameter and return type of the function is long double type.The ‘l‘ character appended to ‘atanhl‘ stands for long double and it signify the parameter and return type of the function.

Code example

long double x= 0.991 ;

printf(“%Lf”, atanh( x ) ); //Calls the 3rd version
printf(“\n%Lf”, atanhl( 0.991 ) ); //Calls the 5th version

Output,

2.699584
2.699584