cosh
Compute the hyperbolic cosine value of a real number.
Interface Definition
C interface:
float coshf(float x);
double cosh(double x);
Fortran interface:
RES = COSHF(X);
RES = COSH(X);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of a radian angle |
Input |
Return Value
- Return the hyperbolic cosine function value y of the radian angle x. y ∈ [1, +∞].
- If the input is ±0, the return value is +1.
- If the input value of coshf is greater than 0x1.8p6f, +∞ is returned. If the input value of cosh is greater than 0x1.8p9, +∞ is returned.
- If the input value of coshf is less than -0x1.8p6f, +∞ is returned. If the input value of cosh is less than -0x1.8p9, +∞ is returned.
- If the input is ±∞, the return value is +∞.
- If the input is NaN, the return value is NaN.
Dependencies
C: "km.h"
Fortran: "km.f03"
Examples
C interface:
double pi = acos(-1);
// typical usage
double a = pi/3, b = pi/2, c = -3*pi/4, d = 0.0;
// special handling
double e = INFINITY, f = -INFINITY, g = NAN;
// print result
printf("cosh(pi/3) = %.15f\n", cosh(a));
printf("cosh(pi/2) = %.15f\n", cosh(b));
printf("cosh(-3*pi/4) = %.15f\n", cosh(c));
printf("cosh(0.0) = %.15f\n", cosh(d));
printf("cosh(INFINITY) = %.15f\n", cosh(e));
printf("cosh(-INFINITY) = %.15f\n", cosh(f));
printf("cosh(NAN) = %.15f\n", cosh(g));
/*
* cosh(pi/3) = 1.600286857702386
* cosh(pi/2) = 2.509178478658057
* cosh(-3*pi/4) = 5.322752149519959
* cosh(0.0) = 1.000000000000000
* cosh(INFINITY) = inf
* cosh(-INFINITY) = inf
* cosh(NAN) = nan
*
* */
Fortran interface:
REAL(8) :: X = 0.0
PRINT*, COSH(X)
!
! OUTPUT
! 1.000000000000000
!
Parent topic: Function Syntax