C ++中的tanh()函數(shù)返回以弧度表示的角度的雙曲正切值。
該函數(shù)在<cmath>頭文件中定義。
[數(shù)學] tanh x = tanh(x) [C++]
double tanh(double x); float tanh(float x); long double tanh(long double x); double tanh(T x); //為整型
tanh()函數(shù)接受一個弧度參數(shù),并以double、float或long double類型返回該角度的雙曲正切值。
x的雙曲正切是:

tanh()函數(shù)采用一個強制性參數(shù),以弧度表示雙曲角。
tanh()函數(shù)返回參數(shù)的雙曲正切值。
#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