C ++中的tanh()函数返回以弧度表示的角度的双曲正切值。
该函数在<cmath>头文件中定义。
[数学] tanh x = tanh(x) [C++]
double tanh(double x); float tanh(float x); long double tanh(long double x); double tanh(T x); //为整型
tanh()函数接受一个弧度参数,并以double、float或long double类型返回该角度的双曲正切值。
x的双曲正切是:

tanh()函数采用一个强制性参数,以弧度表示双曲角。
tanh()函数返回参数的双曲正切值。
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x = 0.50, result;
result = tanh(x);
cout << "tanh(x) = " << result << endl;
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 <iostream>
#include <cmath>
using namespace std;
int main()
{
int x = 5;
double result;
result = tanh(x);
cout << "tanh(x) = " << result << endl;
return 0;
}运行该程序时,输出为:
tanh(x) = 0.999909