該函數計算以弧度給出的角度的雙曲正切值。
數學上
tanhx = ex-e-x/ex+e-x
用法
假設角度為 'x':
float tanh(float x);
double tanh(double x);
long double tanh(long double x);
double tanh(integral x);
參數
x:要計算其雙曲正切的值。
返回值
它返回 x 的雙曲正切值。
例子1
讓我們看一個簡單的例子,當 x 的值是整數類型時。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int degree =60;
float x = degree*3.14/180;
std::cout << "Value of degree is:" <<degree<< std::endl;
cout<<"tanh(x):"<<tanh(x);
return 0;
}
輸出:
Value of degree is:60 tanh(x):0.780507
在此示例中,tanh(x) 函數計算 x 的雙曲正切並返回值 0.78。
例子2
讓我們看一個簡單的例子,當 x 的值是浮點類型時。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
float degree = 45.2;
float x = degree*3.14/180;
std::cout << "Value of degree is:" <<degree<< std::endl;
cout<<"tanh(x):"<<tanh(x);
return 0;
}
輸出:
Value of degree is:45.2 tanh(x):0.657552
在此示例中,tanh(x) 函數計算 x 的雙曲正切並返回值 0.65。
相關用法
- C++ Math tan()用法及代碼示例
- C++ Math tgamma()用法及代碼示例
- C++ Math trunc()用法及代碼示例
- C++ Math scalbn()用法及代碼示例
- C++ Math acosh()用法及代碼示例
- C++ Math asinh()用法及代碼示例
- C++ Math isgreater()用法及代碼示例
- C++ Math fabs()用法及代碼示例
- C++ Math islessgreater()用法及代碼示例
- C++ Math log2()用法及代碼示例
- C++ Math nearbyint()用法及代碼示例
- C++ Math log()用法及代碼示例
- C++ Math nextafter()用法及代碼示例
- C++ Math fdim()用法及代碼示例
- C++ Math isfinite()用法及代碼示例
- C++ Math erfc()用法及代碼示例
- C++ Math sinh()用法及代碼示例
- C++ Math scalbln()用法及代碼示例
- C++ Math cosh()用法及代碼示例
- C++ Math fma()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ Math tanh()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。