C++ STL 中的 atanh() 函数
atanh() 函数返回给定角度的反正切双曲线函数或双曲正切的反正切。它是 C++ STL 中的内置函数。
atanh() 函数的语法如下。
atanh(var)
从语法中可以看到,函数 atanh() 接受一个数据类型为 float、double 或 long double 的参数 var。此参数的值应该介于 -1 和 1 之间。它返回 var 的反正切双曲线函数。
以下是一个展示在 C++ 中使用 atanh() 的程序。
示例
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double d = 0.5, ans;
ans = atanh(d);
cout << "atanh("<< d <<") = " << ans << endl;
return 0;
}输出
atanh(0.5) = 0.549306
在上述程序中,首先初始化变量 d。然后使用 atanh() 求出 d 的反正切双曲线函数并存储在 ans 中。最后显示 ans 的值。以下代码段对此进行了说明。
double d = 0.5, ans;
ans = atanh(d);
cout << "atanh("<< d <<") = " << ans << endl;可以使用 atanh() 函数获得的结果转换为度数并进行显示。以下是演示此操作的一个程序。
示例
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double d = 0.5, ans;
ans = atanh(d);
ans = ans*180/3.14159;
cout << "atanh("<<d <<") = " << ans << endl;
return 0;
}输出
atanh(0.5) = 31.473
在上述程序中,使用 atanh() 获得了反正切双曲线函数。然后将此值转换为度数。最后,显示输出。以下代码段对此进行了说明。
double d = 0.5, ans;
ans = atanh(d);
ans = ans*180/3.14159;
cout << "atanh("<< d <<") = " << ans << endl;
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP