C cosh()

The cosh() function defined in the math.h header file. It helps to return the hyperbolic cosine value of the given number in radians. 


double cosh( double x ); #where x should be in double

Also, two functions coshf() and coshl() were used with type float and long double respectively.


float coshf(float x); 
long double coshl(long double x); 

cosh() Parameters:

The cosh() function takes a single parameter. Using cast operator we can explicitly convert the type to double to find the hyperbolic cosine of type int, float, or long double.

Parameter Description Required / Optional
double value Any double value from negative to positive Required

cosh() Return Value

The return value of cosh() function is of type double in radians.

Input Return Value
any value from negative to positive double value in radians

Examples of cosh() 

Example 1: Working of cosh() function in C?


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

int main()
{
    double v, output;

    v = 0.5;
    output = cosh(v);
    printf("The Hyperbolic cosine of %lf (in radians) is %lf\n", v, output);

    v = -0.5;
    output = cosh(v);
    printf("The Hyperbolic cosine of %lf (in radians) is %lf\n", v, output);

    v = 0;
    output = cosh(v);
    printf("The Hyperbolic cosine of %lf (in radians) is %lf\n", v, output);

    v = 1.5;
    output = cosh(v);
    printf("The Hyperbolic cosine of %lf (in radians) is %lf\n", v, output);

    return 0;
}

Output:


The Hyperbolic cosine of 0.500000 (in radians) is 1.127626
The Hyperbolic cosine of -0.500000 (in radians) is 1.127626
The Hyperbolic cosine of 0.000000 (in radians) is 1.000000
The Hyperbolic cosine of 1.500000 (in radians) is 2.352410

Example 2: How cosh() works in C?


#include <stdio.h>
#include <math.h>
int main () {
   double v;

   v = 1.0;
   printf("The hyperbolic cosine of %lf is %lf\n", v, cosh(v));

   return(0);
}

Output:


The hyperbolic cosine of 1.000000 is 1.543081