English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++The tanh() function usage and example
The function returns the hyperbolic tangent value of the angle represented in radians in<cmath>Header file definition.
[Math] tanh x = tanh(x) [C++]
double tanh(double x); float tanh(float x); long double tanh(long double x); double tanh(T x); //For integer
The tanh() function accepts a radian parameter and returns the hyperbolic tangent value of the angle in double, float, or long double type.
The hyperbolic tangent of x is:
The tanh() function takes a mandatory parameter, representing the hyperbolic angle in radians.
The tanh() function returns the hyperbolic tangent of the parameter.
#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; }
The output when running the program is:
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; }
The output when running the program is:
tanh(x) = 0.999909