cosh(), coshf(), coshl() — Calculate hyperbolic cosine

Standards

Standards / Extensions C or C++ Dependencies

ISO C
POSIX.1
XPG4
XPG4.2
ISO/ANSI C++
C99
Single UNIX Specification, Version 3
C++ TR1 C99

both  

Format

#include <math.h>

double cosh(double x);
float cosh(float x);                  /* C++ only */
long double cosh(long double x);      /* C++ only */
float coshf(float x);
long double coshl(long double x);

General description

Calculates the hyperbolic cosine of x. The value x is expressed in radians.
Note: These functions work in both IEEE Binary Floating-Point and hexadecimal floating-point formats. See IEEE binary floating-point for more information about IEEE Binary Floating-Point.

Returned value

If the result overflows, the function returns +HUGE_VAL and sets errno to ERANGE.

Example

CELEBC27
⁄* CELEBC27                                      

   This example calculates y to be the hyperbolic cosine of x.                  
                                                                                
 *⁄                                                                             
#include <math.h>                                                               
#include <stdio.h>                                                              
                                                                                
int main(void)                                                                  
{                                                                               
   double x,y;                                                                  
                                                                                
   x = 7.2;                                                                     
   y = cosh(x);                                                                 
                                                                                
   printf("cosh( %lf ) = %lf\n", x, y);                                         
}                                                                               
Output
cosh( 7.200000 ) = 669.715755

Related information