function
<cmath> <ctgmath>
cosh
double cosh (double x);
float coshf (float x);
long double coshl (long double x);
double cosh (double x);
float cosh (float x);
long double cosh (long double x);
double cosh (double x);
float cosh (float x);
long double cosh (long double x);
double cosh (T x); // additional overloads for integral types
Compute hyperbolic cosine
Returns the hyperbolic cosine of x.
Header
<tgmath.h> provides a type-generic macro version of this function.
Parameters
- x
- Value representing a hyperbolic angle.
Return Value
Hyperbolic cosine of x.
If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range error occurs:
If an overflow
range error occurs, the global variable
errno is set to
ERANGE.
Example
1 2 3 4 5 6 7 8 9 10 11 12
|
/* cosh example */
#include <stdio.h> /* printf */
#include <math.h> /* cosh, log */
int main ()
{
double param, result;
param = log(2.0);
result = cosh (param);
printf ("The hyperbolic cosine of %f is %f.\n", param, result );
return 0;
}
| |
Output:
The hyperbolic cosine of 0.693147 is 1.250000.
|
See also
- sinh
- Compute hyperbolic sine (function
)
- tanh
- Compute hyperbolic tangent (function
)