Library Function cosh in Math Class

Library Function cosh of math.h Header File in C

On this page we will discuss about library function cosh in math class which is used in C.
The C header file math.h contains the standard math library functions that can be used for performing various mathematical operations. The cosh function returns the hyperbolic cosine of x in radians.
Library Function cosh in Math Class

Library Function cosh in Math Class used in C

  • In C programming language the cosh function is included in math.h header file.
  • The cosh function takes input argument which is an angle in radians and returns the hyperbolic cosine of that angle x. The range of the cosh function in C depends on the type of the argument passed to the function and the limitations of the data type used to store the result.

Declaration of cosh function

double cosh(double x) 
We can find the inverse hyperbolic cosine of different data types like float or long double by using the specific functions coshf and coshl respectively.
float coshf( float arg);
long double coshl(long double arg);

Parameters of cosh function

The x parameter is the angle in radians. The function returns a value of type double, which is the hyperbolic cosine of the angle.

Return value of cosh function

  • The cosh function returns the principal value of hyperbolic cosine of parameter x that lies in the range of function and it’s return type is double.
  • If the parameter x is outside of the range of the function or its magnitude is too large then the cosh function will return a range error.

Implementation of Library Function math.h cosh

The following code shows the use of cosh function with different parameters passed to the function.
Run
#include<stdio.h>
#include<conio.h> 
int main ()
{
    // Declaration of temporary variables
    double a, answer;
    // Calculating hyperbolic cosine of different parameters
    a = 0.67;
    answer = cosh(a);
    printf("The hyperbolic cosine of %lf (in radians) = %lf\n", a, answer);

    a = -0.67;
    answer = cosh(a);
    printf("The hyperbolic cosine of %lf (in radians) = %lf\n", a, answer);
    a = 0;
    answer = cosh(a);
    printf("The hyperbolic cosine of %lf (in radians) = %lf\n", a, answer);
    a = 3.8;
    answer = cosh(a);
    printf("The hyperbolic cosine of %lf (in radians) = %lf\n", a, answer);
    return 0;
}

Output:

The hyperbolic cosine of 0.670000 (in radians) = 1.232973
The hyperbolic cosine of -0.670000 (in radians) = 1.232973
The hyperbolic cosine of 0.000000 (in radians) = 1.000000
The hyperbolic cosine of 3.800000 (in radians) = 22.361778

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription