该函数计算以弧度表示的角度的双曲正切值。
数学上
假设角度为" x":
float tanh(float x); double tanh(double x); long double tanh(long double x); double tanh(integral x);
x :要计算其双曲正切值的值。
它返回x的双曲正切。
让我们看一下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。
链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-tanh-function.html
来源:LearnFk无涯教程网
让我们看一下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。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)