coshl Function

Calculates the hyperbolic cosine function of a long double precision floating-point value.

Include

<math.h>

Prototype

long double coshl(long double x);

Argument

x
value for which to return the hyperbolic cosine

Return Value

Returns the hyperbolic cosine of x. It returns infinity if x is ±∞ .

Remarks

If the magnitude of x is too large, a range error occurs, and errno will be set to ERANGE.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <math.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
  long double x, y;

  errno = 0;
  x = -1.0F;
  y = coshl(x);
  if (errno)
    perror("Error");
  printf("The hyperbolic cosine of %Lf is %Lf\n", x, y);

  errno = 0;
  x = 0.0F;
  y = coshl(x);
  if (errno)
    perror("Error");
  printf("The hyperbolic cosine of %Lf is %Lf\n", x, y);

  errno = 0;
  x = 720.0F;
  y = coshl(x);
  if (errno)
    perror("Error");
  printf("The hyperbolic cosine of %Lf is %Lf\n", x, y);
}

Example Output

The hyperbolic cosine of -1.000000 is 1.543081
The hyperbolic cosine of 0.000000 is 1.000000
Error: range error
The hyperbolic cosine of 720.000000 is inf