C++ Math atanh
The function calculates the inverse hyperbolic tangent of an angle provided in radians.
An inverse hyperbolic tangent, also known as arc hyperbolic tangent, reverses the operation of the hyperbolic tangent function.
Syntax
Suppose an angle given in radian is 'x':
float atanh(float x);
double atanh(double x);
long double atanh(long double x);
double atanh(integral x);
Note: The return_type can be float, double long double.
Parameter
The input parameter 'x' represents the value for which the hyperbolic arctangent will be calculated.
Return value
It returns the arc hyperbolic tangent of x.
| Parameter | Return value |
|---|---|
-1 |
Finite value |
| x= -1 | -inf |
x=1 |
inf |
| x_PRESERVE9__1 | Not a Number(nan) |
Example 1
Let's consider a basic scenario where the value of x falls within the range of -1 to 1.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
float x=0.5;
std::cout << "value of x is :" <<x <<std::endl;
cout<<"atanh(x) : "<<atanh(x);
return 0;
}
Output:
value of x is :0.5
atanh(x) : 0.549306
In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and provides the result of 0.54.
Example 2
Let's examine a basic scenario where the value assigned to x is -1.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int x= -1;
std::cout << "value of x is :" <<x <<std::endl;
cout<<"atanh(x) : "<<atanh(x);
return 0;
}
Output:
value of x is :-1
atanh(x) : -inf
In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and yields the result ?inf.
Example 3
Let's examine a basic scenario where the value assigned to x is 1.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int x=1;
std::cout << "value of x is :" <<x <<std::endl;
cout<<"atanh(x) : "<<atanh(x);
return 0;
}
Output:
value of x is :1
atanh(x) : inf
In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and outputs the result as inf.
Example 4
Let's consider a straightforward illustration where the value of x exceeds 1.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int x=5;
std::cout << "value of x is :" <<x <<std::endl;
cout<<"atanh(x) : "<<atanh(x);
return 0;
}
Output:
value of x is :5
atanh(x) : -nan
In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and yields the result -nan.