tanh()函数以及C ++中的示例
C++tanh()函数
tanh()函数是cmath标头的库函数,用于查找给定值(双曲线角)的双曲正切,它接受数字(x)并返回x的双曲正切。
tanh()函数语法:
tanh(x);
参数:x–是用于计算双曲正切值的数字(双曲天使)。
返回值:double-返回double类型的值,它是双曲线角度x的双曲线正切值。
示例
Input:
float x = 2.45;
Function call:
tanh(x);
Output:
0.985217C++代码演示tanh()函数示例
//示例
//tanh()功能
#include <iostream>
#include <cmath>
using namespace std;
//main()部分
int main(){
float x;
x = -10.23;
cout<<"tanh("<<x<<"): "<<tanh(x)<<endl;
x = 0;
cout<<"tanh("<<x<<"): "<<tanh(x)<<endl;
x = 2.45;
cout<<"tanh("<<x<<"): "<<tanh(x)<<endl;
return 0;
}输出结果
tanh(-10.23): -1 tanh(0): 0 tanh(2.45): 0.985217
参考:C++tanh()函数