cosh
Compute the hyperbolic cosine of the input radian.
Interface Definition
C interface:
float coshf(float x);
double cosh(double x);
long double coshl(long 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
- The hyperbolic cosine y of the radian angle x is returned. y ∈ [1, +∞]
- If the input is ±0, the return value is +1.
- For coshf, when |x| ≥ 0x1.8p6 (96), the return value is +∞; when |x| ≤ 0x1p-13, the return value is 1.0.
- For cosh, when |x| ≥ 0x1.8p9 (768), the return value is +∞; when |x| ≤ 0x1p-26, the return value is 1.0.
- If the input is ±∞, the return value is +∞.
- If the input is NaN, the return value is NaN.
Dependency
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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: Hyperbolic Functions