English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++returns the hyperbolic cosine value of the angle expressed in radians.
The cosh() function in<cmath>defined in the header file.
[Math] cosh x = cosh(x) [C++ Language]
double cosh(double x); float cosh(float x); long double cosh(long double x); double cosh(T x); // For integral type.
The COSH() function takes a single parameter in radians and returns the hyperbolic cosine of the angle as a double, float, or long double type.
The hyperbolic cosine of x is given by the following formula:
The cosh() function takes a mandatory parameter, representing the hyperbolic angle in radians.
The cosh() function returns the hyperbolic cosine value of the parameter.
If the size of the result is too large to be represented by the return type value, the function will return HUGE_VAL with the correct sign and an overflow range error will occur.
#include <iostream> #include <cmath> using namespace std; int main() { double x = 4.55, result; result = cosh(x); cout << "cosh(x) = " << result << endl; double xDegrees = 90; x = xDegrees * 3.14159/180; result = cosh(x); cout << "cosh(x) = " << result << endl; return 0; }
When the program is executed, the output is:
cosh(x) = 47.3215 cosh(x) = 2.50918
#include <iostream> #include <cmath> using namespace std; int main() { int x = -3; double result; result = cosh(x); cout << "cosh(x) = " << result << endl; return 0; }
When the program is executed, the output is:
cosh(x) = 10.0179