C ++中的atanh()函數(shù)返回弧度數(shù)的反雙曲正切(反雙曲正切)。
atanh()函數(shù)采用單個參數(shù),并以弧度返回該值的反雙曲正切值。
該函數(shù)在<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()函數(shù)采用單個強(qiáng)制性參數(shù),范圍為[-1,1]。
如果該值大于1或小于-1,則發(fā)生域錯誤。
atanh()函數(shù)返回傳遞給它的參數(shù)的反雙曲正切值。
參數(shù)(x) | 返回值 |
---|---|
-1 <x <1 | 有限值 |
x = -1 | -∞ |
x = 1 | ∞ |
x <-1或x> 1 | NaN(不是數(shù)字) |
#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