📅  最后修改于: 2023-12-03 15:13:55.782000             🧑  作者: Mango
在C++ STL中,math.tanh()
函数用于计算给定参数的双曲正切值。
math.tanh(x)
其中,x
为函数参数,表示要计算双曲正切值的值。
该函数返回计算出的双曲正切值。
以下是使用math.tanh()
函数的示例程序:
#include <iostream>
#include <cmath>
int main() {
double x = 2.0;
std::cout << "双曲正切值为:" << std::tanh(x) << std::endl;
return 0;
}
输出结果为:
双曲正切值为:0.964028
x
可以是任何实数。tanh(x) = (e^x - e^(-x)) / (e^x + e^(-x))
。