📅  最后修改于: 2020-09-25 08:09:43             🧑  作者: Mango
该函数在
[Mathematics] tanh x = tanh(x) [In C++ Programming]
double tanh(double x);
float tanh(float x);
long double tanh(long double x);
double tanh(T x); // For integral type
tanh() 函数以弧度为单位接受单个参数,并以double
, float
或long double
类型返回该角度的双曲正切值。
x的双曲正切由下式给出:
tanh() 函数采用一个强制性参数,以弧度表示双曲角。
tanh() 函数返回参数的双曲正切值。
#include
#include
using namespace std;
int main()
{
double x = 0.50, result;
result = tanh(x);
cout << "tanh(x) = " << result << endl;
// x in Degrees
double xDegrees = 90;
x = xDegrees * 3.14159/180;
result = tanh(x);
cout << "tanh(x) = " << result << endl;
return 0;
}
运行该程序时,输出为:
tanh(x) = 0.462117
tanh(x) = 0.917152
#include
#include
using namespace std;
int main()
{
int x = 5;
double result;
result = tanh(x);
cout << "tanh(x) = " << result << endl;
return 0;
}
运行该程序时,输出为:
tanh(x) = 0.999909