C ++中的atanh()函数返回弧度数的反双曲正切(反双曲正切)。
atanh()函数采用单个参数,并以弧度返回该值的反双曲正切值。
该函数在<cmath>头文件中定义。
tanh-1 x = atanh(x)
double atanh(double x); float atanh(float x); long double atanh(long double x); double atanh(T x); // 为整型
atanh()函数采用单个强制性参数,范围为[-1,1]。
如果该值大于1或小于-1,则发生域错误。
atanh()函数返回传递给它的参数的反双曲正切值。
| 参数(x) | 返回值 |
|---|---|
| -1 <x <1 | 有限值 |
| x = -1 | -∞ |
| x = 1 | ∞ |
| x <-1或x> 1 | NaN(不是数字) |
#include <iostream>
#include <cmath>
#define PI 3.141592654
using namespace std;
int main()
{
double x = 0.32, result;
result = atanh(x);
cout << "atanh(x) = " << result << " radian" << endl;
cout << "atanh(x) = " << result*180/PI << " degree" << endl;
return 0;
}运行该程序时,输出为:
atanh(x) = 0.331647 radian atanh(x) = 19.002 degree
#include <iostream>
#include <cmath>
#define PI 3.141592654
using namespace std;
int main()
{
int x = 1;
double result;
result = atanh(x);
cout << "atanh(x) = " << result << " radian" << endl;
cout << "atanh(x) = " << result*180/PI << " degree" << endl;
return 0;
}运行该程序时,输出为:
atanh(x) = inf radian atanh(x) = inf degree