Library Function atanh in Math Class
Library Function atanh of math.h Header File in C
On this page we will discuss about library function atanh in math class which is used in C.
The C header file math.h contains the standard math library functions that can be used for performing various mathematical operations. The acosh function returns the arc hyperbolic tangent of x in radians.
Library Function atanh in Math Class used in C
atanh(x) = \tanh^{-1}(x)
Declaration of atanh function
double atanh(double x)
We can find the inverse hyperbolic tangent of different data types like int, float or long double by using the cast operator which explicitly converts the data type to double as given below:
int x = 0; double result; result = atanh(double(x));
float atanhf(float x); long double atanhl(long double x);
Parameters of atanh function
The atanh function accepts a single input value which is greater than or equal to -1 and less than or equal to 1.
Parameter | Description |
---|---|
double value | This value of double function is greater than or equal to 1(-1\leq x\leq 1). |
Return value of atanh function
The atanh function returns inverse hyperbolic tangent when an input parameter is passed to it. The function returns NaN if the parameter passed is less than -1 or greater than 1.
Parameter | Return Value |
---|---|
x=1 | It returns infinite value(\infty). |
x=-1 | It returns a negative infinite value(-\infty). |
x>1 or x<-1 | NaN (not a number) |
-1 < x < 1 | It returns a finite value. |
Implementation of Library Function math.h atanh
The following code shows the use of atanh function with different parameters passed to the function.
#include <stdio.h> #include <math.h> int main() { // constant PI is defined const double PI = 3.1415926; // Declaring temporary variables double y, return_value; // Assigning values to variable y = -0.8; // Calculating arc hyperbolic tangent of parameter y return_value = atanh(y); // Displaying the result of calculation printf("The value of atanh(%.2f) function = %.2lf in radians\n", y, return_value); // converting radians to degree return_value = atanh(y)*180/PI; // Displaying the result of calculation printf("The value of atanh(%.2f) function = %.2lf in degrees\n", y, return_value); // parameter not in range y = 5; // Calculating arc hyperbolic tangent of parameter y return_value = atanh(y); // Displaying the result of calculation printf("The value of atanh(%.2f) function = %.2lf", y, return_value); return 0; }
Output:
The value of atanh(-0.80) function = -1.10 in radians The value of atanh(-0.80) function = -62.95 in degrees The value of atanh(5.00) function = -nan
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment