C++ Math atanh()
C++ Math atanh()
该函数计算以弧度表示的角度的反双曲正切值。
其中,反双曲正切值是双曲正切的逆运算。
语法
假设以弧度表示的角度为" x":
float atanh(float x);
double atanh(double x);
long double atanh(long double x);
double atanh(integral x);
注意: return_type可以是浮点型,也可以是double long double。
参数
x : 要计算其弧双曲正切值的值。
返回值
它返回x的弧双曲正切值。
参数 |
返回值 |
-1
|
有限值 |
x =-1 |
-inf |
x = 1 |
inf |
x <-1或x> 1 |
不是数字(南) |
示例1
让我们看一下x的值介于-1和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;
}
输出:
value of x is :0.5
atanh(x) : 0.549306
在此示例中,atanh(x)函数计算x的双曲正切值并返回值0.54、
示例2
让我们看一下x的值为-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;
}
输出:
value of x is :-1
atanh(x) :-inf
在此示例中,atanh(x)函数计算x的双曲正切值并返回值?inf。
示例3
让我们看看x的值等于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;
}
输出:
value of x is :1
atanh(x) : inf
在此示例中,atanh(x)计算x的双曲正切值并返回值inf。
示例4
让我们看一下简单x的值大于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;
}
输出:
value of x is :5
atanh(x) :-nan
在此示例中,atanh(x)计算x的双曲正切值并返回值-nan。